gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 07:42:12 25 4
gpt4 key购买 nike

我正在从头开始创建一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com