mirror of
https://github.com/optilude/xlsx-template.git
synced 2026-07-02 08:27:39 +08:00
Merge branch 'master' into master
This commit is contained in:
+5
-6
@@ -1,6 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.12
|
||||
- 4
|
||||
- 6
|
||||
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.12
|
||||
- 6
|
||||
- 8
|
||||
|
||||
+8
-10
@@ -4,7 +4,7 @@
|
||||
"use strict";
|
||||
|
||||
var path = require('path'),
|
||||
zip = require('node-zip'),
|
||||
zip = require('jszip'),
|
||||
etree = require('elementtree');
|
||||
|
||||
module.exports = (function() {
|
||||
@@ -540,15 +540,13 @@ module.exports = (function() {
|
||||
// optionally, `table`, `rowAbsolute` and `colAbsolute`.
|
||||
Workbook.prototype.splitRef = function(ref) {
|
||||
var match = ref.match(/(?:(.+)!)?(\$)?([A-Z]+)(\$)?([0-9]+)/);
|
||||
if(match){
|
||||
return {
|
||||
table: match[1] || null,
|
||||
colAbsolute: Boolean(match[2]),
|
||||
col: match[3],
|
||||
rowAbsolute: Boolean(match[4]),
|
||||
row: parseInt(match[5], 10)
|
||||
};
|
||||
}
|
||||
return {
|
||||
table: match && match[1] || null,
|
||||
colAbsolute: Boolean(match && match[2]),
|
||||
col: match && match[3],
|
||||
rowAbsolute: Boolean(match && match[4]),
|
||||
row: parseInt(match && match[5], 10)
|
||||
};
|
||||
};
|
||||
|
||||
// Join an object with keys `row` and `col` into a single reference string
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"elementtree": "0.1.6",
|
||||
"node-zip": "1.1.1"
|
||||
"jszip": "^2.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"buster": "0.7.18",
|
||||
|
||||
@@ -534,7 +534,29 @@ describe("CRUD operations", function() {
|
||||
|
||||
});
|
||||
|
||||
it("Correctly parse when formula in the file", function(done) {
|
||||
|
||||
fs.readFile(path.join(__dirname, 'templates', 'template.xlsx'), function(err, data) {
|
||||
buster.expect(err).toBeNull();
|
||||
|
||||
var t = new XlsxTemplate(data);
|
||||
t.substitute(1, {
|
||||
people: [
|
||||
{
|
||||
name: "John Smith",
|
||||
age: 55,
|
||||
},
|
||||
{
|
||||
name: "John Doe",
|
||||
age: 35,
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user