com.crystaldecisions.sdk.occa.report.exportoptions
Interface IXMLExportFormatOptions

All Superinterfaces:
IClone, IExportFormatOptions
All Known Implementing Classes:
XMLExportFormatOptions

public interface IXMLExportFormatOptions
extends IExportFormatOptions

Defines the format of a document that is exported to XML.

You can programmatically export a report to all XML formats defined and saved with the report file. A generic Crystal Reports XML format that exports report details is saved by default in every report. In addition, report designers can add custom XML export formats by applying XSLT templates to the generic format saving these as unique formats in the report. A report designer can also set one of the formats saved with the report as the default format to use for certain exporting scenarios. You can use the PrintOutputControllerClass.getSavedXMLExportFormats method to allow the user to select a format.

After defining the XML formatting options, set your XMLExportFormatOptions object to an ExportOptions instance using the setFormatOptions property. This should be done in conjunction with specifying the general export format as XML (CrReportExportFormatEnum.crReportExportFormatXML), by setting the ExportOptions.setExportFormatType property. The report can then be exported to the desired XML format with the PrintOutputControllerClass.export method.

Example:

This sample shows how to export the default XML format saved in the report. This sample assumes you have opened a report represented by a ReportClientDocument object, an XMLExportFormats collection of all the export formats saved in the report to obtain the default from, and an XMLExportFormat object to obtain the export format file extension and other descriptive details.

 IXMLExportFormat xmlExportFormat = new XMLExportFormat();
 XMLExportFormats xmlExportFormats = new XMLExportFormats(); 
 IXMLExportFormatOptions xmlExpFormatOpts = new XMLExportFormatOptions();
 xmlExportFormats = clientDoc.getPrintOutputController().getSavedXMLExportFormats();
 int index = xmlExportFormats.getDefaultExportSelection();
 xmlExpFormatOpts.setXMLExportSelection(index); 
 xmlExportFormat = xmlExportFormats.getXMLExportFormat(index);
 IExportOptions expOpts = new ExportOptions();
 expOpts.setExportFormatType(ReportExportFormat.XML);
 expOpts.setFormatOptions(xmlExpFormatOpts);
 ByteArrayInputStream byteIS = (ByteArrayInputStream) clientDoc.getPrintOutputController().export(expOpts);
 byte[] buf = new byte[2000 * 1024];
 int nRead = 0;
 String xmlPath = "C:\\" + clientDoc.displayName() + "_" + xmlExportFormat.getName() + "." + xmlExportFormat.getFileExtension();
 FileOutputStream fs = new FileOutputStream(xmlPath);
 int maxSize = buf.length;
 while ((nRead = byteIS.read(buf)) != -1) {
     fs.write(buf, 0, maxSize);
 }
 fs.close();
 


Method Summary
 int getXMLExportSelection()
           Gets the zero-based index in the XMLExportFormats collection of the XML format to export the report to.
 void setXMLExportSelection(int xmlSelectedIndex)
           Sets the zero-based index in the XMLExportFormats collection of the XML format to export the report to.
 
Methods inherited from interface com.crystaldecisions.sdk.occa.report.exportoptions.IExportFormatOptions
checkValidity
 

Method Detail

getXMLExportSelection

int getXMLExportSelection()

Gets the zero-based index in the XMLExportFormats collection of the XML format to export the report to.

Returns:
An int that specifies index of the selected the XML export format.

setXMLExportSelection

void setXMLExportSelection(int xmlSelectedIndex)

Sets the zero-based index in the XMLExportFormats collection of the XML format to export the report to.

Parameters:
xmlSelectedIndex - An int that specifies index of the selected the XML export format.