private void barButtonItemIn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (this.treeList1.FocusedNode != null && curDevice != null) { IList <string> filedList = new List <string>(); IList <string> capList = new List <string>(); for (int i = 0; i < curDevice.gridView1.Columns.Count; i++) { if (curDevice.gridView1.Columns[i].Caption.Contains("查看")) { continue; } capList.Add(curDevice.gridView1.Columns[i].Caption); filedList.Add(curDevice.gridView1.Columns[i].FieldName); } OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { try { DataTable table = DeviceHelper.GetExcel(op.FileName, filedList, capList); curDevice.UpdateIn(table); } catch (Exception a) { MessageBox.Show(a.Message); } curDevice.Init(); } } else { MessageBox.Show("没有选择设备(如果没有请添加一个)", "导入EXCEL", MessageBoxButtons.OK); } }