本文整理了Java中org.apache.poi.hssf.usermodel.HSSFSheet.protectSheet()
方法的一些代码示例,展示了HSSFSheet.protectSheet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFSheet.protectSheet()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFSheet
类名称:HSSFSheet
方法名:protectSheet
[英]Sets the protection enabled as well as the password
[中]设置已启用的保护以及密码
代码示例来源:origin: stackoverflow.com
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Test");
Row row = sheet.createRow(0);
CellStyle style = wb.createCellStyle();
style.setLocked(true);
cell = row.createCell(0);
cell.setCellStyle(style);
// this is important as locking is pnly activated if sheet is protected
sheet.protectSheet("");
代码示例来源:origin: stackoverflow.com
HSSFWorkbook workbook = new XSSFWorkbook();
// Cell styles. Note the setLocked(true) method call.
HSSFCellStyle lockedNumericStyle = workbook.createCellStyle();
lockedNumericStyle.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
lockedNumericStyle.setLocked(true);
HSSFSheet sheet = workbook.createSheet("Protection Test");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
cell.setCellValue(100);
cell.setCellStyle(lockedNumericStyle);
// This line should cause all locked cells to be protected,
// the user should not be able to change the cells
// contents.
sheet.protectSheet("password");
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
protected void createSheet(String name)
{
sheet = workbook.createSheet(name);
patriarch = sheet.createDrawingPatriarch();
sheet.getPrintSetup().setLandscape(jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE);
short paperSize = getSuitablePaperSize(jasperPrint);
if(paperSize != -1)
{
sheet.getPrintSetup().setPaperSize(paperSize);
}
if(password != null)
{
sheet.protectSheet(password);
}
}
内容来源于网络,如有侵权,请联系作者删除!