I have various WinGrids throughout my program which I allow for export to PDF, Word, and Excel. Everything works great for the Excel and Word exports.
The first PDF export in each session in the program works great, but after that one, any other PDF exports will output the same grid as the first one exported in that session. I assume that somehow this is stuck in memory somewhere, but I cannot seem to find where, or how to clear it out. My Export Code is below:
Public Function ExportGridToPDF(ByVal grd As Infragistics.Win.UltraWinGrid.UltraGrid, ByVal strFileName As String, Optional blnRun As Boolean = True, Optional rptStruct As cPDRptStructure = Nothing, Optional blnPrint As Boolean = False, Optional PrinterName As String = "", Optional ExportAsync As Boolean = False) As String
Try If GetGridColCt(grd) > 50 Then MessageBox.Show("A grid with more than 50 columns can not be exported to PDF.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error) Return "" Else
If strFileName.Contains(":") = False Then strFileName = String.Concat(PDGen.GetTempDir, strFileName)
' Create a report
Dim MyRptSection As ISection MyRptSection = mReport.AddSection
If rptStruct IsNot Nothing Then Call AddHeader(MyRptSection, rptStruct)
Call AddFooter(MyRptSection, rptStruct)
If rptStruct.IncludePageNumbers Then Call AddPageNumbers(MyRptSection) End If
'StatusMsg("Grid sent to PDF") mstrFileName = strFileName mblnRun = blnRun mblnPrint = blnPrint mPrinterName = PrinterName If ExportAsync Then ' Export WinGrid to the section mDoc.ExportAsync(grd, MyRptSection) Else mDoc.Export(grd, MyRptSection) End If
Return mstrFileName End If Catch ex As System.IO.IOException MessageBox.Show("The file [" & strFileName & "] is currently open please close the file and try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning) Return "" Catch ex As Exception PDGen.VBErr(ex, "ExportGridToExcel") Return "" End Try
End Function
mDoc is declared as the following:
Dim WithEvents mDoc As New UltraWinGrid.DocumentExport.UltraGridDocumentExporter
I have tried adding mDoc = New UltraWinGrid.DocumentExport.UltraGridDocumentExporter to the top of the ExportGridToPDF function, but this did not make a difference.
If it matters, I am referencing Infragistics 14.2
I needed to set mReport = New Infragistics.Documents.Reports.Report.Report(). After doing this, it resolved the issue - thankfully.
Hi Nicholas,
I'm happy to hear that you were able to work this out. Is there anything else that we can assist with?