如何在 ASP.NET Core 1.0 中创建报告(例如 PDF,Excel,Word)?

How to create report(e.g. PDF,Excel,Word) in ASP.NET Core 1.0?

我想在 ASP.NET Core 1.0 中创建报告(例如 PDF、Excel、Word), 但 NPOI 和 OpenXML 不支持 ASP.NET Core.

如果您的应用程序仅在 windows 上 运行 没问题,那么将 ASP.NET 核心与完整的 .net 框架结合使用可以让您使用 NPOI 和 OpenXML。通过这种方法,您现在可以开始使用新的 Microsoft Web 框架,希望 NPOI 或 OpenXML 在不久的将来支持 .NET Core。

.NET Core 对 OpenXML 的支持存在问题 (https://github.com/OfficeDev/Open-XML-SDK/issues/65). Some work has to be done before it is ready. Someone who had your demand as well ported it to .NET Core and published his project on GitHub (https://github.com/xrkolovos/Open-XML-SDK-for-NET-Platform-Standard)。我自己没有尝试过,但可能值得一试。

更新:

当前版本的 OpenXML 支持 .NET Core。因此,第二个 GitHub 项目现已过时。

有一个 CI 版本适用于 .Net Core 1.1

https://github.com/OfficeDev/Open-XML-SDK

特定的 nuget 包位于此供稿中:

https://dotnet.myget.org/F/open-xml-sdk/api/v3/index.json

对于 PDF PdfReport.Core 可能是一个解决方案。我可以确认它在 netcoreapp1.1 下工作。它还应该能够导出为 Excel、XML 和 CSV(未经我测试)。

请在这里查看我的回答: