简体   繁体   中英

How to set existing excel file data format 'text' using java

We have an excel file which may be large . We want to set cell format to 'text' to avoid issue like '=cmd', which may run '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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM