Alasql: Error with xls and Excel 2010 (14.0.6106.5005)

Created on 2 Feb 2016  路  11Comments  路  Source: agershun/alasql

Exporting an xls file with alasql, I get the following error when opening the file in Excel:

"The file you are trying to open, 'file.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file."

! Bug Excel

All 11 comments

What code are you using?

The example code listed on the wiki:

var data = [{a:3,b:10},{a:2,b:20}];
var mystyle = {
headers:true,
column: {style:{Font:{Bold:"1"}}},
rows: {1:{style:{Font:{Color:"#FF0077"}}}},
cells: {1:{1:{
style: {Font:{Color:"#00FFFF"}}
}}}
};
alasql('SELECT * INTO XLSXML("restest280b.xls",?) FROM ?',[mystyle,data]);

https://github.com/agershun/alasql/wiki/XLSX

Here is a plunkr:
https://plnkr.co/edit/HhE021QKXGHi3JXpeGX2

I don't get the error when the extension is .xml. I was hoping there was a way to export JSON to an xls file in a clean fashion with formatting. alasql is the only javascript solution I have found that fits my needs. However, I don't want to have to require my clients to dismiss an error message every time they open a file.

XLSXM should be saved as xml (as I remember) but anyway - the example is wrong. We need to change that.

What if you do a XLSX("restest280b.xlsx"? (if you are on browser please include "https://github.com/SheetJS/js-xlsx")

What about XLS("restest280b.xls" - is that working out for you?

That doesn't seem to respect my formatting at all. Updated plunkr:

https://plnkr.co/edit/HhE021QKXGHi3JXpeGX2?p=preview

I get this

skaermbillede 2016-02-03 00 21 10

What are you hoping to get?

You didn't notice that the formatting is missing? The column/row/cell coloring is not present.

Ahhh, yes yes yes - sorry.

Does @agershun have anything to say on this?

Very similar kind of issue i am facing:

var mystyle = {
            sheetid: $scope.Title,
            headers: true,
            caption: {
                title: $scope.Title,
                style: 'font-size: 15px; color:black; text-align: left; width: 100px'
            },
            column: {
                style: 'font-size:15px'
            },
            columns: [
              { columnid: 'Name', title: 'Name', width: 300 },
              { columnid: 'Level', title: 'Level' },
            ]
        };

 alasql('SELECT * INTO XLS("' + $scope.Title + '.xls",?) FROM ?', [mystyle, $scope.ExportSet]);

When i do export, it is successfully doing this with all styles into .xls file but when i open it, an warning message is appearing

"The file you are trying to open, 'file.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file."

I cannot update Registry keys in Client's machines / servers.

I tried using

alasql('SELECT * INTO XLSX("' + $scope.Title + '.xlsx",?) FROM ?', [mystyle, $scope.ExportSet]);

it is trying to export it with out any formats, so Caption data is not at all visible but while opening no warning are made.

So i need either I should apply styles to xlsx file or get rid of warning with .xls file.

Can you please help me in this ?

Does @agershun have anything to say on this?

Any updates?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fredt34 picture fredt34  路  5Comments

peon501 picture peon501  路  5Comments

DickSwart picture DickSwart  路  6Comments

SWard1992 picture SWard1992  路  3Comments

mathiasrw picture mathiasrw  路  5Comments