excel nuget package for .net core
本文关键字:net core for package nuget excel | 更新日期: 2023-09-27 18:17:07
我需要一些库为。net core来帮助我创建一个excel文件(无论确切的文件扩展名)。
我尝试使用MICROSOFT.OFFICE.INTEROP.EXCEL.DLL
(windows dll),我在nuget库中搜索它,我试图找到其他具有核心支持的包,但我没有找到一个。
图书馆有女巫可以帮我吗?
你应该试试EPPlus。核心:
下面是如何使用该库读取Excel的方法(我自己在这里尝试过):
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
胡安