I believe that I have code (Basic) and "Calc as a simple database" from my web site and now available from the documentation project in the Calc section.

As for speed, can you set all the data at one time (or in large groups) using setData or setDataArray?

Denis Camargo wrote:
Hi. I really need help in a few issues:


1) how can I turn autofilters on in a spreadsheet via java macro? I
found that the service DatabaseRange has a property Autofilter, that
should be set to true to activate the autofilters.

How do I access this property/service? In the API-DEV, theres an old
thread, but it did not get me anywhere, the guy was even invited to
share his solution as a code snipped, but never did so. (I will =)

The OOBasic macro generated by the macro recorder below activates the
autofilters, but I was unable to reproduce it using Java:

REM ***** BASIC *****
Sub Main
End Sub

sub filters
rem ----------------------------------------------------------------------
rem define variables

dim document as object
dim dispatcher as object

rem ----------------------------------------------------------------------
rem get access to the document

document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DataFilterAutoFilter", "",
0, Array())

end sub





2) I am having a terrible delay in writing the data on the
spreadsheet. My macro has to write around (20-30k rows * 9 cols) of
information (shading some blocks of rows with related info), and takes
around 2 hours to do so.

I can't put a sample of the code here right now, but basically i loop
through the items, with a nested loop for each row of data for that
item, finishing with the shading, like:

for( Pack p : packages) {

   lastRow = rowCount;
   rowCount = 0;
   for( Row r : p) {

       xSpreadsheet.getCell(x, y).setFormula( r.getData1() );
       ...
       xSpreadsheet.getCell(x, y).setFormula(r.getData9() );
       rowCount++;
   }
   range = xSpreadsheet.getCellRange( rows from lastRow to rowCount,
cols 1 to 9)
   range.shade( isShade() );
}
       The code above doesn't work I know that. The real program
works, it just is taking too long to finish.

Is there a way to speedwrite the data? All the data to write to the
spreadsheet is available before I begin to write, so if there is a way
to write to big chunks of cells at once, that is not a problem.

My program works fine, its just it needs a huge optimization. I will
upload some real code once I get to a machine with a working USB port.



3  - On the same massive cell writing subject, how can I access the
menu command "Insert -> Spreadsheet from file..." via macro? Because I
already created a standalone program that writes a tab-separated text
file with the data, and then I manually load the file. I lose all the
formatting the old macro did, but the whole 30k rows process goes from
2 hours to less than 1 minute. Maybe this is an alternative to problem
2.

Thank you so much for reading all that up to here. Hope someone can
shed me some light.

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


--
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