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

x33g5p2x  于2022-01-29 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(153)

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

Sheet.protectSheet介绍

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

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

/**
  * Write protect Sheet by setting password works only for xls output at the moment
  */
 protected void protectSheet( Sheet sheet, String password ) {
  if ( sheet instanceof HSSFSheet ) {
   // Write protect Sheet by setting password
   // works only for xls output at the moment
   sheet.protectSheet( password );
  }
 }
}

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

String file = "c:\\poitest.xlsx";
FileOutputStream outputStream = new FileOutputStream(file);
Workbook wb = new XSSFWorkbook();

CellStyle unlockedCellStyle = wb.createCellStyle();
unlockedCellStyle.setLocked(false);

Sheet sheet = wb.createSheet();
sheet.protectSheet("password");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("TEST");
cell.setCellStyle(unlockedCellStyle);

wb.write(outputStream);
outputStream.close();

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

String file = "c:\\poitest.xlsx";
FileOutputStream outputStream = new FileOutputStream(file);
Workbook wb = new XSSFWorkbook();

CellStyle unlockedCellStyle = wb.createCellStyle();
unlockedCellStyle.setLocked(false);

Sheet sheet = wb.createSheet();
sheet.protectSheet("password");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("TEST");
cell.setCellStyle(unlockedCellStyle);

wb.write(outputStream);
outputStream.close();

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

String file = "C:\\poitest.xlsx";
   FileOutputStream outputStream = new FileOutputStream(file);
   Workbook wb = new XSSFWorkbook();
   CellStyle unlockedCellStyle = wb.createCellStyle();
   unlockedCellStyle.setLocked(false);
   Sheet sheet = wb.createSheet();
   sheet.protectSheet("password");
   Row row = sheet.createRow(0);
   Cell cell = row.createCell(0);
   cell.setCellValue("TEST");
   cell.setCellStyle(unlockedCellStyle);
   Cell cell2 = row.createCell(1);
   cell2.setCellValue("TEST2");
   wb.write(outputStream);
   outputStream.close();

相关文章

微信公众号

最新文章

更多