Hello Sir,
How to read number of rows and column in excel using openxml .
using (SpreadsheetDocument doc = SpreadsheetDocument.Open(path, false))
{
using (DbContext db = new DbContext())
{
var SheetNumber = 1;
WorkbookPart wbPart = doc.WorkbookPart;
string cs = db.CONNECTION_STRING;
int worksheetcount = doc.WorkbookPart.Workbook.Sheets.Count();
Sheet sheet = (Sheet)doc.WorkbookPart.Workbook.Sheets.ChildElements.GetItem(SheetNumber - 1);
Worksheet worksheet = (doc.WorkbookPart.GetPartById(sheet.Id) as WorksheetPart).Worksheet;
IEnumerable<Row> rows = worksheet.GetFirstChild<SheetData>().Descendants<Row>();
IEnumerable<Column> Col = worksheet.GetFirstChild<SheetData>().Descendants<Column>();
foreach (Row row in rows)
{
if (row.RowIndex.Value == Rnumber)
{
dt.Clear();
foreach (Cell cell in row.Descendants<Cell>())
{
dt.Columns.Add(RemoveSpecialCharacters(GetValue(doc, cell)));
}
}
}
}
}