private static void POC_ReadExcelWorksheetsRowsAndColumns()
{
string excelFile = @"C:\Raw Excel.xlsx";
using (ExcelPackage package = new ExcelPackage(new FileInfo(excelFile)))
{
foreach (ExcelWorksheet workSheet in package.Workbook.Worksheets)
{
// Make sure its not a blank sheet:
if (workSheet.Dimension == null) continue;
{
string excelFile = @"C:\Raw Excel.xlsx";
using (ExcelPackage package = new ExcelPackage(new FileInfo(excelFile)))
{
foreach (ExcelWorksheet workSheet in package.Workbook.Worksheets)
{
// Make sure its not a blank sheet:
if (workSheet.Dimension == null) continue;
// Get dynamic row and column count:
int rowCount = workSheet.Dimension.End.Row;
int columnCount = workSheet.Dimension.End.Column;
int rowCount = workSheet.Dimension.End.Row;
int columnCount = workSheet.Dimension.End.Column;
Console.WriteLine("Worksheet name: {0}, with {1} rows and {2} columns", workSheet.Name, rowCount, columnCount);
Console.WriteLine("workSheet.Dimension.Rows: {0}", workSheet.Dimension.Rows);
Console.WriteLine("workSheet.Dimension.Columns: {0}", workSheet.Dimension.Columns);
Console.WriteLine(string.Format("Cell A1 value is {0}", workSheet.Cells["A1"].Value));
}
}
}
Console.WriteLine("workSheet.Dimension.Columns: {0}", workSheet.Dimension.Columns);
Console.WriteLine(string.Format("Cell A1 value is {0}", workSheet.Cells["A1"].Value));
}
}
}
Comments
Post a Comment