首页 > 解决方案 > 将 .net core 2.1 升级到 .net core 2.2 时,Linq to excel 不起作用

问题描述

在此处输入图像描述> 我的项目使用的是 .Net core 2.1。我使用 LINQ 来获得

从excel文件中读取数据。当我将项目升级到 .Net core 2.2 时。它不工作。

我从 excel 文件中读取数据的代码是

string pathToExcelFile = "path to excel file."
ExcelHelper ConxObject = new ExcelHelper(pathToExcelFile);

var query = from a in ConxObject.UrlConnexion.Worksheet<ExcelProcessFollowUp>()
            select a;

var data = query.ToList();

//excel的帮助类

public class ExcelHelper
{
    public string _pathExcelFile;
    public ExcelQueryFactory _urlConnexion;

    public ExcelHelper(string path)
    {
        this._pathExcelFile = path;
        this._urlConnexion = new ExcelQueryFactory(_pathExcelFile);
    }

    public string PathExcelFile
    {
        get
        {
            return _pathExcelFile;
        }
    }

    public ExcelQueryFactory UrlConnexion
    {
        get
        {
            return _urlConnexion;
        }
    }
}

但它现在不起作用,请给出一些解决方案。

标签: asp.net-coreeppluslinq-to-excel

解决方案


这是 OleDb 驱动程序在 .Net Core 2.x 版本中不起作用的问题。它应该在 .Net Core 3.0 中修复(请参阅此GitHub 问题

您能否尝试升级到 .Net Core 3.0 并查看 LinqToExcel 是否适合您。


推荐阅读