【问题标题】:How to find max value by linqtoexcel from the column(s) of excel spreadsheet?如何通过 linqtoexcel 从 excel 电子表格的列中找到最大值?
【发布时间】:2019-04-09 22:44:16
【问题描述】:

我想使用 linqtoexcel 查找 excel 列的最大值。

ColumnA ColumnB
   1       1
   2       4
   3       3

这将返回

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

【问题讨论】:

    标签: c# linq-to-excel


    【解决方案1】:

    将您的工作簿列映射到 POCO

    public class WorkSheetClass
    {
        public int ColumnA { get; set; }
        public int ColumnB { get; set; }
    }
    

    然后使用 LinqToExcel

    string pathToExcelFile = @"C:\workbook1.xlsx";
    string workbookName = "workbook1";
    
    var columnAMaxValue = new ExcelQueryFactory(pathToExcelFile)
                                  .Worksheet<WorkSheetClass>(workbookName)
                                  .Max(x => x.ColumnA);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 2020-12-02
      • 2012-04-25
      相关资源
      最近更新 更多