将多个XtraGrid控件导出到单个Excel文件 [英] Exporting Several XtraGrid Controls to a Single Excel File

查看:331
本文介绍了将多个XtraGrid控件导出到单个Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个XtraGrid控件,每个包含不同的信息,我得到一些信息,可以将XtraGrid导出到Excel文件,方向如下: http://www.devexpress.com/Support/Center/p/Q362120.aspx



现在有任何方法可以将每个XtraGrid控件导出到单个Excel文件,以便将每个XtraGrid信息导出到其他excel表。



我尝试将导出路径方向设置为相同的Excel文件,但是当第一个导出过程完成时,第二个导出过程只是覆盖了excel文件等等。



我尝试使用这个方向描述的方法 XtraGrid - 导出到Excel ,但我想知道如果有另一种方式whithout使用interop excel库,因为我有使用这个库时会遇到一些问题(我的意思是使用这个库时你创建一个Excel进程,但创建它之后,你不能杀死它,即使你已经使用了这个方法)。



任何帮助都将受到欢迎。

解决方案

要做到这一点,您需要添加一个printableComponentLink到每个gridControl,然后创建一个可以添加每个printableComponent链接的复合链接。



此链接可能会证明DevExpress 知识库文章可能证明是有用的,因为它有一个例子。



然后,您将使用 compositeLink.ExportToXlsx 方法。如果您使用 XlsxExportOptions.ExportMode 属性等于 SingleFilePageByPage XlsxExportOptions c>并将其传递给 CompositeLink.ExportToXlsx 方法,每个页面都将导出到单独的工作表。


I've got several XtraGrid Controls each one containing different information, I get some information about the way in which you can export a XtraGrid to an Excel file in the following direction http://www.devexpress.com/Support/Center/p/Q362120.aspx

Now Is there any way to export the each XtraGrid Control to a single Excel file so that every XtraGrid information is exported to a different excel sheet.

I tried setting the exporting path direction to the same Excel file, but when the first exporting process is done, the second exporting process just overrides the excel file and so on.

I tried using the method described in this direction XtraGrid - Export To Excel , but I wanted to know if there is another way whithout using the interop excel libraries because I have experience some problems when using this library (I mean when using this library you create an Excel process but after you created it you cannot kill it, even though you have used the method that is supposed to do that).

Any help would be welcomed.

解决方案

To do that you will want to add a printableComponentLink to each gridControl, and then Create a compositeLink that you can add each of the printableComponent links to.

This link may prove DevExpress KB Article may prove useful as it has an example of that.

Then you will use the compositeLink.ExportToXlsx method. If you create XlsxExportOptions with the XlsxExportOptions.ExportMode property equal to SingleFilePageByPage and pass it to the CompositeLink.ExportToXlsx method, every page will be exported to a separate sheet.

这篇关于将多个XtraGrid控件导出到单个Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆