Thanks for your message Michael,
My problem happens when I read a file (HSSFWorkbook), like using a
template to create my own dynamic Excel file.
For a HSSFWorkbook, and for a HSSFSheet I use a loop to parse each row
(HSSFRow).
To have the HSSFCell, I use this method : oneRow.getCell((short) cellNb)
-If ((the cell has a value inside) && (a style(a border for example)))
{
I get the correct object HSSFCell with the method oneRow.getCell(
(short) cellNb)
}
-If((the cell has NO value)&& (a style(a border for example)))
{
I get the null Object with the method oneRow.getCell((short) cellNb)
To catch the style of this cell, I need to use this method:
HSSFCell.getCellStyle
But it is not possible to apply a method to a null object!
}
I Hope this text makes it more clear.
Benjamin CHALLAMEL
> Benjamin -
>
> If I under stand your question correctly.... HSSFCells have both a Cell
> Style and Cell Type associated with them. If you intend to have an empty
> cell you should set the Cell Type to HSSFCell.CELL_TYPE_BLANK and create a
> Cell Style with the appropriate borders and Data Format, etc. The
> HSSFCell
> class has get/set methods for the Cell Style, Cell Type, and of course the
> Cell Value. To create a new Cell Style see the
> HSSFWorkbook.createCellStyle() method.
>
> I haven't seen this happen before but if you are loosing the formatting
> after you update the value of a cell, you could save the Cell Style before
> you set the Type and Value and then set it back after you set the Type and
> Value to make sure the Cell Style (borders, etc) are set the way you want.
>
> I hope this helps,
>
> - MJD
>
> One somewhat related caveat that is not well documented: You need to try
> to
> share Cell Styles between all cells with identical formatting. Do not
> create a new Cell Style for each cell you create unless they are truly
> formatted uniquely. This creates a management nightmare if you have very
> many Cell Styles, but it's a necessary aspect of the beasties.
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 07, 2006 10:56 AM
> To: [email protected]
> Subject: [Question]HSSFRow.getCell(cellNb),loosing border if no data in
> the
> cell
>
> Hello,
>
> I'm working with this JAR : poi-2.5.1-final-20040804.jar
>
> My problem is about reading a HSSFCell and loosing the border.
>
> We have a HSSFRow.
> I'm getting the value for a HSSFCell from a HSSFRow, with this method:
> oneCell = oneRow.getCell((short) cellNb);
> For both cases (describe after), there is a border on the specified cell:
>
> 1)Case "there is a value in the cell" and a border:
>
> -> "oneRow.getCell((short) cellNb)" return a HSSFCell object, after I can
> set an other value
> -> the value has a border
>
> 2)Case "there is no value in the cell" and a border:
>
> -> "oneRow.getCell((short) cellNb)" return null,
> -> I have to create a HSSFCell (oneCell = oneRow.createCell((short)
> cellNb)) to set the value
> -> I have lost the border.
>
> Do you know if I'm using the API in a wrong way, or maybe the I can get
> the Style of a HSSFCell somewhere?
>
> Thanx in advanced.
>
> Benjamin CHALLAMEL
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
> ****************************************************************************
> This email may contain confidential material.
> If you were not an intended recipient,
> Please notify the sender and delete all copies.
> We may monitor email to and from our network.
> ****************************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> Mailing List: http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/