poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MSB <markbrd...@tiscali.co.uk>
Subject Re: Sorting by column(s)
Date Mon, 18 Jan 2010 16:40:53 GMT

As far as I am aware, it is not possible to sort the data in columns using
POI.

Have you considered using Java's support for collections to help you
overcome this problem - the Arrays.sort() method may be of some help and if
not, it is always possible to create your own sorting algorithms. Then all
you would need to do is write the data into one of the collections classes,
sort that and then retrieve the data to populate the worksheet. Thinking
about this further, the JTable class may be the way to go; I know that it is
possible to sort this on columns and I can see that it should be possible to
create a JTable, populate it with data, sort the model and then retrieve the
sorted data to populate the worksheet. Sadly, it has been a long time since
I used Java to create GUIs and so I cannot remember all of the details but I
am confident it is possible, here is a good place to start
http://www.java2s.com/Tutorial/Java/0240__Swing/1100__JTable-Sort.htm. You
may not even need to use the complex JTable object but can simply use the
model part of it's MCV design pattern, the
javax.swing.table.DefaultTableModel class.

Yours

Mark B


dcg wrote:
> 
> Hi,
> 
> How does one sort by one or more columns in POI?
> 
> Undoubtfully this is a very basic (and simple?) question but for some
> reason
> i can't find any mention of it anywhere, nor am i able to locate a method
> in
> the API the suggests column-sorting.
> I sincerely hope its due to the fact that i'm overlooking something
> bacause
> sorting a sheet seems quite basic.
> 
> Any suggestions/ links as to how to sort columns would be much
> appreciated.
> 
> Tia,
> 
> Fermin DCG
> 
> 

-- 
View this message in context: http://old.nabble.com/Sorting-by-column%28s%29-tp27209292p27213160.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message