您好,我是在导入excel以后进行的表格设置,因为导入excel后原本设置的一些下拉框都失效了,您可以试一下导入后是否有这个问题呢,看看怎么解决。我把代码贴一下。
- //导入数据按钮
- private void ribbonButton20_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- string s;
- ofd.Filter = "Excel 文件 (*.xlsx)|*.xlsx";
- ofd.RestoreDirectory = true;
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- s = ofd.FileName;
- fpSpread1.OpenExcel(s, FarPoint.Excel.ExcelOpenFlags.TruncateEmptyRowsAndColumns);
- //设置驱油物注入量的单位下拉框类型
- string QuYouWu = fpSpread1.Sheets[1].Cells[7, 4].Text;//先获取值
- FarPoint.Win.Spread.CellType.ComboBoxCellType comboBoxCell = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
- comboBoxCell.Items = (new string[] { "吨", "千立方米" });
- fpSpread1.Sheets[1].Cells[7, 4].CellType = comboBoxCell;
- fpSpread1.Sheets[1].Cells[7, 4].Value = QuYouWu;//设置默认选项
- }
复制代码 |