3

有没有办法使用 OpenXML-SDK 和 C# 读取 excel 表列而不是行。

我已经尝试过使用 EPPlus 包,但遇到了一些问题,因为我的应用程序还使用了 EPPlus 不支持的“.xslm”文件。所以,我需要一个 OpenXML 解决方案来读取列中的数据。

如果有人有一个例子,那将有所帮助。

谢谢斯里

4

1 回答 1

2
    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)
{

}
于 2011-03-14T19:52:28.937 回答