DataExcel 隐藏列头,行头,显示标尺


DataExcel 隐藏列头,行头,显示标尺


            ///清除所有行,列,合并单元格,扩展单元格,等
            dataexcel1.Clear();
            ///初始化默认行,列
            dataexcel1.Init();

            //隐藏列头
            this.dataexcel1.ShowColumnHeader = false;
            //隐藏行头
            this.dataexcel1.ShowRowHeader = false;
            //隐藏 选中时的边框
            this.dataexcel1.ShowSelectRect = false;
            //隐藏 网络线
            this.dataexcel1.ShowGridRowLine = false;
            this.dataexcel1.ShowGridColumnLine = false;
            //显示标尺
            this.dataexcel1.ShowHorizontalRuler = true;
            this.dataexcel1.ShowVerticalRuler = true;
            //隐藏滚动条
            this.dataexcel1.VScroller.Visible = false;
            this.dataexcel1.HScroller.Visible = false;

            //获取行 通过集合获取行时不会自动创建行 
            IRow row = dataexcel1.Rows[5];
            if (row == null)
            {
                row = dataexcel1.ClassFactory.CreateDefaultRow(dataexcel1, 5);
                dataexcel1.Rows.Add(row);
            }
            row.BackColor = Color.RosyBrown;

            //获取行 通过GetRow函数获取行会自动创建行 
            row = dataexcel1.GetRow(6);
            row.BackColor = Color.RoyalBlue;


            //获取行 通过GetRow函数获取行会自动创建行 
            row = dataexcel1.GetRow(1);
            row.Height = 30;
            row.BackColor = Color.RoyalBlue;


            //获取行 通过GetRow函数获取行会自动创建行 
            row = dataexcel1.GetRow(2);
            row.Height = 30;
            row.BackColor = Color.RoyalBlue;

            //获取列 通过集合获取列时不会自动创建列
            IColumn column = dataexcel1.Columns[9];
            if (column == null)
            {
                column = dataexcel1.ClassFactory.CreateDefaultColumn(dataexcel1, 9);
                dataexcel1.Columns.Add(column);
            }
            column.BackColor = Color.SandyBrown;
            column.Width = 120;

            //获取行 通过GetRow函数获取行会自动创建行 
            column = dataexcel1.GetColumn(1);
            column.Width = 190;

            ICell cell = dataexcel1["A1"];
            cell.Text = "我是单元格1";
            cell.BackColor = Color.Aquamarine;
            //获取第二行第1列
            cell = dataexcel1[2, 1];
            cell.Text = "单元格名称:" + cell.Name;
            cell.BackColor = Color.Azure;
            //能过字符串合并
            IMergeCell MergeCell = dataexcel1.MergeCell("B1:F1");
            MergeCell.BackColor = Color.AliceBlue;
            MergeCell.Text = "B1:F1";

            MergeCell = dataexcel1.MergeCell("B2:F2");
            MergeCell.BackColor = Color.AliceBlue;
            MergeCell.Text = "B2:F2";

            //获取合并的单元格 
            //合并后的单元格以最左上角的单元格为基础
            cell = dataexcel1["B2"];
            cell.Text = "我是合并单元格" + cell.Name;
            cell.BackColor = Color.Beige;
            cell.Font = new Font("宋体", 13);
            cell.ForeColor = Color.Red;
            //设置内容居中
            cell.HorizontalAlignment = StringAlignment.Center;
            cell.VerticalAlignment = StringAlignment.Center;

            dataexcel1.Save(dataexcel1.Version + "_" + DateTime.Now.ToString("yyMMddHHmmss") + (fileindex++).ToString().PadLeft(4, '0') + ".dat");







猜你喜欢

转载自blog.csdn.net/zanfeng/article/details/76020071