ASP.NET - 能够将 CSV/excel 导出到多个工作表吗?
我想知道是否有人有一个解决方案能够将数据导出到多个工作表中的excel中...到目前为止我只知道如何将多个对象导出到一个工作表中!
我正在使用 Devexpress 导出器?似乎他们不支持这一点,我也可以采用通用解决方案吗?
任何指导将不胜感激!
I was wondering if anyone has a solution to be able to export data into excel in multiple sheets... As of now I only know how to export multiple objects into a single sheet!
I am using Devexpress exporter?? Seems like they don't support this, I can go with a generic solution as well?
Any guidance will be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
埃普拉斯?
http://epplus.codeplex.com/releases/view/42439
我在winforms 应用程序,它很棒。但它只处理 xlsx 文件 - 即 Excel 2007 及以上版本。
安德鲁
Epplus ?
http://epplus.codeplex.com/releases/view/42439
I used this in winforms application and it's great. It only does xlsx files though - ie Excel 2007 onwards.
andrew
文件路径可能应该是 server.mappath(),因为生成的 excel 应首先保存在服务器路径中并且可以允许下载。
添加引用 Excel 并添加命名空间“Using Excel”。
filepath should probably be server.mappath() as generated excel shoul first be saved in server path and can be allowed to download.
Add reference Excel and add namespace "Using Excel".
去年年初我遇到了完全相同的问题。最终,我能够自动生成一个 .xlt Excel 文件,其中包含多个 Excel 可以接受的电子表格(实际上是网页)。
我知道这不漂亮,但它对我有用。如果您决定尝试一下,请告诉我它是否也适合您。
输出以下内容(您可以调整为具有所需的任意数量的工作表):
对于每个页面,输出:
End for循环
在代码中,将响应缓冲区设置为 false,内容类型设置为“application/vnd.ms-excel”并添加标题“Content-Disposition”,“inline; filename={ 您的文件名}”。请注意,输出文件的第一行之前不得有换行符。
I faced the exact same problem early last year. Eventually I was able to hack my way into automate generation of a .xlt Excel file with multiple spreadsheets (which are actually webpages) that can be accepted by Excel.
I know it's not pretty, but it worked for me. If you decide to try it, let me know if it works for you too.
Output the followings (you can adjust to have any number of sheets you want):
For each page, output:
End for loop
In your code, set response buffer to false, content type to "application/vnd.ms-excel" and add the header "Content-Disposition", "inline; filename={ your file name }". Note there must be no line breaks before the first line of your output file.
您是否正在尝试 XlsxExportOptions.ExportMode 属性? SingleFilePageByPage 导出模式允许您将文档逐页导出到多个工作表中相同的 XLSX 文件。另请参阅以下文章:如何将报告导出到不同的工作表XLS 文件。
Are you trying the XlsxExportOptions.ExportMode property? The SingleFilePageByPage export mode allows you to export a document page-by-page to multiple sheets within the same XLSX file. Please also look at the the following article:How to export a report to the different sheets in the XLS file.
查看 http://www.devexpress.com/example=E2440 关于您的请求。
看来这正是您正在寻找的。
Take a look at the http://www.devexpress.com/example=E2440 regarding your request.
It seems that it is exactly you are looking for.