|
|
|
|
Re: Forms 10g. How to create pie chart in Excel sheet [message #548507 is a reply to message #546872] |
Thu, 22 March 2012 08:58 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/b5b79e171d5930939e12fee5f638c84a?s=64&d=mm&r=g) |
calacausi
Messages: 23 Registered: March 2012
|
Junior Member |
|
|
hi,
I think it is possible to build the pie chart using OLE2, instead of installing some external tool. So, I am struggling with Excel sheet features; but instead of a pie chart, I got a histogram, and the data source is wrong.
Here is the code I wrote to build the chart
workcharts:=OLE2.GET_OBJ_PROPERTY(workbook,'CHARTS');
WORKCHART := ole2.Invoke_obj(workcharts, 'Add');
OLE2.SET_PROPERTY(workchart, 'NAME', 'CHART');
--set chart data source. P_NAME is the name of data sheet (i.e. SUMMARY COSTS 2011-2012-2026)
--J is the row index where data are stored (i.e. A12:D13)
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Sheets("' || P_NAME || '").Range("A' || (J-1) || ':D' || J || '")');
OLE2.ADD_ARG(args, 'xl3DPieExploded');
-- OLE2.ADD_ARG(args, 'xlColumns');
OLE2.INVOKE(workchart, 'SetSourceData', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.RELEASE_OBJ(workchart);
OLE2.RELEASE_OBJ(workcharts);
...
for you to understand the example, I attached pics of data sheet, expected pie chart and the resulting (wrong) chart.
![/forum/fa/9981/0/](/forum/fa/9981/0/)
As you can see, the histogram covers all data, and not the range I put in args list.
Furthermore, I would prefer to put the chart within the data sheet and not in a separate sheet. Can someone give me a help?
-
Attachment: test.jpg
(Size: 175.36KB, Downloaded 2919 times)
|
|
|
|
Re: Forms 10g. How to create pie chart in Excel sheet [message #548598 is a reply to message #548508] |
Fri, 23 March 2012 06:30 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](http://www.gravatar.com/avatar/b5b79e171d5930939e12fee5f638c84a?s=64&d=mm&r=g) |
calacausi
Messages: 23 Registered: March 2012
|
Junior Member |
|
|
I created a chart by hand and saved steps into a macro. This is the resulting code
Sub chart()
'
' chart Macro
'
'
Range("A12:D13").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Range( _
"'SUMMARY COSTS 2011-2012-2026'!$A$12:$D$13")
End Sub
maybe the missing step in my oracle procedure is the first (Range("A12:D13").Select). How can I get this? I tried to do it using an arglist
args:=OLE2.create_arglist;
STR_FORMULA := 'A' || (J-1); --A12
OLE2.add_arg(args, STR_FORMULA);
STR_FORMULA := 'D' || J; --D13
OLE2.add_arg(args, STR_FORMULA);
myRange:=OLE2.get_obj_property(worksheet, 'Range', args);
OLE2.SET_PROPERTY(myRange,'selected',true);
OLE2.destroy_arglist(args);
then I set workchart datasource to myRange; but it doesnt work. I hope you can help me. thanks
|
|
|