We are in the process of adding export to XLS / PDF and printing support to our grids using the UltraGridPrintDocument, UltraPrintPreviewDialog, UltraGridDocumentExporter and the UltraGridExcelExporter.
The core printing and export functionality is all working nicely except for one issue. We have a number of columns showing in our UltraGrid that while they need to be displayed on screen should be excluded from any printout or export. Is there an easy way to achieve this please?
If it makes a difference the grid uses a mix of bound and unbound columns.
Regards,
Simon Geering.
You can use the exporter BeginExport event to hide any column you want.
Thanks for your reply Amiram, I've put together the following event handlers for this but am having no joy:
Private Shared Sub Exporter_BeginExport(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.DocumentExport.BeginExportEventArgs) Handles mobjUltraGridDocumentExporter.BeginExport Hide_Columns(e.Layout) End Sub Private Shared Sub mobjUltraGridExcelExporter_BeginExport(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs) Handles mobjUltraGridExcelExporter.BeginExport Hide_Columns(e.Layout) End Sub
Which then call:
Private Shared Sub Hide_Columns(ByRef objDisplay_Layout As Infragistics.Win.UltraWinGrid.UltraGridLayout) For Each objBand In objDisplay_Layout.Bands For Each strFieldName In mstrHidden_Fields If objBand.Columns.Exists(strFieldName) Then objBand.Columns(strFieldName).Hidden = True End If Next Next End Sub
I must be missing something because the Hidden property seems to have no impact on if the column is visible in the export. In this test case i use CSV as the target export format since it is easier to verify the results for hiding columns at the end of the grid than in XLS format.
Anyone any ideas?
Is the instance of the grid you get in the event args the same as the underlying grid or is it a clone in the same way I understand that printing makes a clone of your grid for printing only. If so I can always get round this by removing the columns but I would of thought this should not be needed!
Any help gratefully appreciated