Craig Johnson wrote:
Andrew Douglas Pitonyak wrote:
Craig Johnson wrote:

Hi folks! Just joined the [email protected] mailing list.

I'm trying to write some staroffice basic macros to update some charts that display data from weekly updated spreadsheets. I have the macros in place to update the spreadsheet rows with new data but can't find how to access the chart data ranges. I know how to get at them from the Format->Data Ranges popup but I need to change the ranges from within a macro.

Anyone know how to access spreadsheet chart data ranges from a macro?

Depends on what you need or desire to do...

Hi Andrew,

I hope you'll excuse me for bothering you directly with this. I've tried posting on the [email protected] alias but found it to be mostly off-topic rants and/or discussions that have little or nothing to do with using openoffice. I'm getting ready to file what I think is a bug at the api.openoffice.org site but that too seems to be a non-trival task.

But you did NOT email me directly, you emailed this to [email protected] :-)

Do you remember replying to my question above? You were really the only one who gave any useful feedback! I've recently purchased a copy of your OOME book too and have found it quite useful.

But alas, no coverage of charts :-(

The problem I'm facing now has to do with the chart getRanges and setRanges routines you pointed out in your reply to me. I'm having some difficulty understanding why they do not seem to be working for me and have come to a conclusion that it may actually be a bug (or bugs) in the openoffice code itself.

To illustrate my problem(s) I have tried to encapsulate them in a spreadsheet doc with macros that "test" things. I am hoping to find an expert user to review what I am facing and give me some feedback as to whether I'm doing something wrong or have really encountered an openoffice bug.

The attached spreadsheet doc contains the necessary data and instructions.
I would greatly appreciate any feedback you may be able to provide.

Eagerly awaiting your response,
Craig Johnson
Very interesting....

First, let me say that charts are in a strong state of change at the moment, and I have had trouble understanding them. That said, you need to get the embedded object and look at that. For example:

Sub DisplayData()
   CR = Chr$(13)
   SPC = " "

   Dim Sheet as Object
   Sheet = getNamedSheet("Sheet1")

   Dim Charts as Object
   Dim Chart as Object

   Charts = Sheet.getCharts()
   Chart = Charts.getByIndex(0)
   ChartRanges = Chart.getRanges()
   Dim x, i%, j%, y, s$
   x = Chart.getEmbeddedObject().getData().getData()
   For i = LBound(x) To UBound(x)
     y = x(i)
     For j = LBound(y) To UBound(y)
       s = s & y(j) & "  "
     Next
     s = s & CHR$(10)
   Next
   MsgBox s
End Sub

The reason the lower bound on the other is -1, is because calling getRanges returns an empty array. This may be because of the chart type, but that is a wild guess.

The embedded object supports the com.sun.star.chart2.ChartDocument service.

You want to see the ranges?

   x = Chart.getEmbeddedObject().getUsedRangeRepresentations()
   MsgBox Join(x, CHR$(10))

I did find some old code here, that may be of interest

http://lxr.go-oo.org/source/graphics/chart2/qa/TestCaseOldAPI.java

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to