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 <[email protected]>
Gesendet: Mittwoch, 20. November 2013 13:33
An: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]