很低级的问题,下载EPplus没有看操作文档就照抄网上的例子。
报错截图:

网上关于EPplus的资料很少,所有半天没找到问题在哪,后来重新下载EPplus后了名为readme.txt自述文档,从中可得知使用EPplus必须设置LicenseContext参数;
文档中的解决办法:
### 1. Via code
```csharp
// If you are a commercial business and have
// purchased commercial licenses use the static property
// LicenseContext of the ExcelPackage class :
ExcelPackage.LicenseContext = LicenseContext.Commercial;
// If you use EPPlus in a noncommercial context
// according to the Polyform Noncommercial license:
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
using(var package = new ExcelPackage(new FileInfo("MyWorkbook.xlsx")))
{
}
```
### 2. Via appSetti

在使用EPplus库创建Excel文档时遇到`OfficeOpenXml.LicenseException`错误。解决方法是在代码中设置`ExcelPackage.LicenseContext`属性,或者通过appSettings.json或app/web.config配置文件,以及设置环境变量'EPPlusLicenseContext'来指定商业或非商业使用情境。
最低0.47元/天 解锁文章
4543

被折叠的 条评论
为什么被折叠?



