HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("测试锁定单元格");
//1.设置Sheet保护
sheet.protectSheet("123");
HSSFCellStyle cellstyle = wb.createCellStyle();
//2.设置单元格是否锁定
cellstyle.setLocked(false);
HSSFRow row0 = sheet.createRow(0);
HSSFCell cell00 = row0.createCell(0);
cell00.setCellValue("山东小伙伴");
cell00.setCellStyle(cellstyle);
FileOutputStream out = new FileOutputStream("模板.xlsx");
wb.write(out);
out.close();
HSSFSheet sheet = wb.createSheet("测试锁定单元格");
//1.设置Sheet保护
sheet.protectSheet("123");
HSSFCellStyle cellstyle = wb.createCellStyle();
//2.设置单元格是否锁定
cellstyle.setLocked(false);
HSSFRow row0 = sheet.createRow(0);
HSSFCell cell00 = row0.createCell(0);
cell00.setCellValue("山东小伙伴");
cell00.setCellStyle(cellstyle);
FileOutputStream out = new FileOutputStream("模板.xlsx");
wb.write(out);
out.close();