Kkt2
Kkt2

Reputation: 67

Hiding a column value before exporting to xls

I have a gridview, gridViewOrders, with master-detail relationship. I am hiding default values for the column OrderedDate in gridViewOrders_CustomUnboundColumnData event as follows

if((DateTime)e.Value == DEFAULT_DATE)
{
     e.Value = null;
}

When I try to export the same grid (using gridViewOrders.ExportToXls(fileName)) to an Xls; these hidden values are shown in the excel as exported excel file which something not intended. I want the detail row not to display the value if it = DEFAULT_DATE (DEFAULT_DATE = 01/01/2000).

MainView

Id  Name  OrderedDate
 1   K_23 
 2   J_11  12/03/2019
 3   K_4   15/02/2020
 4   P_3

Exported to XLS

 Id  Name  OrderedDate
 1   K_23  01/01/2000
 2   J_11  12/03/2019
 3   K_4   15/02/2020
 4   P_3   01/01/2000

Upvotes: 1

Views: 255

Answers (1)

Lucifer
Lucifer

Reputation: 1594

Hi please try setting TextExportMode to Text

For example:

yourGrid.ExportToXls(yourFilePath,new DevExpress.XtraPrinting.XlsExportOptions()
{
                TextExportMode = DevExpress.XtraPrinting.TextExportMode.Text
});

Upvotes: 1

Related Questions