繁体   English   中英

使用OpenXML在列中读取Excel工作表数据

[英]Read excel sheet data in columns using OpenXML

有没有办法使用OpenXML-SDK&C#明智地读取excel工作表列而不是行。

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

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

谢谢斯里兰卡

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

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM