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
80
Excel export - .net datetime to excel small date value
posted

I would like to export a grid content to excel using the ultragrid excel exporter.

One of my column is a datetime, but the excel column needs to be a small date.

I am aware I can change the format of the excel column during the export ( http://www.infragistics.com/community/forums/t/24639.aspx ) but changing the format doesn't change the value.

Is there any way to change the values inside the excel column to be small dates using the ultragrid excel exporter ?

Parents
No Data
Reply
  • 28945
    Verified Answer
    Offline posted

    Hello Matthieu,

    You can handle the exporter's CellExporting event to convert the datetimes to short dates using ToShortDateString method.

    eg code.


    void ultraGridExcelExporter1_CellExporting(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.CellExportingEventArgs e)        
    {        
         if (e.Value != e.GridColumn.Header.Caption)       
          {                 
             e.Value = ((DateTime)e.Value).ToShortDateString();      
          }   
    }

     

    Let me know if you have any questions regarding this matter.

Children