下载地址:解压包 压缩包内dataexcel为控件
网页版:开源在线excel展示插件JS版
更新地址:DataExcel
-
简介及其使用
- 最新界面
- 控件使用效果
- 打印预览
- 浏览器查看效果
- 打印预览效果
-
一 简介 、DataExcel是由.net 开发的一套表格计算组件
包括 基本的表格视图,编辑控件,图表,公式计算,事件处理,文件格式化,排版,打印,图表。
DataExcel依赖于.net 框架。分别有2.0 4.0版本。
-
比.net 自带的DataGridView多了些功能
- 二 文件构成、
文件包括两个DLL文件。DataExcel.v1.1.dll DataUtils.v1.1.dll (V1.1为版本,根据不同版本文件名不同) DataExcel 为界面组件所在
另外 DataExcel.exe 为使用DataExcel组件开发的轻量级程序(非必须)
三 控件使用、
使用VS新建Winform项目 右键项目引用节点添加引用 需要添加(DataExcel.v1.1.dll,DataUtils.v1.1.dll)的引用
新建WINFORM窗口在工具箱右键并点击"选择项"选择中 DataExcel.v1.1.dll,
工具栏会出现
拖动 DataExcel 至窗口 显示如下
-
示例代码
-
///清除所有行,列,合并单元格,扩展单元格,dataexcel1.Clear();///初始化默认行,列dataexcel1.Init();//获取列IColumn column = dataexcel1.GetColumn(1);//设置列宽column.Width = 100;//获取第五行,第一列的单元格ICell cell = dataexcel1.GetCell("A5");cell.Text = "文本框:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取列column = dataexcel1.GetColumn(2);//设置列宽column.Width = 100;//获取第5行,第一列的单元格cell = dataexcel1.GetCell("B5");cell.Value = "我是编辑框";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为文本框cell.OwnEditControl = new Feng.Excel.Edits.CellTextBoxEdit();//设置进入编辑的方式cell.EditMode = Feng.Enums.EditMode.Focused | Feng.Enums.EditMode.KeyDown | Feng.Enums.EditMode.Click;cell = dataexcel1.GetCell("A6");cell.Text = "单选框:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第6行,第一列的单元格Feng.Excel.Edits.CellRadioCheckBox radioedit = new Feng.Excel.Edits.CellRadioCheckBox();radioedit.Group = "单选组1";cell = dataexcel1.GetCell("B6");cell.Caption = "单选框1";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为单选框cell.OwnEditControl = radioedit;cell = dataexcel1.GetCell("C6");cell.Caption = "单选框2";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为单选框cell.OwnEditControl = radioedit;cell = dataexcel1.GetCell("D6");cell.Caption = "单选框3";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为单选框cell.OwnEditControl = radioedit;cell = dataexcel1.GetCell("A7");cell.Text = "复选框:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第7行,第一列的单元格Feng.Excel.Edits.CellCheckBox checkedit = new Feng.Excel.Edits.CellCheckBox(); cell = dataexcel1.GetCell("B7");cell.Value = true;cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;cell.Caption = "是/否";//设置编辑控件为复选框cell.OwnEditControl = checkedit;cell = dataexcel1.GetCell("A8");cell.Text = "选择日期:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第8行,第一列的单元格Feng.Excel.Edits.CellDateTime datetimeedit = new Feng.Excel.Edits.CellDateTime();cell.FormatType = Feng.Utils.FormatType.DateTime;cell.FormatString = "yyyy-MM-dd";cell = dataexcel1.GetCell("B8");cell.Value = DateTime.Now;cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown; //设置编辑控件为复选框cell.OwnEditControl = datetimeedit; //设置进入编辑的方式cell.EditMode = Feng.Enums.EditMode.Focused | Feng.Enums.EditMode.KeyDown | Feng.Enums.EditMode.Click;cell = dataexcel1.GetCell("A9");cell.Text = "数字选择:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第9行,第一列的单元格Feng.Excel.Edits.CellNumber numberedit = new Feng.Excel.Edits.CellNumber();cell = dataexcel1.GetCell("B9");cell.FormatType = Feng.Utils.FormatType.Numberic;cell.FormatString = "$##0.00";cell.Value = 365.25;cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为复选框cell.OwnEditControl = numberedit;//设置进入编辑的方式cell.EditMode = Feng.Enums.EditMode.Focused | Feng.Enums.EditMode.KeyDown | Feng.Enums.EditMode.Click;cell = dataexcel1.GetCell("A10");cell.Text = "数字文本框:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第10行,第一列的单元格Feng.Excel.Edits.CellNumberBoxEdit numtextedit = new Feng.Excel.Edits.CellNumberBoxEdit(); cell = dataexcel1.GetCell("B10");cell.FormatType = Feng.Utils.FormatType.Numberic;cell.FormatString = "$##0.00";cell.Value = 365.25;cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为复选框cell.OwnEditControl = numtextedit;//设置进入编辑的方式cell.EditMode = Feng.Enums.EditMode.Focused | Feng.Enums.EditMode.KeyDown | Feng.Enums.EditMode.Click;cell = dataexcel1.GetCell("A11");cell.Text = "下拉文本框:";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.Red;//设置编辑控件为LABEL 及为不可编辑cell.OwnEditControl = new Feng.Excel.Edits.CellLabel();//获取第11行,第一列的单元格Feng.Excel.Edits.CellComboBox comboedit = new Feng.Excel.Edits.CellComboBox();cell = dataexcel1.GetCell("B11"); cell.Value = "选项1";cell.BackColor = Color.AliceBlue;cell.ForeColor = Color.RosyBrown;//设置编辑控件为复选框cell.OwnEditControl = comboedit;comboedit.Items.AddRange(new string[] { "选项1", "选项2", "选项3", "选项4", "选项5", "选项6", "选项7" });//设置进入编辑的方式cell.EditMode = Feng.Enums.EditMode.Focused | Feng.Enums.EditMode.KeyDown | Feng.Enums.EditMode.Click;public void SetFunction(){///清除所有行,列,合并单元格,扩展单元格,等dataexcel1.Clear();///初始化默认行,列dataexcel1.Init();ICell cell = null;for (int i = 1; i < 6; i++){for (int j = 1; j < 5; j++){cell = dataexcel1[i, j];cell.Value = i + j;}}dataexcel1[6, 1].Expression = "\"合计:\"&sum(a1:a5)";//& 表示把两个字符串连接到一起dataexcel1[6, 2].Expression = "\"平均:\"&avg(b1:b5)";dataexcel1[6, 3].Expression = "\"数量:\"&count(c1:c5)";dataexcel1.Save(dataexcel1.Version + "_" + DateTime.Now.ToString("yyMMddHHmmss") + (fileindex++).ToString().PadLeft(4, '0') + ".dat");}///清除所有行,列,合并单元格,扩展单元格,等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 = "只读行";///清除所有行,列,合并单元格,扩展单元格,等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");/// <summary>/// 获取行,列,单元格,合并后的合并单元格,并设置颜色/// </summary>public void CellInfo(){///清除所有行,列,合并单元格,扩展单元格,等dataexcel1.Clear();///初始化默认行,列dataexcel1.Init();//获取行 通过集合获取行时不会自动创建行 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");}
-
js excel 在线插件