You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by shankarrao <sh...@gmail.com> on 2011/01/28 15:29:22 UTC

How to determine if CellFormat is NULL

Could you please let me know how to determine if the cellFormat is NULL?
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-CellFormat-is-NULL-tp3361528p3361528.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


Re: How to determine if CellFormat is NULL

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Thanks, that was what I needed to know, at least I think it was.

What JExcel calls formatting is, I think, what we refer to as a cells style.
Therefore, all you will have to do is call the getCellStyle() method on the
cell and see if that is eqaul to null, someting like this;

Cell cell = row.getCell(0);
if(cell.getCellStyle() == null) {
    ......
}

POI refers to a cells style as the collection of attributes that define it's
appearance, the font used, the alignment of the cells contents, etc. Data
format is the string of characters used within Excel to actually determine
how the characters that appear within the cell will be laid out. So a
formatting string of 0,000.00 woiuld format the numeric contents of a cell
as a decimal number with the comma used as the thousand separator and a full
stop as the decimal separator. Further, the data format is one of the
attributes of the cells style, usually.

Hope that helps.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-CellFormat-is-NULL-tp3361528p3363255.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


Re: How to determine if CellFormat is NULL

Posted by shankarrao <sh...@gmail.com>.
Hi Mark,

To recollect, we are switching from jExcel API to Apache POI. Hence we have
to rewrite the existing code in Apache POI.

Below is the code in jExcel. We need to rewrite this code snippet in Apache
POI.
if(sheet.getCell(col,row).getCellFormat()==null) {
sheet.addCell(new Number(col,row,1234,currencyFormat));
}

In jExcel, the method getCellFormat() is used to get the cell format which
applies to a cell. For cell with a cell type of EMPTY, which has no
formatting information, this method will return null. Some empty cells (e.g.
on template spreadsheets) may have a cell type of EMPTY, but will actually
contain formatting information.

Please let me know if the explanation provided above is clear and do let me
know if you require more information in this regard.

-Shankar


-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-CellFormat-is-NULL-tp3361528p3362760.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


Re: How to determine if CellFormat is NULL

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
May I ask why you want to know if a cells format is null?

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/How-to-determine-if-CellFormat-is-NULL-tp3361528p3361607.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