我需要写一个excel单元格非常大(> 91430000000000000000 )问题是单元格的最大值是9143018315613270000 ,所有更大的值 - 将被最大值替换。 如果将撇号添加到数字中,这个问题将简单地用手解决,例如'9143018315313276189但是如何通过apache POI使用相同的技巧? 我有以下代码:
attrId.setCellValue(new XSSFRichTextString('\'' + value.getId().toString()));但它不起作用:
这里第一行根本没有任何撇号,第二行是用手写的,这是我正在寻找的结果。 第三是我的代码的结果。 我也尝试使用带有double和String的setCellValue,它们都不能帮助我。
所以,这里提出了一个问题:如何通过apache POI在excel中写入非常大的数字?
I need to write to an excel cell a very large numbers(>91430000000000000000) The issue is that max value for cell is 9143018315613270000, and all values which is larger - would be replaced by max value. This issue will simply resolved by hands if an apostrophe is added to an number, for example '9143018315313276189 But how to the same trick via apache POI? I have follow code:
attrId.setCellValue(new XSSFRichTextString('\'' + value.getId().toString()));But it doesn't work:
Here the first row haven't any apostrophe at all, second one is written by hands and it is the result I'm looking for. Third is a result of my code. I also tried to use setCellValue which takes double and String, both of them doesn't help me ether.
So, here goes the question: How to write in excel a very large numbers via apache POI?
最满意答案
首先设置单元格样式
DataFormat format = workbook.createDataFormat(); CellStyle testStyle = workbook.createCellStyle(); testStyle.setDataFormat(format.getFormat("@")); String bigNumber = "9143018315313276189"; row.createCell(40).setCellStyle(testStyle); row.getCell(40).setCellValue(bigNumber);Set the cell style first
DataFormat format = workbook.createDataFormat(); CellStyle testStyle = workbook.createCellStyle(); testStyle.setDataFormat(format.getFormat("@")); String bigNumber = "9143018315313276189"; row.createCell(40).setCellStyle(testStyle); row.getCell(40).setCellValue(bigNumber);更多推荐
发布评论