//加载数据表 private void TableLoad() { try { DataTable table = ExcelUtils.ImportExcel(this.filename, args.sheetname, args.columns, null, null, false); if (table == null) { return; } for (int i = 0; i < table.Rows.Count; ++i) { if (table.Rows[i].RowState == DataRowState.Detached || table.Rows[i].RowState == DataRowState.Deleted) { continue; } string cell = table.Rows[i][0].ToString().Trim(); if ("表头".Equals(cell)) { int j = 0; foreach (DataColumn col in table.Columns) { col.ColumnName = table.Rows[i][j++].ToString(); } } table.Rows[i].Delete(); if ("BEGIN".Equals(cell)) { break; } } cur_dataView = table.DefaultView; } catch (Exception ex) { ConfigUtils.Error(ex.Message, ex.StackTrace); MessageBox.Show("Error: " + ex.Message); } }