File-Saver download screen table is saved in excel format

I now use the angularjs2 framework, typescript + File-Saver to download the table data on the screen and save it to excel

function onDownload (data) {
const blob = new Blob ([$("- sharptable"). Html ()],

{ type: "application/vnd.ms-excel;" });

saveAs (blob, "export.xls");
}

The

download can proceed normally, but when I open excel, it will prompt me that the file format or file extension is incorrect and whether to continue.
ask the bosses if they have a solution.

Mar.13,2021

your this is obviously saved in text format (because the content of your blob is .html). If it is in csv format, you should use csv as the extension of the downloaded file, so that excel will not report an error.

Menu