c# - .net 核心的 excel nuget 包

标签 c# excel asp.net-core nuget-package

这个问题在这里已经有了答案:





asp net core export to Excel

(3 个回答)


4年前关闭。




我需要一些 .net 核心库来帮助我创建一个 excel 文件(无论确切的文件扩展名)。

我尝试使用 MICROSOFT.OFFICE.INTEROP.EXCEL.DLL (windows dll),我在nuget画廊中搜索过,我试图找到其他具有核心支持的包,但我没有找到。

有图书馆女巫可以帮助我吗?

最佳答案

您应该尝试 EPPlus.Core:

以下是使用该库读取 Excel 的方法(我自己试过 here):

var filePath = @"D:/test.xlsx";
FileInfo file = new FileInfo(filePath);

using (ExcelPackage package = new ExcelPackage(file))
{       
    ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
    int rowCount = worksheet.Dimension.Rows;
    int ColCount = worksheet.Dimension.Columns;

    var rawText = string.Empty;
    for (int row = 1; row <= rowCount; row++)
    {
        for (int col = 1; col <= ColCount; col++)
        {   
            // This is just for demo purposes
            rawText += worksheet.Cells[row, col].Value.ToString() + "\t";    
        }
        rawText+="\r\n";
    }
    _logger.LogInformation(rawText);
}

在官方页面上,我在这里找到了 ASP.Net Core 中的完整示例:https://github.com/VahidN/EPPlus.Core/tree/master/src/EPPlus.Core.SampleWebApp

胡安

关于c# - .net 核心的 excel nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40487670/

相关文章:

c# - AutoMapper - 自定义映射

c# - Autofac 枚举不适用于类型或模块的多个注册

c# - 查找丢失的鼠标点击

c# - Azure 认知服务 TTS - 示例应用程序中其他语言的错误

vba - 将数据从 Excel 复制到 Word 而不覆盖现有文本

angular - asp.net core prerender webpack 错误 : TypeError: Cannot read property 'filter'

c# - 验证值存储在我的 Web.config 文件中的位置

database - 如何计算日期但排除 Microsoft Access 中的周末?

python - 如何在python中使用openpyxl将范围从一张纸复制到另一张纸作为值

asp.net-core - Raspberry Pi 4 上的 .Net Core 和 Raspbian?