Date format changed to sevral format while exporting to excel

I am trying to convert my php based report into excel by using below code. everything is working fine, but the date is changed to different format. How can i fixed that issue. Can expert guide me about this ???
excel export code


    function html_table_to_excel(type)
        var data = document.getElementById('employee_data');

        var file = XLSX.utils.table_to_book(data, {sheet: "sheet1"});

        XLSX.write(file, { bookType: type, bookSST: true, type: 'base64' });

        XLSX.writeFile(file, 'Procedure Wise Report.' + type);

    const export_button = document.getElementById('export_button');

    export_button.addEventListener('click', () =>  {


is it different in the raw file, or in excels presentation of it?

its in excel presentation

So if it looks one way in the raw XSLX file, and a different in the excel app, that’s not a problem in the script, it’s how excel is formatting the date. You can change that in excel.

its showing same output every where some thing like below image . As showing in image, first three top row its in mm-dd-yy format, after three row its in dd/mm/yyyy and so on

I’m going to guess thats because 10-12-23 is ambiguous.

It could be mm-dd-yy. (October 12th)
It could also be dd-mm-yy. (December 10th)

10-13-23 is not ambiguous, because there is no 13th month of the year, so it must be October 13th.

this is html/page page from where i export into excel format. The standard format in below html page is dd/mm/yyyy. Should I try to change the html date format into dd-mmm-yy ??? may be it can solve the issue ?


I will assume (because it hasnt been specified) that you are using SheetJS to convert this, because it’s the only function reference i can find in google that appears to match.

Based on the Documentation of this function, what happens if you change
var file = XLSX.utils.table_to_book(data, {sheet: "sheet1"});
var file = XLSX.utils.table_to_book(data, {sheet: "sheet1", cellDates: true});

out of suggested change by you. i am using javascript via this link

<script type="text/javascript" src=""></script>


okay… lets try forcing the output…

var file = XLSX.utils.table_to_book(data, {sheet: "sheet1", cellDates: true, dateNF: "dd/mm/yyyy"});

1 Like

issue is solved! Thanks alot sir

1 Like