|
Report Application Server .NET SDK Developer Guide
|
|
To export a report to XML
|
|
- Create a new XMLExportFormatOptions object.
|
Visual Basic
|
|
|
Dim xmlExpFormatOpts As XMLExportFormatOptions = New XMLExportFormatOptionsClass() xmlExpFormatOpts.ExportSelection = xmlExportFormats.DefaultExportSelection
|
|
C#
|
|
|
XMLExportFormatOptions xmlExpFormatOpts = new XMLExportFormatOptionsClass(); xmlExpFormatOpts.ExportSelection = xmlExportFormats.DefaultExportSelection;
|
- Set the export type toCrReportExportFormatEnum.crReportExportFormatXML in order to export the report as an XML file.
|
Visual Basic
|
|
|
Dim expOpts As ExportOptions = New ExportOptionsClass() expOpts.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatXML expOpts.FormatOptions = xmlExpFormatOpts
|
|
C#
|
|
|
ExportOptions expOpts = new ExportOptionsClass(); expOpts.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatXML; expOpts.FormatOptions = xmlExpFormatOpts;
|
- Use the ExportEx method of the PrintOutputController class to export the report to a ByteArray object with the determined export options.
|
Visual Basic
|
|
|
Dim tempByteArray As ByteArray = rcd.PrintOutputController.ExportEx(expOpts) Dim byteStreamOutput As Byte() = tempByteArray.ByteArray
|
|
C#
|
|
|
ByteArray tempByteArray = rcd.PrintOutputController.ExportEx(expOpts); Byte[] byteStreamOutput = tempByteArray.ByteArray;
|
- Create a new FileStream object, stream the file using the Write method, and close the stream.
|
Visual Basic
|
|
|
Dim xmlPath As String = (("C:\" & rcd.DisplayName & "_") + xmlExportFormat.Name & ".") + xmlExportFormat.FileExtension Dim fs As New FileStream(xmlPath, FileMode.Create, FileAccess.ReadWrite) Dim maxSize As Integer = byteStreamOutput.Length fs.Write(byteStreamOutput, 0, maxSize) fs.Close()
|
|
C#
|
|
|
string xmlPath = "C:\\" + rcd.DisplayName + "_" + xmlExportFormat.Name + "." + xmlExportFormat.FileExtension; FileStream fs = new FileStream(xmlPath, FileMode.Create, FileAccess.ReadWrite); int maxSize = byteStreamOutput.Length; fs.Write(byteStreamOutput, 0, maxSize); fs.Close();
|
|
Visual Basic
|
|
|
Private Sub ExportReportToXML(ByVal rcd As ISCDReportClientDocument, ByVal xmlExportFormats As XMLExportFormats, ByVal xmlExportFormat As XMLExportFormat) Dim xmlExpFormatOpts As XMLExportFormatOptions = New XMLExportFormatOptionsClass() xmlExpFormatOpts.ExportSelection = xmlExportFormats.DefaultExportSelection Dim expOpts As ExportOptions = New ExportOptionsClass() expOpts.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatXML expOpts.FormatOptions = xmlExpFormatOpts Dim tempByteArray As ByteArray = rcd.PrintOutputController.ExportEx(expOpts) Dim byteStreamOutput As Byte() = tempByteArray.ByteArray Dim xmlPath As String = (("C:\" & rcd.DisplayName & "_") + xmlExportFormat.Name & ".") + xmlExportFormat.FileExtension Dim fs As New FileStream(xmlPath, FileMode.Create, FileAccess.ReadWrite) Dim maxSize As Integer = byteStreamOutput.Length fs.Write(byteStreamOutput, 0, maxSize) fs.Close() End Sub
|
|
C#
|
|
|
private void ExportReportToXML(ISCDReportClientDocument rcd, XMLExportFormats xmlExportFormats, XMLExportFormat xmlExportFormat) { XMLExportFormatOptions xmlExpFormatOpts = new XMLExportFormatOptionsClass(); xmlExpFormatOpts.ExportSelection = xmlExportFormats.DefaultExportSelection; ExportOptions expOpts = new ExportOptionsClass(); expOpts.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatXML; expOpts.FormatOptions = xmlExpFormatOpts; ByteArray tempByteArray = rcd.PrintOutputController.ExportEx(expOpts); Byte[] byteStreamOutput = tempByteArray.ByteArray; string xmlPath = "C:\\" + rcd.DisplayName + "_" + xmlExportFormat.Name + "." + xmlExportFormat.FileExtension; FileStream fs = new FileStream(xmlPath, FileMode.Create, FileAccess.ReadWrite); int maxSize = byteStreamOutput.Length; fs.Write(byteStreamOutput, 0, maxSize); fs.Close(); }
|
This list includes the namespaces used by the sample code:
- CrystalDecisions.Enterprise
- CrystalDecisions.ReportAppServer.ClientDoc
- CrystalDecisions.ReportAppServer.Controllers
- CrystalDecisions.ReportAppServer.ReportDefModel
- CrystalDecisions.ReportAppServer.DataDefModel
- CrystalDecisions.ReportAppServer.CommonObjectModel
- System.IO
© 2021 SAP AG. All rights reserved.
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Created with the Personal Edition of HelpNDoc: Full-featured Help generator