[prev in list] [next in list] [prev in thread] [next in thread] 

List:       poi-user
Subject:    Re: The CellType of a cell which is set to String
From:       "Javen O'Neal" <javenoneal () gmail ! com>
Date:       2016-08-12 15:35:00
Message-ID: CAM+TppLeoiCpo4=N7T2==rBRubvjBLwySFzZwWx+a=RiUoByyQ () mail ! gmail ! com
[Download RAW message or body]


To see how Excel actually saved the values, unzip the xlsx file and open
sheet1.xml. You should see a couple <c> elements, with a value and type.

On Aug 12, 2016 8:32 AM, wrote:

The cell data format is a distinct concept from the cell value. The format
only defines how the value should be printed, but doesn't change the
underlying value.

If you want to convert the cell value to a printed string, use
https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html

On Aug 12, 2016 2:59 AM, "niaomingjian@outlook.com" <
niaomingjian@outlook.com> wrote:

Hi

In a excel,
Firstly, I typed '1' in A1, then I changed the format of this cell to
String.
Secondly, I changed the format of A2 to Standard(the default format), then
I typed '1' in this cell.
Finally, I saved this excel.

This is my excel file for test.
I'm using poi 3.14.
My source is very simple, as following:
================================================
File file = new File("1.xlsx");

Workbook wb = WorkbookFactory.create(file);

Sheet sheet = wb.getSheetAt(0);

System.out.println(sheet.getRow(0).getCell(0).getCellType());
System.out.println(sheet.getRow(1).getCell(0).getCellType());

wb.close();
================================================

output:
============
0
1
============

The result shows that A1's type is CELL_TYPE_NUMERIC, and A2's type is
CELL_TYPE_STRING.

Though I set both cells to String, the results are different.

In addition, in this excel, the appearance of these two cells are also
different.
There is a green triangle at the top-right corner of A2.

Could anyone explain this for me?

Regards,
Young


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic