Skip to Content
0
Former Member
Sep 10, 2009 at 12:51 PM

XML Export - Cannot select format CR2008 SP2

161 Views

I have a report that contains data and 2 XML formats; the standard Crystal format and our XML format.

I use the following function to export to and XML disk file;

public String exportToXml(String sDestinationFile, int iXmlFormat) {
            String sError = null;

            mobjLogger.Debug("Exporting to XML file " + sDestinationFile);
            try {
                // Check the report is OK

                Z_CheckReportIsValid();

                // Setup the exporting

                mobjLogger.Debug("Setting XML options Format=" + iXmlFormat);
                DiskFileDestinationOptions objDestinationOptions = new DiskFileDestinationOptions();
                objDestinationOptions.DiskFileName = sDestinationFile;

                XmlExportFormatOptions objExportOptions = new XmlExportFormatOptions();
                objExportOptions.ExportSelection = iXmlFormat;

                ExportOptions objOptions = new ExportOptions();
                objOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                objOptions.DestinationOptions = objDestinationOptions;
                objOptions.ExportFormatType = ExportFormatType.Xml;
                objOptions.ExportFormatOptions = objExportOptions;

                // Run the export

                mobjLogger.Debug("Running XML export");
                mobjReport.Export(objOptions);
            }
            catch (Exception e) {
                mobjLogger.Error("Error exporting XML to " + sDestinationFile + " - " + Z_GetErrorMessage(e));
                sError = Z_GetErrorMessage(e);
            }
            return sError;
        }

However, it doesn't matter what I select as the XML format to use, it always uses the default Crystal format.

In the designer, it all works fine - I get offered both formats and it exports correctly.

If I change the default in the report to be my customised format (index 1), then when I run the report from .Net I always get "Invalid Export Options", irrespective of what I have actual format I am trying to use i.e. both the Crystal and my customised format fail with the "Invalid Export Options" error.

Has anyone got any ideas because this is a show stopper for us?

Many thanks,

Steve