我在做什么 我正在使用alasql库在客户端生成excel。我从API获取JSON数据,然后将该数据传递给alasql库以获取具有样式的excel。
正在做什么 下载的文件将保存为.xls扩展名,并应用所有样式(粗体,彩色等)
什么不起作用 如果我尝试使用alasql库将文件保存为.xlsx格式,则在打开excel文件时收到以下错误消息。 “ Excel无法打开文件,因为文件格式或文件扩展名无效,请验证文件未损坏并且文件扩展名与文件格式匹配”
目的 我要使用.xlsx而不是.xls的原因是因为打开文件时,文件的大小减小了,并且没有其他消息弹出(不是来自受信任的来源...)
代码
// 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]);
演示
http://jsfiddle.net/6sd7zwjp/
请帮忙!