本文整理了Java中org.apache.poi.ss.usermodel.Sheet.protectSheet()
方法的一些代码示例,展示了Sheet.protectSheet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Sheet.protectSheet()
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Sheet
类名称: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();
内容来源于网络,如有侵权,请联系作者删除!