java - 如何使用 RangeCellAddress 通过 POI 解锁单元格?

标签 java apache-poi

我正在从头开始创建一个 XSSFSheet 对象,该对象将具有一组属于 header 的单元格,并且必须保护该 header 免受最终用户的影响。电子表格中的所有其他单元格必须能够编辑。我怎样才能实现这个目标?我可以使用 RangeCellAddress 来解锁一组单元格吗?

最佳答案

基于this链接,很简单

Locking cells in HSSF is easier than you might think. You first have to protect the sheet by calling the protectSheet() method of the HSSFSheet class and assigning a password that will be needed to unlock the sheet from within Excel. Once you've done that, call the setLocked() method for each cell style used in the sheet. For the cells you want to be locked, you have to create separate cell styles from the ones for the cells you want unlocked.

XSSFSheetXSSFCellStyle 确实分别有方法 protectSheet()setLocked(),所以我假设它应该可以工作(虽然还没有尝试过)。

关于java - 如何使用 RangeCellAddress 通过 POI 解锁单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11442012/

相关文章:

java - Derby 嵌入式驱动程序错误 XBM02 请确保您的类路径包含正确的 Derby 软件

java - Apache POI解密doc文件无法处理加密文件?

java 将 .xls 转换为 csv

JasperReports 中的 java.util.ConcurrentModificationException

java - 如何防止文件加载时发生 Java 的 OutOfMemoryError?

java - Vaadin 13 Flex 增长

java - 使用 POI 读取 Excel 文件时如何修复 java.lang.ExceptionInInitializerError?

java - Apache POI Excel 公式输入不属于它们的@符号

java - 如何使用 Apache POI 更改 .pptx 文件中的现有自定义属性/属性

Java 反射与代码生成