[英]How to set existing excel file data format 'text' using java
We have an excel file which may be large . 我们有一个excel文件,可能很大 。 We want to set cell format to 'text' to avoid issue like '=cmd', which may run 'cmd'.
我们希望将单元格格式设置为“文本”,以避免类似“ = cmd”的问题,该问题可能会运行“ cmd”。
Does there have any high efficient way to keep excel data format as text but keep other format like backgroud color or font-size? 是否有任何高效的方法可以将excel数据格式保留为文本,但保留其他格式(如背景色或字体大小)?
To set the cell type, you can use: 要设置单元格类型,可以使用:
Cell cell = row.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell.setCellType(CellType.STRING);
This should avoid using formulas in the cells, unless you specifically set the type to CellType.FORMULA
. 这应该避免在单元格中使用公式,除非您将类型专门设置为
CellType.FORMULA
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.