相关疑难解决方法(0)

使用apache poi将列设为只读

我正在使用apache-poi生成excel文件.我需要将第4列设为只读,其余2列将由用户编辑.

我正在用它XSSFCellStyle来实现这个目标,但它对我不起作用.

整个代码是:

Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>();

XSSFCellStyle style5 = wb.createCellStyle();
XSSFFont headerFont = wb.createFont();
headerFont.setBold(true);
style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
style5.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
style5.setFont(headerFont);
style5.setLocked(true); // this line does not get executed.
styles.put("header", style5);
Run Code Online (Sandbox Code Playgroud)

java excel apache-poi

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

apache-poi ×1

excel ×1

java ×1