Reading Excel data in columns using OpenXML

Is there a way to read an excel sheet column and not in rows using OpenXML-SDK and C #.

I already tried using the EPPlus package, but ran into some problems because my application also uses ".xslm" files that are not supported by EPPlus. So, I need a solution in OpenXML to read data in columns.

If anyone has an example, this will help.

Thanks Sri

+3
source share
1 answer
    WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.First().Id);


// Get the cells in the specified column and order them by row.
IEnumerable<Cell> cells = worksheetPart.Worksheet.Descendants<Cell()
.Where(c => string.Compare(GetColumnName(c.CellReference.Value),
columnName, true) == 0).OrderBy(r => GetRowIndex(r.CellReference));

foreach (var cell in cells)
{

}
+2
source

Source: https://habr.com/ru/post/1785952/


All Articles