You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by SM...@empirecorp.org on 2004/05/13 20:15:28 UTC

Problem Formatting a cell in Excel after using HSSFWorkbook

I am creating a HSSFWorkbook with HSSFCell and it works pretty well.
The cells are created using text values not number values and when this is
viewed in Excel none of the cells can be formatted using the Excel format
functions.


If you take the following example:
http://jakarta.apache.org/poi/hssf/quick-guide.html#DataFormats

and change one of the:
	cell.setCellValue(11111.25);
to
	cell.setCellValue("11111.25");

compile and run, you will see this problem when trying to format column A.


Should I submit this as a bug or am I doing something wrong ?


-Thanks
Steve More


NOTICE:  This e-mail may contain confidential or legally privileged
information and is intended solely for delivery to the specific person
identified as the recipient.  Any review, re-transmission, dissemination or
other use or taking of any action in reliance upon this e-mail by persons
other than the intended recipient is prohibited.  If you receive this e-mail
in error, please contact us at (smore@empirecorp.org) and delete from your
computer system, or otherwise from you records, the information, which was
transmitted to you in error.

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


AW: Problem Formatting a cell in Excel after using HSSFWorkbook

Posted by Karl-Heinz Zengerle <ka...@sawag.com>.
Hi Steve.

Try something like

HSSFCellStyle oCS = oWB.createCellStyle();
oCS.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));	// text

Does it also happen then?

I didn't discover such problems up to yet.

Regards,	Karl-Heinz.

-----Ursprüngliche Nachricht-----
Von: SMore@empirecorp.org [mailto:SMore@empirecorp.org] 
Gesendet: Donnerstag, 13. Mai 2004 20:15
An: poi-user@jakarta.apache.org
Betreff: Problem Formatting a cell in Excel after using HSSFWorkbook

I am creating a HSSFWorkbook with HSSFCell and it works pretty well.
The cells are created using text values not number values and when this
is
viewed in Excel none of the cells can be formatted using the Excel
format
functions.


If you take the following example:
http://jakarta.apache.org/poi/hssf/quick-guide.html#DataFormats

and change one of the:
	cell.setCellValue(11111.25);
to
	cell.setCellValue("11111.25");

compile and run, you will see this problem when trying to format column
A.


Should I submit this as a bug or am I doing something wrong ?


-Thanks
Steve More


NOTICE:  This e-mail may contain confidential or legally privileged
information and is intended solely for delivery to the specific person
identified as the recipient.  Any review, re-transmission, dissemination
or
other use or taking of any action in reliance upon this e-mail by
persons
other than the intended recipient is prohibited.  If you receive this
e-mail
in error, please contact us at (smore@empirecorp.org) and delete from
your
computer system, or otherwise from you records, the information, which
was
transmitted to you in error.

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


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


RE: Problem Formatting a cell in Excel after using HSSFWorkbook

Posted by Michael Zalewski <za...@optonline.net>.
I don't understand what you think is a bug.

If you call HSSFCell.setCellValue with a String argument, Excel puts a
string value in the cell. If you call setCellValue with a numeric argument,
Excel puts a number value into the cell (and Excel can format numbers as
dates).

It's the same as if you enter '111111.25 into a cell in Excel. If you do
this, you will see that the cell cannot be formatted as a number (because
the ' character forces the contents of the cell to a string).

Explained another way: In Excel, if you enter 'ABC or ABC into a cell, it is
the same thing, and both are equivalent to setCellValue( "ABC"). If the
first character of the string you want to enter into a cell is an
apostrophe, you actually have to double it up as in

''POI' is cool 	equivalent to	.setCellValue( "'POI' is cool")

But if you want to enter a numeric string into Excel, you must put the
apostrophe before the number, as in '111111.25. (equivalent to
.setCellValue( "111111.25"). If you don't use an apostrophe, you get a
numeric value (equivalent to .setCellValue( 111111.25)

-----Original Message-----
From: SMore@empirecorp.org [mailto:SMore@empirecorp.org]
Sent: Thursday, May 13, 2004 2:15 PM
To: poi-user@jakarta.apache.org
Subject: Problem Formatting a cell in Excel after using HSSFWorkbook

I am creating a HSSFWorkbook with HSSFCell and it works pretty well.
The cells are created using text values not number values and when this is
viewed in Excel none of the cells can be formatted using the Excel format
functions.


If you take the following example:
http://jakarta.apache.org/poi/hssf/quick-guide.html#DataFormats

and change one of the:
        cell.setCellValue(11111.25);
to
        cell.setCellValue("11111.25");

compile and run, you will see this problem when trying to format column A.


Should I submit this as a bug or am I doing something wrong ?


-Thanks
Steve More


NOTICE:  This e-mail may contain confidential or legally privileged
information and is intended solely for delivery to the specific person
identified as the recipient.  Any review, re-transmission, dissemination or
other use or taking of any action in reliance upon this e-mail by persons
other than the intended recipient is prohibited.  If you receive this e-mail
in error, please contact us at (smore@empirecorp.org) and delete from your
computer system, or otherwise from you records, the information, which was
transmitted to you in error.

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


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