Set column in excel export as "date" format

When we use excel export per default, our dates get returned in the xlsx as long digits.

We want to achieve to show the actual formatted date (treated as date value in excel) in the xlsx File. How do we achieve this?


Kind regards,


Sebastian G.


4 Replies 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team March 16, 2022 04:36 PM UTC

Hi Sebastian, 

  Greetings from Syncfusion support. 

  Before proceeding to the solution, please provide the following details so that we may be able to provide a better solution ASAP. 

  • In your update you have mentioned that dates get returned in the xlsx as long digits, here what do you mean by  long digits?
  • You also mentioned that you want to actual formatted date, please explain this in detail.
  • Please share a screenshot or video demonstration of your requirement.
  • Please share the complete grid code you are using.

Please get back to us for further details. 

Regards, 
Joseph I.  



SG Sebastian Göhring replied to Joseph Christ Nithin Issack March 16, 2022 11:24 PM UTC

  • In your update you have mentioned that dates get returned in the xlsx as long digits, here what do you mean by  long digits?

Long - the default value for dates, counting the milliseconds from 1.1.1970 until now.

  • You also mentioned that you want to actual formatted date, please explain this in detail.

Excel has custom formats to intepret values differently. I dont want my date to be treated as number, I want it to be treated as Date by default (for example to further calculate difference between times between the rows)

  • Please share a screenshot or video demonstration of your requirement.
  • Please share the complete grid code you are using.

This is currently not possible.


SG Sebastian Göhring replied to Sebastian Göhring March 17, 2022 12:07 AM UTC

I solved it by myself. The required goal was acheived by using this inside 

excelQueryCellInfo

(for others who have the same issue):


let column = args.column;
if(column.type === "date"){
let intl = new Internationalization();
let dFormatter = intl.getDateFormat({ format: args.column.format, type: 'date', skeleton: args.column.format });
args.value = dFormatter(new Date(args.value))
}

Related thread: https://www.syncfusion.com/forums/143020/setting-a-grid-column-date-format-prevents-excel-and-csv-export-working




Marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team March 17, 2022 02:25 PM UTC

Hi Sebastian, 

  Thanks for your update. 

   We are glad that your issue has been resolved. 

   Please get back to us for further assistance. 

Regards, 
Joseph I. 


Loader.
Up arrow icon