EPPlus : Please set the ExcelPackage.LicenseContext property 대처방안
오류 로그
2021-03-31 20:51:27,481 [5] ERRORStaffController - OfficeOpenXml.LicenseException: Please set the ExcelPackage.LicenseContext property. See https://epplussoftware.com/developers/licenseexception at OfficeOpenXml.ExcelPackage.get_Workbook() at OfficeOpenXml.ExcelPackage.CreateBlankWb() at OfficeOpenXml.ExcelPackage.ConstructNewFile(String password) at OfficeOpenXml.ExcelPackage..ctor(FileInfo newFile) at PartnerPlatform.Service.StaffExport.ExportExcelSingleWorksheets(IDbConnection dbConnection, String sWebRootFolder, String fileName, List`1 staff) in /Users/jinyazhou/Test/PartnerPlatform/Service/ExcelExport.cs:line 43 at PartnerPlatform.Controllers.StaffController.Export() in /Users/jinyazhou/Test/Controllers/ExcelController.cs:line 19 Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.1.13/System.Runtime.Serialization.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
이유
EPPlus는 LGPL 오픈 소스 라이선스에 따라 버전 4.5.3.3 까지 라이선스가 부여되었지만, 버전 5부터는 Polyform Noncommercial 1.0.0 즉, 상용화가 되었습니다.
5.0 이상의 버전을 사용하면서, 상용버전이 아닌 개인적인 사용이라면 아래과 같이
"ExcelPackage.LicenseContext = LicenseContext.NonCommercial;" 을 추가해 주셔야 사용이 가능합니다.
// 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")))
{
}
New features in version 4.5: * .NET Core support * Sparklines * Sort method added to ExcelRange * Bug fixes and minor changes, see below and visit https://github.com/JanKallman/EPPlus for tutorials, samples and the latest information
Changes 4.5.3.3 * Support for .NET Standard 2.1.
4.5.3.2 * Added a target build for .NET Core 2.1 (netcoreapp2.1) with System.Drawing.Common 4.6.0-preview6.19303.8 * Fixed Text property with short date format * Fixed problem with defined names containing backslash * More bugfixes, see https://github.com/JanKallman/EPPlus/commits/master