锁定单元格原理 给所有单元格赋值上锁样式,如有不设置只读的,赋值为未上锁样式,主要代码

            ISheet sheet = workBook.CreateSheet(sheetName);
            workBook.GetSheetAt(0).ProtectSheet("password");
            //解除锁定样式
            ICellStyle cellstyleUnLock = workBook.CreateCellStyle();
            cellstyleUnLock.IsLocked = false;//解锁
            //锁定样式
            ICellStyle style1 = workBook.CreateCellStyle();
            style1.IsLocked = true;//上锁  

          foreach (DataColumn column in sourceTable.Columns)
                {
          //支付金额允许修改
                    if (column.ColumnName != "支付金额")
                        dataRow.GetCell(column.Ordinal).CellStyle = style;
                    else
                        dataRow.GetCell(column.Ordinal).CellStyle = cellstyleUnLock;

         }

 

相关文章:

  • 2022-01-19
  • 2022-01-04
  • 2021-08-10
  • 2021-10-09
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案