I have successfully exported multiple grids to Excel but now I am trying to figure out how to export them to a PDF or XPS. Is it possible?
Yes, you can, but each grid must be in it's own section. This means that you cannot export more than one grid to the same section, and by extension, you cannot export more than one grid to the same page (since the section contains the pages).
Basically, what you do is create a Report object and export the grid to it. Then export another grid to the same report. Each export operation will create a new section in the report.
I attempted to do it this way but I must be missing something. Because it will not load as a PDF.
Infragistics.Documents.Report.Report pdfReport = new Infragistics.Documents.Report.Report();
this.ultraGridDocumentPDFExporter.Export(this.ultraGrid1, pdfReport);
this.ultraGridDocumentPDFExporter.Export(this.ultraGrid2, pdfReport);
SaveFileDialog saveFileDialogPDF = new System.Windows.Forms.SaveFileDialog();
saveFileDialogPDF.DefaultExt = "pdf";
saveFileDialogPDF.FileName = "Order Inquire Export on " + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year;
saveFileDialogPDF.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
saveFileDialogPDF.RestoreDirectory = true;
if (saveFileDialogPDF.ShowDialog() == DialogResult.OK)
{
pdfReport.Save(saveFileDialogPDF.FileName);
}
saveFileDialogPDF.Dispose();
saveFileDialogPDF = null;
That worked. Thanks.
I think you will find that you get the same result if you only export one grid.
This has nothing to do with what you are exporting, it's because you are using the Save method instead of Publish. Save just saves the report to XML, it's not a PDF document. You have to use Publish to create a PDF or XPS document.