Hi Robert,
I think you have a good idea.
I'm not sure why it was done the way it was done. Perhaps the rows are
not really sortable that way - there may be internal settings.
The reason is more likely that the original use of POI was either to
read to extract information or to write out a report. Now I think that
there are people who want to update a spreadsheet with POI and then
return it to the user.
I'm curious which sort would you apply to the TreeMap? It may make
sense to extend HSSFSheet / XSSFSheet with a sort api.
If you want to try it yourself, you are certainly free to download the
poi source and make TreeMap accessible. I'm willing to take a look at
your result and we can see if it makes a good contribution to the
project.
Regards,
Dave
On Feb 11, 2009, at 11:05 AM, Schmid, Robert D. wrote:
I am facing a situation where I need to sort an excel file. After
much
searching I determined that the functionality is not there.
So I opened the source and began to poke around. After reading the
source I have come to the conclusion that it has been deliberately
written to make sorting impossible.
In the HSSFSheet, rows are stored as a TreeMap - an inherently
sortable
map but the rows use themselves as keys. The HSSFRow implements
comparable but uses its own row numbers as the comparison value.
I could easily extend these classes for sorting IF
The rows TreeMap was accessible outside the class. It is not.
I could extend HSSFRow and override the compareTo method but HSSFRow
is
'final'.
So, why is it implemented this way? Are there some advantages to this
implementation that make it worth blocking out the inherent sort
features of a TreeMap?
Robert Schmid
Senior Research Scientist
Southwest Research Institute
(210) 522-2909
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]