rndme/download

Unable to generate .xlsx file from the data

ajaywcc9032 opened this issue · 1 comments

Hi,

Thanks you very much for this great resource.
I am using this to download Excel file with extension .xls by passing the html data as a data variable and no issues found it works perfectly as expected.
But now I need to download the same Excel file with extension .xlsx and I have tried calling download function as per below code snippets:

download(data, "text.xslx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

And also: download(data, "text.xslx", "text/xlsx")

It always gives me below error when I open the downloaded file:
image

I read all the relevant articles but could not find the solution. There was an article/issue which was fixed(#21) but that was related to the download .xlsx file from the URL and I need to download from the data which I am passing.
This passing data contains the dynamically generated html file.

Could you please help me in resolving this issue or guide me what mistake I am making ?

Thanks in advance !
Ajay

rndme commented

I'm not an excel expert, but I believe that the undocumented html-as-a-sheet behavior only works with the .xls extension. I've created a sample html table file and indeed, it opened fine (with a complaint dialog) when named .xsl, but when renamed to .xlsx, it refused to open. This is apart from downloading the file at all, so I'm closing since it doesn't relate to download.js; it's just how excel works, for better or worse.