You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by V S P <to...@fastmail.fm> on 2009/05/06 08:03:46 UTC

HSSF sorting by two columns

Hello
I have done my best to search before posting
but did not find the help in all the docs and the API

all I need is to sort (strings) by two columns B and C
(I have 5 total columns)

My preference is that the sort will happen on the 'user' side
when the spreadsheet is opened and not while I am creating it.

Thank you in advance,
VSP
-- 
  V S P
  toreason@fastmail.fm

-- 
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again


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


Re: HSSF sorting by two columns

Posted by MSB <ma...@tiscali.co.uk>.
Sorry to say this but no, I do not think this is possible using 'core'
HSSF/XSSF - though of course I could be wrong.

To my mind you have two options;

1. Create a template file that contains an on activation macro - one that
will run when the user opens the workbook. The macro will contain code to
perform the sort for you and you can use HSSF/XSSF to open the template
file, populate the worksheets with data and then save it all away again.
Sadly, unless you are able to use the Office 2007 .xlsm file extension
(denoting a macro enabled workbook or one containing macros that have been
deemed safe) then the user will be faced with a message telling them the
file contains macros and asking them whether or not themacros should be
enabled or disabled. Of course, if they choose to disable the macros then
the data will not be sorted.

2. The second option is to create some code that will sort the data for you
prior to populating the worksheet. I think that you will have to create some
sort of container that you can write the data to initially, that can be
sorted and then interrogated again so that you can recover the data - sorted
into order - to populate the worksheet. Though it may sound a little
intimidating, I must admit that this is probably the option I would take.


V S P wrote:
> 
> Hello
> I have done my best to search before posting
> but did not find the help in all the docs and the API
> 
> all I need is to sort (strings) by two columns B and C
> (I have 5 total columns)
> 
> My preference is that the sort will happen on the 'user' side
> when the spreadsheet is opened and not while I am creating it.
> 
> Thank you in advance,
> VSP
> -- 
>   V S P
>   toreason@fastmail.fm
> 
> -- 
> http://www.fastmail.fm - Or how I learned to stop worrying and
>                           love email again
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/HSSF-sorting-by-two-columns-tp23400522p23401598.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