Page tree
Skip to end of metadata
Go to start of metadata

ActiveReports提供了用于将报告导出为六种格式的自定义组件。每种导出格式都具有特殊功能,但是,并非所有格式都支持您可以在报告中使用的所有功能。这是每种格式的独特使用可能性,以及每种格式固有的限制。

HTML导出:用于在Web浏览器或电子邮件上显示。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Html.dll的引用来访问HTML导出过滤器。
PDF导出:用于在其他计算机上保留格式。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Pdf.dll的引用来访问PDF导出过滤器。
文本导出:用于传输原始数据,几乎不需要格式化。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Xml.dll的引用来访问“文本导出”过滤器。
RTF导出:用于保留某些格式,但允许使用Word或写字板打开报告。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Word.dll的引用来访问RTF导出过滤器。
Excel导出:用于显示为电子表格。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Excel.dll的引用来访问Excel导出筛选器。
TIFF导出:用于传输传真。您可以通过在项目中添加对GrapeCity.ActiveReports.Export.Image.dll的引用来访问“图像导出”过滤器。
请参阅使用导出过滤器导出报告以使用导出过滤器导出页面报告,RDL报告或部门报告。

请参见使用SpreadBuilder的基本电子表格,以便逐个单元地创建Excel电子表格,以实现最大程度的控制。

使用导出过滤器导出报告

ActiveReports提供了各种导出筛选器,可用于将Page,Section和Rdl Reports导出为支持的文件格式。

注意:默认情况下,在ActiveReports中,NuGet程序包位于... \ GrapeCity \ ActiveReports 14 \ NuGet文件夹中。

使用以下步骤通过导出过滤器导出报告。这些步骤假定您已经创建了Windows应用程序,并将导出控件添加到了Visual Studio工具箱中。有关更多信息,请参见添加ActiveReports控件。

导出报告

1、在项目的Bin> Debug文件夹中,放置report.rpx(部分报告)或report.rdlx(页面/ Rdl报告)。

2、在解决方案资源管理器中,右键单击“引用”节点,然后选择“添加引用”。

3、在出现的“引用管理器”对话框中,选择以下引用,然后单击“确定”将其添加到您的项目中。

      GrapeCity.ActiveReports.Export.Excel
      GrapeCity.ActiveReports.Export.Html
      GrapeCity.ActiveReports.Export.Image
      GrapeCity.ActiveReports.Export.Pdf
      GrapeCity.ActiveReports.Export.Word
      GrapeCity.ActiveReports.Export.Xml

4、在Form.cs或Form.vb上,双击标题栏以创建Form_Load事件。

5、在Form_Load事件中,添加以下代码以将报告添加到您的项目中。


要将Page / Rdl报告添加到项目中

Visual Basic.NET代码。 粘贴到Form_Load事件中。


' Create a page/Rdl report.
Dim rpt As New GrapeCity.ActiveReports.PageReport()
' Load the report you want to export. 
' For the code to work, this report must be stored in the bin\debug folder of your project.
rpt.Load(New System.IO.FileInfo ("report.rdlx"))
Dim MyDocument As New GrapeCity.ActiveReports.Document.PageDocument (rpt)

C#代码。 粘贴到Form_Load事件中。


// Create a page/Rdl report.
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
// Load the report you want to export. 
// For the code to work, this report must be stored in the bin\debug folder of your project.
rpt.Load(new System.IO.FileInfo ("report.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument MyDocument = new GrapeCity.ActiveReports.Document.PageDocument (rpt);

将“区域”报告添加到您的项目中

Visual Basic.NETcode。 粘贴到Form_Load事件中。

' Create a Section report.Dim rpt As New GrapeCity.ActiveReports.SectionReport()' For the code to work, report.rpx must be placed in the bin\debug folder of your project.Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\report.rpx")rpt.LoadLayout(xtr)rpt.Run()

C#代码。 粘贴到Form_Load事件中。

// Create a Section report.GrapeCity.ActiveReports.SectionReport rpt = new GrapeCity.ActiveReports.SectionReport();
// For the code to work, report.rpx must be placed in the bin\debug folder of your project.
System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + "\\report.rpx");
rpt.LoadLayout(xtr);
rpt.Run();

6、添加以下代码以将Page,Rdl和Section报告导出为多种格式。
(此代码对于所有报告类型(.rpx和.rdlx)都是通用的。)

在Visual Basic.NET中编写代码

Visual Basic.NET代码。 粘贴到Form_Load事件中。

' Export the report in HTML format.
Dim HtmlExport1 As New GrapeCity.ActiveReports.Export.Html.Section.HtmlExport()
HtmlExport1.Export(MyDocument, Application.StartupPath + "\HTMLExpt.html")

' Export the report in PDF format.
Dim PdfExport1 As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport()
PdfExport1.Export(MyDocument, Application.StartupPath + "\PDFExpt.pdf")

' Export the report in RTF format.
Dim RtfExport1 As New GrapeCity.ActiveReports.Export.Word.Section.RtfExport()
RtfExport1.Export(MyDocument, Application.StartupPath + "\RTFExpt.rtf")

' Export the report in text format.
Dim TextExport1 As New GrapeCity.ActiveReports.Export.Xml.Section.TextExport()
TextExport1.Export(MyDocument, Application.StartupPath + "\TextExpt.txt")

' Export the report in TIFF format.
Dim TiffExport1 As New GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport()
TiffExport1.Export(MyDocument, Application.StartupPath + "\TIFFExpt.tiff")

' Export the report in Excel format.
Dim XlsExport1 As New GrapeCity.ActiveReports.Export.Excel.Section.XlsExport()
' Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx
XlsExport1.Export(MyDocument, Application.StartupPath + "\XLSExpt.xlsx")

用C#编写代码

C#代码。 粘贴到Form_Load事件中。

// Export the report in HTML format.
GrapeCity.ActiveReports.Export.Html.Section.HtmlExport HtmlExport1 = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
HtmlExport1.Export(MyDocument, Application.StartupPath + "\\HTMLExpt.html");

// Export the report in PDF format.
GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport PdfExport1 = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
PdfExport1.Export(MyDocument, Application.StartupPath + "\\PDFExpt.pdf");

// Export the report in RTF format.
GrapeCity.ActiveReports.Export.Word.Section.RtfExport RtfExport1 = new GrapeCity.ActiveReports.Export.Word.Section.RtfExport();
RtfExport1.Export(MyDocument, Application.StartupPath + "\\RTFExpt.rtf");

// Export the report in text format.
GrapeCity.ActiveReports.Export.Xml.Section.TextExport TextExport1 = new GrapeCity.ActiveReports.Export.Xml.Section.TextExport();
TextExport1.Export(MyDocument, Application.StartupPath + "\\TextExpt.txt");

// Export the report in TIFF format.
GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport TiffExport1 = new GrapeCity.ActiveReports.Export.Image.Tiff.Section.TiffExport();
TiffExport1.Export(MyDocument, Application.StartupPath + "\\TIFFExpt.tiff");

// Export the report in XLSX format.
GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
// Set a file format of the exported excel file to Xlsx to support Microsoft Excel 2007 and newer versions.
XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
XlsExport1.Export(MyDocument, Application.StartupPath + "\\XLSExpt.xlsx");

注意:通过“导出”过滤器将报告导出到.MHT文件时,请使用htmlExport.Export(Document doc,Stream outputStream);
有关更多信息,请参见HTML导出方法。

7、按F5运行该应用程序。 导出的文件保存在bin \ debug文件夹中。








相关资源:


注意

如需寻求在线帮助,请访问 ActiveReports 求助中心

如需了解更多ActiveReports产品特性,请访问 ActiveReports 官方网站

ActiveReports 官方技术交流群:109783140

下载产品体验产品功能:http://www.gcpowertools.com.cn/products/download.aspx?pid=16

  • No labels