使用Com 组件读取Excel时,如果确认数据范围
for (int i = 1; i < mySheet.Rows.Count; i++) { DataRow dr = dt.NewRow(); for (int j = 1; j < mySheet.Columns.Count; j++) { try { string fla = ((Range)mySheet.Cells[i, j]).Formula.ToString(); Range r = (Range)mySheet.Cells[i, j]; r.Formula = fla; dr[j] = Convert.ToString(r.Value2); } catch { hasCell = false; break; } }