Home » excel » In ag-grid Excel export, how to get a null datetime type to be empty cell instead of 1900.01.00

In ag-grid Excel export, how to get a null datetime type to be empty cell instead of 1900.01.00

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am using ag-grid and using its “export to excel” feature. I am exporting a column which is a datetime type. I am basically doing as I (very briefly) outlined in my answer here (https://stackoverflow.com/a/49523800/1082063) to another users question. It works well, except for one glitch.

If an AG-grid cell value is null, i.e. the cell empty, I want the cell in the exported Excel workbook to also be empty. However, when the “null” value is returned for a cell, ag-grid puts in a cell in the workbook with <Data ss:Type="DateTime"></Data>, which gets interpreted by Excel as 1900-01-00.

Any way around this?

How to&Answers:

Format the cells as yyyy-mm-dd;;; . A cell rendered blank by formatting exports a blank cell.