Correcting date formats when exporting to Excel

Hi,

How can I change the date formats for my DateTime columms when exporting to Excel?  Date column values are exported to default Excel date formats, I want to specify for example that Date values be in "yyyy-MM-dd" formats to match Mariadb DateTime column format.  I tried using CellExporting event as below:

private void Options_CellExporting(object sender, DataGridCellExcelExportingEventArgs e)

        {

            if (e.ColumnName == "MfgDate" || e.ColumnName == "ExpiryDate")

            {

                e.Range.CellStyle.NumberFormat = "yyyy-MM-dd";

            }

        }

But it didn't do anything.   Appreciate your help and suggestions.

Thanks,

Sandy


2 Replies

SA San September 1, 2022 12:16 AM UTC

Hi ,

I think I got it now.  Just did the formatting using XLSIO instead.


Thanks anyway.

Sandy



VS Vijayarasan Sivanandham Syncfusion Team September 1, 2022 05:42 AM UTC

Hi San,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.

Regards,
Vijayarasan S



Loader.
Up arrow icon