[英]Lock excel work book using apache poi api java
I have to lock a workbook while reading and writing a row.我必须在读取和写入一行时锁定工作簿。
Is there way to accomplish this using Apache
POI API without protecting and password option?.有没有办法在没有保护和密码选项的情况下使用
Apache
POI API 来实现这一点?
As a suggestion, paste some of your code that could help others to understand and solve the problem.作为建议,粘贴一些可以帮助其他人理解和解决问题的代码。
As far as I know you can't "lock" the hole Workbook
but one thing you can try is to apply a CellStyle
to cells you want to protect while reading or writing.据我所知,您无法“锁定”孔
Workbook
但您可以尝试的一件事是将CellStyle
应用于您在阅读或写作时要保护的单元格。
Workbook wb = new XSSFWorkbook();
CellStyle lockedCellStyle = wb.createCellStyle();
lockedCellStyle.setLocked(true);
Sheet sheet = wb.createSheet();
// .... Create rows and cells as needed
// When Writing or reading
Cell cell = getCellsToLockWithAnyMethod();
cell.setCellStyle(lockedCellStyle);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.