org.apache.poi.hssf.usermodel.HSSFSheet.protectSheet()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFSheet.protectSheet()方法的一些代码示例,展示了HSSFSheet.protectSheet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFSheet.protectSheet()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFSheet
类名称:HSSFSheet
方法名:protectSheet

HSSFSheet.protectSheet介绍

[英]Sets the protection enabled as well as the password
[中]设置已启用的保护以及密码

代码示例

代码示例来源:origin: stackoverflow.com

  1. HSSFWorkbook wb = new HSSFWorkbook();
  2. HSSFSheet sheet = wb.createSheet("Test");
  3. Row row = sheet.createRow(0);
  4. CellStyle style = wb.createCellStyle();
  5. style.setLocked(true);
  6. cell = row.createCell(0);
  7. cell.setCellStyle(style);
  8. // this is important as locking is pnly activated if sheet is protected
  9. sheet.protectSheet("");

代码示例来源:origin: stackoverflow.com

  1. HSSFWorkbook workbook = new XSSFWorkbook();
  2. // Cell styles. Note the setLocked(true) method call.
  3. HSSFCellStyle lockedNumericStyle = workbook.createCellStyle();
  4. lockedNumericStyle.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
  5. lockedNumericStyle.setLocked(true);
  6. HSSFSheet sheet = workbook.createSheet("Protection Test");
  7. HSSFRow row = sheet.createRow(0);
  8. HSSFCell cell = row.createCell(0);
  9. cell.setCellValue(100);
  10. cell.setCellStyle(lockedNumericStyle);
  11. // This line should cause all locked cells to be protected,
  12. // the user should not be able to change the cells
  13. // contents.
  14. sheet.protectSheet("password");
  15. The password makes it possible to remove the protection from the sheet and makes it possible then for the locked cells to be modified.

代码示例来源:origin: jasperreports/jasperreports

  1. protected void createSheet(String name)
  2. {
  3. sheet = workbook.createSheet(name);
  4. patriarch = sheet.createDrawingPatriarch();
  5. sheet.getPrintSetup().setLandscape(jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE);
  6. short paperSize = getSuitablePaperSize(jasperPrint);
  7. if(paperSize != -1)
  8. {
  9. sheet.getPrintSetup().setPaperSize(paperSize);
  10. }
  11. if(password != null)
  12. {
  13. sheet.protectSheet(password);
  14. }
  15. }

相关文章

HSSFSheet类方法