Bandgridview Exports Columns column header information By default, not bands column header information, in order to export multi-layered costumes. The code is as follows
1 Public Static voidExportExcel2 (DevExpress.XtraGrid.Views.BandedGrid.BandedGridView bandedgridview)2 {3SaveFileDialog SaveFileDialog =NewSaveFileDialog ();4Savefiledialog.title ="Export Excel";5Savefiledialog.filter ="Excel File (*.xlsx) |*.xlsx";6DialogResult DialogResult =Savefiledialog.showdialog ();7 if(DialogResult = =DialogResult.OK)8 {9DevExpress.XtraPrinting.XlsxExportOptionsEx op =NewDevExpress.XtraPrinting.XlsxExportOptionsEx ();Ten OneOp. Exporttype =DevExpress.Export.ExportType.WYSIWYG; ABandedGridView.OptionsPrint.PrintHeader =false; -BandedGridView.OptionsPrint.AutoWidth =false; - bandedgridview.exporttoxlsx (Savefiledialog.filename, op); theDevExpress.XtraEditors.XtraMessageBox.Show ("Save success! ","Tips", MessageBoxButtons.OK, messageboxicon.information); - } -}
There are several points to note:
1. There are two options: DevExpress.XtraPrinting.XlsxExportOptions and DevExpress.XtraPrinting.XlsxExportOptionsEx, need to use: D EvExpress.XtraPrinting.XlsxExportOptionsEx;
There are two ways of 2.devexpress.export.exporttype: Dataaware and WYSIWYG; The default is Dataaware, which needs to be set to WYSIWYG;
3.the default values for each property under Optionsprint are true, set Printheader = False (do not display column headers) and Autowidth = False (not adaptive width)
Dev control learn-gridcontrol in Bandgridview Export multi-layer wardrobe operations