NPOI 保护 sheet XSSF excel 工作簿
NPOI protect sheet XSSF excel workbook
我只需要保护以这种方式生成的 xssf Excel 中的一行(例如 rowNum 0)(使用库 NPOI 版本 2.2.1.0)
ISheet sheet_for_dropdown_list = Workbook.CreateSheet("DropDownList");
实际上保护命令仅用于通过密码
完全保护sheet
sheet_for_dropdown_list.ProtectSheet("admin");
然后我尝试解锁第 1 行设置 属性
isLocked false in a style
ICellStyle extCellStyle = Workbook.CreateCellStyle();
unprotectCellStyle.IsLocked = false
IRow1 row1= sheet_for_dropdown_list.GetRow(1);
并取消保护所有单元格
foreach (ICell cell in row1)
cell.CellStyle = unprotectCellStyle;
可以对> 0 的所有行执行此操作
此解决方案部分有效,因为可以修改单元格内容但不能修改列的高度。因此在空闲单元格中无法插入高度大于实际高度列的内容。
我认为您要设置 header 行的高度。您可以指定高度或环绕文本或两者兼而有之。
要指定高度,请参阅 this link。要包装文本,请使用以下语法
XSSFCellStyle headerStyle = (XSSFCellStyle)workbook.CreateCellStyle();
headerStyle.WrapText = true;
我只需要保护以这种方式生成的 xssf Excel 中的一行(例如 rowNum 0)(使用库 NPOI 版本 2.2.1.0)
ISheet sheet_for_dropdown_list = Workbook.CreateSheet("DropDownList");
实际上保护命令仅用于通过密码
完全保护sheetsheet_for_dropdown_list.ProtectSheet("admin");
然后我尝试解锁第 1 行设置 属性 isLocked false in a style
ICellStyle extCellStyle = Workbook.CreateCellStyle();
unprotectCellStyle.IsLocked = false
IRow1 row1= sheet_for_dropdown_list.GetRow(1);
并取消保护所有单元格
foreach (ICell cell in row1)
cell.CellStyle = unprotectCellStyle;
可以对> 0 的所有行执行此操作
此解决方案部分有效,因为可以修改单元格内容但不能修改列的高度。因此在空闲单元格中无法插入高度大于实际高度列的内容。
我认为您要设置 header 行的高度。您可以指定高度或环绕文本或两者兼而有之。
要指定高度,请参阅 this link。要包装文本,请使用以下语法
XSSFCellStyle headerStyle = (XSSFCellStyle)workbook.CreateCellStyle();
headerStyle.WrapText = true;