导入excle读取表头添加到对应的源字段列表里

it2022-05-06  12

void inputexcle() { string msg = string.Empty; try { var ofd = new OpenFileDialog() { Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls", Multiselect = false }; if (ofd.ShowDialog() == DialogResult.Cancel) return; this.btintable.Text = ofd.FileName; dtexcle.Clear(); dtexclebk.Clear(); dtexcle =dtexclebk= BinData.InputExcel(ofd.FileName, ref msg); this.repositoryItemComboBox1.Items.Clear(); foreach (DataColumn cl in dtexcle.Columns) { this.repositoryItemComboBox1.Items.AddRange(new object[] { cl.ColumnName.ToString(),}); } this.repositoryItemComboBox1.Items.AddRange(new object[] { "",}); } catch { MessageBox.Show(msg); } }

repositoryItemComboBox1是gridview中一个combox控件。

转载于:https://www.cnblogs.com/bantongshui/archive/2013/06/06/3170000.html

相关资源:DirectX修复工具V4.0增强版

最新回复(0)