Skip to content

Commit 2225381

Browse files
committed
Merge branch 'release/0.4.10'
2 parents dc00c4d + b9bc662 commit 2225381

23 files changed

+14214
-13949
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Changelog
22

3-
> 0.4.11 "Lawdar" (xx.10.2018)
4-
> 0.4.10 "Maoshk" (xx.9.2018)
3+
> 0.4.11 "Lawdar" (xx.10.2018)
4+
5+
6+
7+
## 0.4.10 "Maoshk" (04.10.2018)
8+
9+
10+
Add: xlsxml files with multiple sheets
511

612

713
## 0.4.9 "Alsalfiah" (05.08.2018)

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to Contribute to the AlaSQL project
22

3-
Thank you very much or the your intentions! AlaSQL project still has a lot of thing to be improved, and your help is very appreciated!
3+
Thank you very much for your interest! AlaSQL project still has a lot of thing to be improved, and your help is very appreciated!
44

55
For you to edit the source please do the following:
66

@@ -15,11 +15,10 @@ For you to edit the source please do the following:
1515
- Run `npm test` to verify only the new test fails
1616
- Implement your contributions in `src/`
1717
- Run `npm test` and verify all tests are OK
18-
- Commit changes to git and push to your forked repo
18+
- Commit changes to git and push to your forked repo (including the `dist/` folder)
1919
- Click "Create Pull-request" when looking at your forked repo on Github
2020

2121
_Please note that `npm test` will compile from `src/` and overwrite `dist/` before running all tests_
2222

23-
24-
If you would would like to change the alasql.org website please make a PR to https://github.com/agershun/alasql-org
23+
If you would like to change the alasql.org website please make a PR to https://github.com/agershun/alasql-org
2524

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ _Got a question? Ask on [Stack Overflow](http://stackoverflow.com/questions/ask?
1313
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/328/badge)](https://bestpractices.coreinfrastructure.org/projects/328)
1414
[![](https://data.jsdelivr.com/v1/package/npm/alasql/badge?style=rounded)](https://www.jsdelivr.com/package/npm/alasql)
1515
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier)
16+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fagershun%2Falasql.svg?type=small)](https://app.fossa.io/projects/git%2Bgithub.com%2Fagershun%2Falasql?ref=badge_small)
17+
1618

1719

1820

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@
5757
"bin",
5858
"lib"
5959
],
60-
"version": "0.4.9"
60+
"version": "0.4.10"
6161
}

dist/alasql-worker.js

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.9 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.10 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.9
4+
@version 0.4.10
55
66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff

dist/alasql-worker.min.js

100755100644
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/alasql.fs.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.9 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.10 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.9
4+
@version 0.4.10
55

66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142142
Current version of alasql
143143
@constant {string}
144144
*/
145-
alasql.version = '0.4.9';
145+
alasql.version = '0.4.10';
146146

147147
/**
148148
Debug flag
@@ -4288,8 +4288,12 @@ utils.findAlaSQLPath = function() {
42884288
};
42894289

42904290
var getXLSX = function() {
4291-
var XLSX = null;
4292-
/* If require() shuold be supported else take from global scope */
4291+
var XLSX = alasql.private.externalXlsxLib;
4292+
4293+
if (XLSX) {
4294+
return XLSX;
4295+
}
4296+
42934297
if (utils.isNode || utils.isBrowserify || utils.isMeteorServer) {
42944298
//*not-for-browser/*
42954299
XLSX = require('xlsx') || null;
@@ -4527,6 +4531,14 @@ alasql.lastid = 0;
45274531

45284532
alasql.buffer = {};
45294533

4534+
alasql.private = {
4535+
externalXlsxLib: null,
4536+
};
4537+
4538+
alasql.setXLSX = function(XLSX) {
4539+
alasql.private.externalXlsxLib = XLSX;
4540+
};
4541+
45304542
/**
45314543
Select current database
45324544
@param {string} databaseid Selected database identificator
@@ -16720,10 +16732,18 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1672016732

1672116733
// Set sheets
1672216734
var sheets = {};
16735+
var sheetsdata;
16736+
var sheetscolumns;
1672316737
if (opts && opts.sheets) {
1672416738
sheets = opts.sheets;
16739+
// data and columns are already an array for the sheets
16740+
sheetsdata = data;
16741+
sheetscolumns = columns;
1672516742
} else {
1672616743
sheets.Sheet1 = opts;
16744+
// wrapd ata and columns array for single sheet
16745+
sheetsdata = [data];
16746+
sheetscolumns = [columns];
1672716747
}
1672816748

1672916749
// File is ready to save
@@ -16796,15 +16816,30 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1679616816
return 's' + styles[hh].styleid;
1679716817
}
1679816818

16819+
function values(obj) {
16820+
try {
16821+
return Object.values(obj);
16822+
} catch (e) {
16823+
// support for older runtimes
16824+
return Object.keys(obj).map(function(e) {
16825+
return obj[e];
16826+
});
16827+
}
16828+
}
16829+
16830+
var sheetidx = 0;
1679916831
for (var sheetid in sheets) {
1680016832
var sheet = sheets[sheetid];
16801-
16833+
var idx = typeof sheet.dataidx != 'undefined' ? sheet.dataidx : sheetidx++;
16834+
var data = values(sheetsdata[idx]);
1680216835
// If columns defined in sheet, then take them
16836+
var columns = undefined;
1680316837
if (typeof sheet.columns != 'undefined') {
1680416838
columns = sheet.columns;
1680516839
} else {
1680616840
// Autogenerate columns if they are passed as parameters
16807-
if (columns.length == 0 && data.length > 0) {
16841+
columns = sheetscolumns[idx];
16842+
if (columns === undefined || (columns.length == 0 && data.length > 0)) {
1680816843
if (typeof data[0] == 'object') {
1680916844
if (Array.isArray(data[0])) {
1681016845
columns = data[0].map(function(d, columnidx) {
@@ -16836,7 +16871,7 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1683616871
if (typeof column.columnid == 'undefined') column.columnid = columnidx;
1683716872
if (typeof column.title == 'undefined') column.title = '' + column.columnid.trim();
1683816873
if (sheet.headers && Array.isArray(sheet.headers))
16839-
column.title = sheet.headers[idx];
16874+
column.title = sheet.headers[columnidx];
1684016875
});
1684116876

1684216877
// Header

dist/alasql.js

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! AlaSQL v0.4.9 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
1+
//! AlaSQL v0.4.10 | © 2014-2018 Andrey Gershun & Mathias Rangel Wulff | License: MIT
22
/*
33
@module alasql
4-
@version 0.4.9
4+
@version 0.4.10
55

66
AlaSQL - JavaScript SQL database
77
© 2014-2016 Andrey Gershun & Mathias Rangel Wulff
@@ -142,7 +142,7 @@ var alasql = function(sql, params, cb, scope) {
142142
Current version of alasql
143143
@constant {string}
144144
*/
145-
alasql.version = '0.4.9';
145+
alasql.version = '0.4.10';
146146

147147
/**
148148
Debug flag
@@ -4283,8 +4283,12 @@ utils.findAlaSQLPath = function() {
42834283
};
42844284

42854285
var getXLSX = function() {
4286-
var XLSX = null;
4287-
/* If require() shuold be supported else take from global scope */
4286+
var XLSX = alasql["private"].externalXlsxLib;
4287+
4288+
if (XLSX) {
4289+
return XLSX;
4290+
}
4291+
42884292
if (utils.isNode || utils.isBrowserify || utils.isMeteorServer) {
42894293
/*not-for-browser/*
42904294
XLSX = require('xlsx') || null;
@@ -4522,6 +4526,14 @@ alasql.lastid = 0;
45224526

45234527
alasql.buffer = {};
45244528

4529+
alasql["private"] = {
4530+
externalXlsxLib: null,
4531+
};
4532+
4533+
alasql.setXLSX = function(XLSX) {
4534+
alasql["private"].externalXlsxLib = XLSX;
4535+
};
4536+
45254537
/**
45264538
Select current database
45274539
@param {string} databaseid Selected database identificator
@@ -16715,10 +16727,18 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1671516727

1671616728
// Set sheets
1671716729
var sheets = {};
16730+
var sheetsdata;
16731+
var sheetscolumns;
1671816732
if (opts && opts.sheets) {
1671916733
sheets = opts.sheets;
16734+
// data and columns are already an array for the sheets
16735+
sheetsdata = data;
16736+
sheetscolumns = columns;
1672016737
} else {
1672116738
sheets.Sheet1 = opts;
16739+
// wrapd ata and columns array for single sheet
16740+
sheetsdata = [data];
16741+
sheetscolumns = [columns];
1672216742
}
1672316743

1672416744
// File is ready to save
@@ -16791,15 +16811,30 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1679116811
return 's' + styles[hh].styleid;
1679216812
}
1679316813

16814+
function values(obj) {
16815+
try {
16816+
return Object.values(obj);
16817+
} catch (e) {
16818+
// support for older runtimes
16819+
return Object.keys(obj).map(function(e) {
16820+
return obj[e];
16821+
});
16822+
}
16823+
}
16824+
16825+
var sheetidx = 0;
1679416826
for (var sheetid in sheets) {
1679516827
var sheet = sheets[sheetid];
16796-
16828+
var idx = typeof sheet.dataidx != 'undefined' ? sheet.dataidx : sheetidx++;
16829+
var data = values(sheetsdata[idx]);
1679716830
// If columns defined in sheet, then take them
16831+
var columns = undefined;
1679816832
if (typeof sheet.columns != 'undefined') {
1679916833
columns = sheet.columns;
1680016834
} else {
1680116835
// Autogenerate columns if they are passed as parameters
16802-
if (columns.length == 0 && data.length > 0) {
16836+
columns = sheetscolumns[idx];
16837+
if (columns === undefined || (columns.length == 0 && data.length > 0)) {
1680316838
if (typeof data[0] == 'object') {
1680416839
if (Array.isArray(data[0])) {
1680516840
columns = data[0].map(function(d, columnidx) {
@@ -16831,7 +16866,7 @@ alasql.into.XLSXML = function(filename, opts, data, columns, cb) {
1683116866
if (typeof column.columnid == 'undefined') column.columnid = columnidx;
1683216867
if (typeof column.title == 'undefined') column.title = '' + column.columnid.trim();
1683316868
if (sheet.headers && Array.isArray(sheet.headers))
16834-
column.title = sheet.headers[idx];
16869+
column.title = sheet.headers[columnidx];
1683516870
});
1683616871

1683716872
// Header

dist/alasql.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)