You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sachinadams <sa...@gmail.com> on 2012/08/09 14:06:31 UTC
XSSF cellType setting to number
The following code fails to set the cell type. Other types are properly set
but number seems to have issues. The HSSF Implimentation does not have this
issue.
Please respond, if there are workarounds or its a known defect.
-------------------------------------------------------------
Workbook wb = new XSSFWorkbook();
Cell cell = row.createCell(1);
System.out.println("BEFORE SETTING : [" + cell.getCellType()+"]");
*cell.setCellType(Cell.CELL_TYPE_NUMERIC);*
System.out.println("AFTER SETTING : [" + cell.getCellType()+"]");
OUTPUT::
BEFORE SETTING : [3]
AFTER SETTING : [3]
-------------------------------------------------------------
Sachin
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-cellType-setting-to-number-tp5710637.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: AW: XSSF cellType setting to number
Posted by Nick Burch <ap...@gagravarr.org>.
On Wed, 27 Nov 2013, Bhargav Tandel wrote:
> Yes you are right we didn't set cell type.But question is, it was
> working fine even though we didn't set cell type in HSSF. why it should
> not working with XSSF. Why in XSSF cell type is required? And as your
> comment if i initiate cell type with "Cell.CELL_TYPE_BLANK", it will
> also wrong result but if i initiate cell type with
> "Cell.CELL_TYPE_STRING ", it will working fine.
What do you think you are gaining by setting a cell type but no value?
Cell types really only make sense in conjunction with some value in the
cell...
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: AW: XSSF cellType setting to number
Posted by Bhargav Tandel <bh...@gmail.com>.
Hi marcell
Yes you are right we didn't set cell type.But question is, it was working
fine even though we didn't set cell type in HSSF. why it should not working
with XSSF. Why in XSSF cell type is required?
And as your comment if i initiate cell type with "Cell.CELL_TYPE_BLANK", it
will also wrong result but if i initiate cell type with
"Cell.CELL_TYPE_STRING ", it will working fine.
Hope you understood my question.
Thanks.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-cellType-setting-to-number-tp5710637p5714358.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
AW: XSSF cellType setting to number
Posted by Marcell Jobs <mj...@integrationmatters.com>.
Hi Bhargav, hi Sachin,
it seems to be, that it has something to do with the blank cell type and XSSF:
Workbook wb = new XSSFWorkbook();
// wb = new HSSFWorkbook();
Sheet sh = wb.createSheet();
Row row = sh.createRow(0);
Cell cell = row.createCell(1,Cell.CELL_TYPE_BLANK);
System.out.println("BEFORE SETTING : [" + cell.getCellType()+"]");
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
System.out.println("AFTER SETTING : [" + cell.getCellType()+"]");
Output:
BEFORE SETTING : [3]
AFTER SETTING : [3]
If you switch it to HSSFWorkbook, it works fine:
Output:
BEFORE SETTING : [3]
AFTER SETTING : [0]
Question: Why don't you set the cell type, when you instantiate the cell?
Regards,
Marcell
________________________________________
Von: Bhargav Tandel <bh...@gmail.com>
Gesendet: Mittwoch, 20. November 2013 13:33
An: user@poi.apache.org
Betreff: Re: XSSF cellType setting to number
Hi sachin
i have faced same issue as u have. I don't no the actual root cause of
behind that issue but i have got solution for that.i used createCell()
method with two argument.Second argument passed type string.
Workbook wb = new XSSFWorkbook();
Cell cell = row.createCell(1,Cell.CELL_TYPE_STRING);
System.out.println("BEFORE SETTING : [" + cell.getCellType()+"]");
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
System.out.println("AFTER SETTING : [" + cell.getCellType()+"]");
OUTPUT::
BEFORE SETTING : [1]
AFTER SETTING : [0]
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-cellType-setting-to-number-tp5710637p5714303.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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: XSSF cellType setting to number
Posted by Bhargav Tandel <bh...@gmail.com>.
Hi sachin
i have faced same issue as u have. I don't no the actual root cause of
behind that issue but i have got solution for that.i used createCell()
method with two argument.Second argument passed type string.
Workbook wb = new XSSFWorkbook();
Cell cell = row.createCell(1,Cell.CELL_TYPE_STRING);
System.out.println("BEFORE SETTING : [" + cell.getCellType()+"]");
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
System.out.println("AFTER SETTING : [" + cell.getCellType()+"]");
OUTPUT::
BEFORE SETTING : [1]
AFTER SETTING : [0]
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-cellType-setting-to-number-tp5710637p5714303.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