开发者

Store number in Excel using Apache POI

I am using Apache POI to store data in excel sheet. I can store data like "50%" in the cell. Excel also shows up, but it show error like "Number stored as String".

If i click that message and click "convert number to String". It shows pe开发者_如何学Crfectly.

How to store it without errror using POI


This code will work

Create a style with a format of %

and set the value as a number (double) and not with %

setCellValue(double value)

The output will be 50%

CellStyle style = workBook.createCellStyle();
style.setDataFormat(workBook.createDataFormat().getFormat("0%"));
cell.setCellStyle(style);
cell.setCellValue(0.50); // set value as number
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜