public static void PopulateInCollection(string fileName) { DataTable table = ExcelToDataTable(fileName); //Iterate through the rows and columns of the Table for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 0; col <= table.Columns.Count; col++) { Datacollection dtTable = new Datacollection() { rowNumber = row, colName = table.Columns[col].ColumnName, colValue = table.Rows[row - 1][col].ToString() }; //Add all the details for each row dataCol.Add(dtTable); } } }
public static void PopulateInCollection(string fileName) { DataTable table = ExcelToDataTable(fileName); //Iterate through the rows and columns of the Table for (int row = 1; row <= table.Rows.Count; row++) { for (int col = 0; col < table.Columns.Count; col++) { Datacollection dtTable = new Datacollection() { rowNumber = row, colName = table.Columns[col].ColumnName, colValue = table.Rows[row - 1][col].ToString() }; //Add all the details for each row dataCol.Add(dtTable); } } }
public static void PopulateInCollection(string fileName, string sheetName) { ClearData(); var table = ExcelToDataTable(fileName, sheetName); //Iterate through the rows and columns of the Table for (var row = 1; row <= table.Rows.Count; row++) { for (var col = 0; col < table.Columns.Count; col++) { var dtTable = new Datacollection { RowNumber = row, ColName = table.Columns[col].ColumnName, ColValue = table.Rows[row - 1][col].ToString() }; //Add all the details for each row DataCol.Add(dtTable); } } }