/// <summary> /// /// </summary> /// <param name="xls"></param> /// <param name="sheet">Start from 1</param> /// <returns></returns> public static SheetData GetSheetData(XlsFile xls, int sheet) { xls.ActiveSheet = sheet; SheetData sheetData = new SheetData(); int colCount = xls.GetColCount(sheet); int rowCount = xls.GetRowCount(sheet); int row = 1; for (int col = 1; col <= colCount; col++) { string val = Convert.ToString(xls.GetCellValue(row, col)); if (string.IsNullOrEmpty(val)) { break; } sheetData.Columns.Add(val.Trim()); } colCount = sheetData.Columns.Count(); row++; while (row <= rowCount) { object[] recordRow = new object[colCount]; for (int col = 1; col <= colCount; col++) { recordRow[col - 1] = xls.GetCellValue(row, col); } sheetData.Records.Add(recordRow); row++; } return(sheetData); }
Dictionary <string, string> GetFailTCDefects(XlsFile xls) { Dictionary <string, string> defects = new Dictionary <string, string>(); xls.ActiveSheetByName = "FailTC"; int lastRow = xls.GetRowCount(xls.ActiveSheet); for (var i = 1; i <= lastRow; i++) { string val = Convert.ToString(xls.GetCellValue(i, 1)); if (!string.IsNullOrEmpty(val) && !defects.ContainsKey(val)) { defects.Add(val, "Yes"); } } return(defects); }