On my way to work soon and I have not had any chance to play with code yet
but this may help.

I know that it is possible to lock a row using Excel so that as you scroll
the contents of the worksheet up and down, that row remains in view - that
was one of the things you wished to emulate. Well the other option is to
create a template using Excel that has the first row locked in this way.
Then, you can open it using POI and populate that first row - row 0 - with
your headings safe in the knowledge that when you save the workbook it
should behave as you expected. This would also provide the flexibility you
are after - the number of headings would only be limited by the number of
columns in the row.

In the meantime, I wil play with some code but do not hold out any hope at
all really as I cannot remember seeing a method with an obvious name and I
think that the setRepeatingRowsAndColumns() method defined on the workbook
relates more to printing - though it woul be easy to check that out of
course.

Yours

Mark B


Dave-53 wrote:
> 
> Thanks Mark,
>  
> We use the Old version .xls.  Unfortunately the column headers are
> dynamically created.
>  
> It seems there is no nice way to do it. Thanks,
> Dave
> 
> 
> --- On Sun, 4/25/10, MSB <[email protected]> wrote:
> 
> 
> From: MSB <[email protected]>
> Subject: Re: How to set column header names
> To: [email protected]
> Date: Sunday, April 25, 2010, 7:45 AM
> 
> 
> 
> Hello Dave,
> 
> Without being able to play with some code, and I am on the wrong machine
> for
> that currently, I cannot say definitivly whether the API provides you with
> that ability. However, there is a dodge that you could use if - and this
> is
> the crucial bit - if you know what the column headings are going to be
> before you build the workbook.
> 
> If you do know the column headings in advance, all you need to do is;
> 
> 1. Open Excel.
> 2. Create a new blank workbook.
> 3. Set the column headings exactly as you want them.
> 4. Save the workbook away.
> 
> This is now a template that you will use to create your final file using
> POI. So
> 
> 5. Open that same file using POI.
> 6. Populate the worksheet(s).
> 7. Save the file away again under a different namw (maybe).
> 
> One of the decisions the designers of the api took was to preserve
> anything
> they read in the file. So it ought to be the case that the column headings
> you set will be preserved. Whilst I cannot guarantee this will happen -
> and
> I cannot currently test if, sorry - I am confident that it will.
> 
> Yours
> 
> Mark B
> 
> PS Can you tell us which version of the file format you are targetting
> please, the older binary format (.xls) or the newer OOXML\SpreadsheetML
> format (.xlsx). The reason I ask is that it is also possible to
> post-process
> the xml based files; you can unzip them and using a parser like SAX step
> through the DOM and modify certain areas that POI may not currently touch.
> 
> 
> 
> 
> Dave-53 wrote:
>> 
>> Hi, I got another question:
>>  
>> Is there a way to set column header names? Usually a sheet column header
>> names are 
>> A, B, C,D....
>>  
>> We like to set header names as ID, Name, Age, Grade,....
>>  
>> If the column header names can not be changed, how to add column header
>> that can be anchored at the top? In other words,  the header row will not
>> move during pageDown/up.
>>  
>> We could not find such API. Thanks for help.
>>  
>> Dave
>> 
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://old.nabble.com/How-to-set-column-header-names-tp28355185p28356493.html
> Sent from the POI - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-set-column-header-names-tp28355185p28361392.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to