To export a report to XML

Parent Previous Next

 

Report Application Server .NET SDK Developer Guide

To export a report to XML


 







  1. 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;

  1. 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;

  1. 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;

  1. 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:

© 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