猿问

如何通过 linqtoexcel 从 excel 电子表格的列中找到最大值?

我想通过使用 linqtoexcel 找到 excel 列的最大值。


ColumnA ColumnB

   1       1

   2       4

   3       3

这将返回


“最大 ColumnA 为 3” “最大 ColumnB 为 4”


慕桂英546537
浏览 118回答 1
1回答

白衣染霜花

将您的工作簿列映射到 POCOpublic class WorkSheetClass{&nbsp; &nbsp; public int ColumnA { get; set; }&nbsp; &nbsp; public int ColumnB { get; set; }}然后使用 LinqToExcelstring pathToExcelFile = @"C:\workbook1.xlsx";string workbookName = "workbook1";var columnAMaxValue = new ExcelQueryFactory(pathToExcelFile)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Worksheet<WorkSheetClass>(workbookName)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Max(x => x.ColumnA);
随时随地看视频慕课网APP
我要回答