DataExcel 设置单元格,列,行只读 ReadOnly属性


  ///清除所有行,列,合并单元格,扩展单元格,等
            dataexcel1.Clear();
            ///初始化默认行,列
            dataexcel1.Init();
             
            //获取行 通过GetRow函数获取行会自动创建行 
            IRow row = dataexcel1.GetRow(1);
            row.Height = 30; 
            row = dataexcel1.GetRow(2);
            //设置行只读
            row.InhertReadOnly = false;
            row.ReadOnly = true;
            row.BackColor = Color.AliceBlue;
            row.Height = 30;
            row = dataexcel1.GetRow(3);
            row.Height = 30;

            IColumn column = dataexcel1.GetColumn(1);
            column.Width = 120; 
            column = dataexcel1.GetColumn(2);
            //设置列只读
            column.InhertReadOnly = false;
            column.ReadOnly = true;
            column.Width = 120;
            column.BackColor = Color.AntiqueWhite;
            column = dataexcel1.GetColumn(3);
            column.Width = 120;
            column = dataexcel1.GetColumn(4);
            column.Width = 120;

            ICell cell = dataexcel1[1, 1];
            cell.Name = "name1";
            cell.Value = "只读单元格";
            //设置单元格只读
            cell.ReadOnly = true;
            cell.InhertReadOnly = false;

            cell = dataexcel1[2, 1];
            cell.Name = "name2";
            cell.Value = "只读单元格";
            //设置单元格只读
            cell.ReadOnly = true;
            cell.InhertReadOnly = false;


            cell = dataexcel1[3, 2];
            cell.Value = "只读列";


            cell = dataexcel1[2, 4];
            cell.Value = "只读行";




效果如图:





























评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值