手动添加WorkSheet后Sheet被锁定,设置Protect=false也不行。
关键代码如下
- grdCustoms.Sheets.Clear();
- grdCustoms.Sheets.Add(sheet1);
- grdCustoms.Sheets.Add(sheet2);
- grdCustoms.Sheets.Add(sheet3);
- grdCustoms.Sheets.Add(sheet4);
- sheet1.Protect = false;
- sheet1.SelectionPolicy = SelectionPolicy.MultiRange;
- this.grdCustoms.AutoRefresh = false;
- this.grdCustoms.SuspendCalcService();
- this.grdCustoms.SuspendEvent();
- sheet1.SelectionUnit = SelectionUnit.Cell;
- var v = DataValidator.CreateListValidator("网络,电视,广告,门店");
-
- for (int i = 0; i < 10; i++)
- {
- for (int n = 0; n < 20; n++)
- {
- sheet1.Rows[i].Locked = false;
- sheet1.Cells[1, n].Locked = false;
- sheet1.SetValue(i, n, i * n);
- }
- sheet1.Cells[i, 2].DataValidator = v;
- }
- this.grdCustoms.ResumeEvent();
- this.grdCustoms.ResumeCalcService();
- this.grdCustoms.AutoRefresh = true;
复制代码 |
|