我有一个使用 EPPlus
生成的 excel,我想获取工作表中的所有列名。我试过使用 LinqToExcel
var excelFile = new ExcelQueryFactory(excelPath)
IQueryable<Row> excelSheetValues = from workingSheet in excelFile.Worksheet(sheetName) select workingSheet;
string[] headerRow = excelFile.GetColumnNames(sheetName).ToArray();
但它抛出一个错误,我们不能使用 linq 获取 excel 的列名以用于 epplus,因为它在使用 Micrsoft Office dll 时工作正常
最佳答案
尝试这样的事情。
var sheet= package.Workbook.Worksheets[1];
foreach (var firstRowCell in sheet.Cells[sheet.Dimension.Start.Row, sheet.Dimension.Start.Column, 1, sheet.Dimension.End.Column])
MessageBox.Show(firstRowCell.Text);
关于c# - 如何从使用 EPPLUS 生成的 excel 中获取列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31174590/