Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
UltraGridDocumentExport throwing strange error
posted
Hi, I am trying to use the UltraGridDocumentExporter to export the contents of an ultragrid to PDF. The code that I have written mirrors (almost exactly) some code from an IF employee's blog post. The method that I wrote was working fine, but is now throwing the dreaded "Object Reference not set to an instance of an object" whenever I try to export the grid. I tried using the method on another grid and it works perfectly fine. Both grids are in OutlookGroupByMode so I don't think that is the issue. Here is the exception/stack trace: ExceptionMessage: Object reference not set to an instance of an object. StackTrace: at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.ProcessGridRowInternal(UltraGridExporterHelper ultraGridExporterHelper, UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridExporterHelper.Infragistics.Win.UltraWinGrid.IUltraGridExporter.ProcessRow(UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, ISection section) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, Report report) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, String fileName, GridExportFileFormat fileFormat) at PMS.MainUI.printToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Development\Core\PMS\MainUI.cs:line 591 Here's the code, as I said before, the code works. There seems to be something about the layout of the grid that the exporter doesn't like.... using System; using System.Collections.Generic; using System.Linq; using System.Text; using Infragistics.Documents.Report; using Infragistics.Documents.Report.Section; using Infragistics.Documents.Report.Text; using Infragistics.Documents.Graphics; using Infragistics.Documents.Report.Table; using Infragistics.Documents.Report.Grid; using Infragistics.Documents.Report.Band; using Infragistics.Documents.Report.Flow; using Infragistics.Win.UltraWinGrid; using Infragistics.Win.UltraWinGrid.DocumentExport; using System.Xml; namespace PMS.Reporting { public class PDFExporter { private static UltraGridDocumentExporter myExporter = new UltraGridDocumentExporter(); public static void ExportOMSGrid(UltraGrid pUltraGrid) { Report r = new Report(); ISection s1 = r.AddSection(); s1.PageNumbering.SkipFirst = true; s1.PageNumbering.OffsetY = -18; s1.PageNumbering.Template = "Page [Page #] of [TotalPages]"; ISectionHeader s1Header = s1.AddHeader(); s1Header.Height = 20; IText s1headertitle = s1Header.AddText(0, 0); s1headertitle.AddContent(string.Format("Trade Blotter\n As Of {0}", DateTime.Now.ToString("MM/dd/yy hh:mm"))); s1headertitle.Alignment = TextAlignment.Center; myExporter.Export(pUltraGrid, s1); } } } Any help would be appreciated Thanks, Sean