ReportDocument rptDoc = new ReportDocument(); // Load report rptDoc.Load("myReport.rpt"); // Export to XPS rptDoc.CreateXpsDocument("C:\\reports\\myReport.xps", true);
using CrystalDecisions.CrystalReports.Engine; using System.IO.Packaging; ReportDocument rptDoc = new ReportDocument(); // Load report rptDoc.Load("myReport.rpt"); // Create XPS document using (Package package = Package.Open("C:\\reports\\myReport.xps", FileMode.Create)) { // Export to XPS rptDoc.ExportToXps(new XpsExportOptions(), package); }This example loads a report file named "myReport.rpt" and creates an XPS package. The XPS package is saved in the "C:\reports\" folder with the file name "myReport.xps". The XPS document is then exported to the package using ExportToXps method. The XpsExportOptions helps to customize some aspects of the XPS document. In both examples, the package library used is System.IO.Packaging. This library enables developers to create, manipulate and read XPS documents.