C# 导出到 .xlsx

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/725190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 22:37:44  来源:igfitidea点击:

Export to .xlsx

c#asp.netexcel

提问by

Could anyone suggest best way to export data to .xlsx format. 1.Dynamically creating sheets. 2.customizing the data in each sheet. We can't use office web components.

任何人都可以建议将数据导出为 .xlsx 格式的最佳方法。1.动态创建工作表。2.自定义每张表中的数据。我们不能使用办公网络组件。

Thanks

谢谢

回答by splattne

You could use a third-party component like Aspose Cellsor XLSIO(Syncfusion):

您可以使用第三方组件,如Aspose CellsXLSIO(Syncfusion):

Using Aspose.Cells, developers can easily open and save a multitude of file formats. These include Excel 97 / 2000 / XP / 2007 (XLSX), SpreadSheetML, Tab Delimited and CSV documents. Using Aspose.Cells you can also open encrypted Excel files. It is even possible to convert Excel documents into PDF format by using another Aspose product (that is Aspose.Pdf) alongwith Aspose.Cells.

使用 Aspose.Cells,开发人员可以轻松打开和保存多种文件格式。其中包括 Excel 97 / 2000 / XP / 2007 (XLSX)、SpreadSheetML、制表符分隔和 CSV 文档。使用 Aspose.Cells 您还可以打开加密的 Excel 文件。甚至可以使用另一个 Aspose 产品(即 Aspose.Pdf)和 Aspose.Cells 将 Excel 文档转换为 PDF 格式。

回答by Dirk Vollmar

You should have a look at the OpenXML SDK 2.0.

您应该看看OpenXML SDK 2.0

Related blog articles:

相关博客文章:

回答by ceejayoz

Remember also that in many cases a .CSV will do. Excel reads those fine.

还要记住,在许多情况下,.CSV 文件就可以。Excel 读取这些很好。

You'll only need an XLSX file for Excel-only features like the formatting, multiple worksheets, etc. - and for those, there are a number of existing Excel 1997-2003 generator libraries that make files that'll work with Excel 2007.

您只需要一个 XLSX 文件来实现格式、多个工作表等仅限 Excel 的功能。对于这些功能,有许多现有的 Excel 1997-2003 生成器库可以生成可与 Excel 2007 一起使用的文件。

回答by Joe Erickson

SpreadsheetGear for .NETcan generate XLS and XLSX workbooks and includes a comprehensive API for customizing / formatting the data.

SpreadsheetGear for .NET可以生成 XLS 和 XLSX 工作簿,并包含一个用于自定义/格式化数据的综合 API。

You can see the live ASP.NET Excel Reporting samples here.

您可以在此处查看实时 ASP.NET Excel 报告示例。

Disclaimer: I own SpreadsheetGear LLC.

免责声明:我拥有 SpreadsheetGear LLC。

回答by dbkk

Excel Packageis an open-source (GPL) component for reading/writing Excel 2007 files. I used it on a small project, and the API is straightforward.

Excel 包是一个开源 (GPL) 组件,用于读取/写入 Excel 2007 文件。我在一个小项目中使用了它,API 很简单。

The source code also seems well-organized and easy to get around (if you need to expand functionality or fix minor issues as I did).

源代码似乎也井井有条且易于使用(如果您需要像我一样扩展功能或修复小问题)。

You can use either approach (customizing a template or creating everything from scratch). Customizing is much easier if you want the result to look nice.

您可以使用任何一种方法(自定义模板或从头开始创建所有内容)。如果您希望结果看起来不错,则自定义要容易得多。

回答by dan

EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).

EPPlus 是一个 .net 库,它使用 Open Office Xml 格式 (xlsx) 读取和写入 Excel 2007/2010 文件。

http://epplus.codeplex.com/

http://epplus.codeplex.com/

回答by gbucsariu

You can use EasyXLSto export your data as xlsx file. A nice formatting can be set to your report using this library.

您可以使用EasyXLS将数据导出为 xlsx 文件。使用这个库可以为您的报告设置一个很好的格式。