Reading Excel file Rows and Cells C# code
Simple POC did to read Excel file rows and columns. Code extracted from following link.
https://www.codeproject.com/Tips/801032/Csharp-How-To-Read-xlsx-Excel-File-With-Lines-of
public static void ReadExcel()
{
var count = 0;
foreach (var worksheet in Workbook.Worksheets("2010AllItems.xlsx"))
foreach (var row in worksheet.Rows)
{
count++;
foreach (var cell in row.Cells)
{
Console.WriteLine(cell.Text);
// if (cell != null) // Do something with the cells
}
if (count > 2)
break;
}
}
https://www.codeproject.com/Tips/801032/Csharp-How-To-Read-xlsx-Excel-File-With-Lines-of
public static void ReadExcel()
{
var count = 0;
foreach (var worksheet in Workbook.Worksheets("2010AllItems.xlsx"))
foreach (var row in worksheet.Rows)
{
count++;
foreach (var cell in row.Cells)
{
Console.WriteLine(cell.Text);
// if (cell != null) // Do something with the cells
}
if (count > 2)
break;
}
}
Comments
Post a Comment
Your comments...