public static void PopulateInCollection(string fileName, string SheetName) { ExcelLib.ClearData(); DataTable table = ExcelToDataTable(fileName, SheetName); for (int row1 = 0; row1 < table.Rows.Count; row1++) { //DataRow[] rowname = table.Select("BtnAddToCart"); string result = table.Rows[row1][0].ToString(); if (result == "BtnAddToCart") { int index = row1; Console.WriteLine(index); } } //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++) { List <string> rowValue = new List <string> { }; rowValue.Add(table.Rows[row - 1][0].ToString()); Datacollection dtTable = new Datacollection() { rowNumber = row, colName = table.Columns[col].ColumnName, colValue = table.Rows[row - 1][col].ToString(), rowName = table.Rows[row - 1][0].ToString() }; //Add all the details for each row dataCol.Add(dtTable); } } }
public void PopulateInCollection1(string fileName, string SheetName) { ExcelLib.ClearData(); DataTable table = ExcelToDataTable(fileName, SheetName); for (int row1 = 0; row1 < table.Rows.Count; row1++) { List <string> rowValue = new List <string> { }; rowValue.Add(table.Rows[row1][0].ToString()); Console.WriteLine(rowValue); } //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++) { List <string> rowValue = new List <string> { }; rowValue.Add(table.Rows[row - 1][0].ToString()); 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 CollectionFromExcel(string fileName, string SheetName) { ExcelLib.ClearData(); DataTable table = ExcelToDataTable(fileName, SheetName); //Added on 31 Jan noofrows = table.Rows.Count; noofcolumns = table.Columns.Count; //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 async void PopulateInCollection(string fileName, string SheetName) { ExcelLib.ClearData(); DataTable table = await ExcelToDataTable(fileName, SheetName).ConfigureAwait(false); //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); } } }