2009/5/24 Bernard Marcelly <[email protected]>: > Message de Johnny Rosenberg date 2009-05-24 18:44 : >> >> 2009/5/24 Oliver Brinzing <[email protected]>: >>> >>> Hi Johnny, >>> >>>> With Xray I found not only createSearchDescriptor in a range, but also >>>> createSortDescriptor. However, I can't find any information anywhere >>>> about how to use it. The Search thing is easy and II use it all the >>>> time, like this: >>> >>> >>> http://wiki.services.openoffice.org/wiki/Documentation/OOo3_User_Guides/Calc_Guide/Sorting >> >> Yes, that was one of the examples that I was talking about. So my >> question remains: How can I sort using the method I described in my >> original post, rather than the method described at various places at >> the Internet? >> > (...) >> >> The link you provided is certainly enough for me to being able to >> sort, BUT it doesn't use the Range.createSortDescriptor at all, as far >> as I can see. My question isn't about how I can sort, because there >> are a lot of examples on how to do that, yours are one of them. My >> question is how to use the ”createSortDescriptor” of a range like that >> one described above. >> >> If it's impossible, I wonder why they included ”createSortDescriptor” >> for ranges in the first place. If it's there, it should be possible to >> use, right? >> > > Yes, it is possible to use it, but it's not easy at all ! Because > createSortDescriptor returns an array of PropertyValue, not an object as for > createSearchDescriptor (you can see it with Xray). Then you must find out at > which position is each PropertyValue (eg property "SortFields") that you > have to fill in. It's not possible without a helper routine which scans the > array. It is much simpler to create your own array of PropertyValue and fill > each, like in the Developer's Guide example (in Java) > <http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Sorting> > > Also, sorting is not simple because the argument of sort() routine is an > array of PropertyValue, of which "SortFields" contains another array of > PropertyValue. > > Regards > Bernard > > Thank you very much for your reply, which I think was a pretty good answer to my question. So it is possible but it's not as easy as I hoped. Well, I guess that was pretty much what I wanted to know.
One thing that I really don't like with the OpenOffice.org macro thing, is the use of arrays of arrays. In some cases it would have been so much easier if it was possible to use two dimensional arrays instead. For example, in most cases I write data downwards. First rows are headers and then data follows row by row. Maybe I want to copy all the data of one column to an array? Yeah, right, good luck. Yes, it's possible but surprisingly stupid. Because the data can not be retreived by just copy it from Data(x), because Data(0) contains another array in which one value/string can be found, or something like that, and the same thing with data(1) and so on. This would work fine if I wrote my data column by column, but how often do we do that? Well, sorry for being off topic there for a while, and thanks again for answering my question. Kind regards Johnny Rosenberg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
