1

What am I doing I am generating excel on client side using alasql library. I get JSON data from API and then I pass that data to alasql library to get excel downloaded with styles.

What is working Downloaded file gets saved in .xls extension with all the style applied (bold, color,...)

What is not working If I try to save the file in .xlsx format using alasql library I get following error message when opening excel file. "Excel cannot open the file because the file format or file extension is not valid verify that the file has not been corrupted and that the file extension matches the format of the file"

Purpose The reason why I want to use .xlsx and not .xls is because the size gets reduced and no other message pops up when opening file like (not from trusted source...)

Code

// A: This gives warning error unsafe to open. NOT good
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLS("A.xls",?) FROM ?', [opts, Apidata]);
// B: File corrupted. BAD
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLS("B.xlsx",?) FROM ?', [opts, Apidata]);
// C: This gives warning error unsafe to open. NOT good
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLSX("C.xls",?) FROM ?', [opts, Apidata]);
// D: No styling. NOT good
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLSX("D.xlsx",?) FROM ?', [opts, Apidata]);
// E: This gives warning error unsafe to open. NOT good
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLSXML("E.xls",?) FROM ?', [opts, Apidata]);
// F: File corrupted. BAD
alasql('SELECT name AS [Name], email AS [Email Address], dob AS [Date of Birth] INTO XLSXML("F.xlsx",?) FROM ?', [opts, Apidata]);

Demo
http://jsfiddle.net/6sd7zwjp/

Please help!

Alvin
  • 290
  • 5
  • 25
  • A feature request has been registered at [https://github.com/agershun/alasql/issues/574](https://github.com/agershun/alasql/issues/574) – Alvin Jul 09 '18 at 14:21

0 Answers0