public bool Eq(MyRowData other) { if (other == null || other.Datas == null || other.Datas.Count != Datas.Count) { return(false); } for (int i = 0; i < Datas.Count; i++) { if (other.Datas[i].Content != Datas[i].Content) { return(false); } } return(true); }
private static Dictionary <string, MyRowData> LoadData(string fileName, SheetMetaManager.AddData func, bool isWrite, out ExcelPackage epo) { var dict = new Dictionary <string, MyRowData>(); var fi = new FileInfo(fileName); ExcelPackage ep = ExcelFileOpener.Open(fi, isWrite); { var workbook = ep.Workbook; for (int i = 1; i <= workbook.Worksheets.Count; i++) { var sheetIn = workbook.Worksheets[i]; int colCount = 0; if (sheetIn.Dimension != null) { colCount = sheetIn.Dimension.End.Column; for (int col = 2; col <= colCount; col++) { var dt = sheetIn.GetValue(9, col); if (dt == null) { colCount = col; break; } } } bool isRegular = colCount > 0 && sheetIn.Dimension.End.Row >= 13 && sheetIn.Cells[13, 1].Text == "BEGIN"; if (!isRegular) { continue; } func(sheetIn.Name, colCount); for (int row = 14; row <= sheetIn.Dimension.End.Row; row++) { if (row >= 14 && sheetIn.GetValue(row, 2) == null) { break; } var dts = new List <CellData>(); dts.Add(new CellData()); //excel下标从1开始 for (int col = 1; col <= colCount; col++) { CellData cellInfo = new CellData(); var cell = sheetIn.Cells[row, col]; if (cell != null) { if (!string.IsNullOrEmpty(cell.Formula)) { cellInfo.Content = cell.Formula; cellInfo.IsFormula = true; } else { cellInfo.Content = cell.Text; } } dts.Add(cellInfo); } var rowData = new MyRowData(); rowData.Datas = dts; dict[string.Format("{0}-key={1}", sheetIn.Name, dts[2].Content)] = rowData; } } } if (isWrite) { epo = ep; } else { ep.Dispose(); epo = null; } return(dict); }
public static void SetMyRow(this DataGridViewRow row, MyRowData myRow) { dictRow[row] = myRow; }