DataExcel 设置单元格 编辑控件 radiocheck,checkbox,textedit,combotext,numberedit
2017-07-19 16:56
676 查看
///清除所有行,列,合并单元格,扩展单元格, 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;
效果:
相关文章推荐
- vc ListControl设置checkbox风格,时owerdata不能设置为true---m_list.SetItemText()m_list.SetItemData()有关
- Ajax: Excel风格的HTML Table输入控件[五]:单元格的编辑
- [zt]excel为不同的单元格设置不同的编辑密码
- java 使用poi导出Excel,设置单元格保护不可编辑,设置下拉框
- NPOI2.2.0.0实例详解(十)—设置EXCEL单元格【文本格式】 NPOI 单元格 格式设为文本 HSSFDataFormat
- Android代码生成TextView,Button,CheckBox等控件的设置技巧
- DataExcel 设置单元格,列,行只读 ReadOnly属性
- Infragistics控件对UltraWebGrid单元格编辑进行控制及样式设置
- excel设置单元格不可编辑
- MPAndroidChart设置setNoDataTextDescription不起作用
- POI中设置Excel单元格格式
- Excel开发学习笔记:文件选择控件、查找匹配项、单元格格式及数据有效性
- Android 动态的给Button、TextView、ImageView等控件设置了background后,再设置padding属性时该属性不起作用
- 使用NPOI设置Excel表的单元格背景颜色
- c# WinForm开发 DataGridView控件的各种操作总结(单元格操作,属性设置)
- c# WinForm开发 DataGridView控件的各种操作总结(单元格操作,属性设置)
- android控件TextView设置是否可见属性
- VB中如何让text控件设置成透明
- Excel 2010单元格中设置表头
- Excel设置数据有效性实现单元格下拉菜单的3种方法