Comparing version 0.12.1 to 0.13.0
@@ -46,3 +46,10 @@ 'use strict'; | ||
var name = worksheet.name || 'Sheet'; | ||
var data = (0, _helpers.buildSheetFromMatrix)(worksheet.data || [], options); | ||
// If worksheet has options, use this one ; if there's only one worksheet, use global options (for retro-compatibility) | ||
var optionsLocal = {}; | ||
if (worksheet.options) { | ||
optionsLocal = worksheet.options; | ||
} else if (worksheets.length === 1 && options) { | ||
optionsLocal = options; | ||
} | ||
var data = (0, _helpers.buildSheetFromMatrix)(worksheet.data || [], optionsLocal); | ||
workBook.SheetNames.push(name); | ||
@@ -49,0 +56,0 @@ workBook.Sheets[name] = data; |
{ | ||
"name": "node-xlsx", | ||
"author": "Olivier Louvignes <olivier@mg-crea.com>", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "NodeJS Excel files parser & builder", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"buffer-from": "^1.1.0", | ||
"xlsx": "^0.12.4" | ||
"xlsx": "^0.14.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "devDependencies": { |
# Node XLSX | ||
![status](https://img.shields.io/badge/status-maintained-brightgreen.svg) | ||
[![npm version](https://img.shields.io/npm/v/node-xlsx.svg?style=flat)](https://www.npmjs.com/package/node-xlsx) | ||
[![license](https://img.shields.io/github/license/mgcrea/node-xlsx.svg?style=flat)](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)) | ||
[![npm downloads](https://img.shields.io/npm/dm/node-xlsx.svg)](https://www.npmjs.com/package/node-xlsx) | ||
[![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)](https://tldrlegal.com/license/apache-license-2.0-(apache-2.0))<br /> | ||
[![build status](http://img.shields.io/travis/mgcrea/node-xlsx/master.svg?style=flat)](http://travis-ci.org/mgcrea/node-xlsx) | ||
@@ -10,4 +12,4 @@ [![dependencies status](https://img.shields.io/david/mgcrea/node-xlsx.svg?style=flat)](https://david-dm.org/mgcrea/node-xlsx) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/5bbea5e7b2084c2586e5599cda6aefc8)](https://www.codacy.com/app/mgcrea/node-xlsx?utm_source=github.com&utm_medium=referral&utm_content=mgcrea/node-xlsx&utm_campaign=Badge_Coverage) | ||
[![npm downloads](https://img.shields.io/npm/dm/node-xlsx.svg)](https://www.npmjs.com/package/node-xlsx) | ||
Excel file parser/builder that relies on [js-xlsx](https://github.com/SheetJS/js-xlsx). | ||
@@ -17,3 +19,4 @@ | ||
## Usage | ||
### Installation | ||
```npm install node-xlsx --save``` | ||
### Examples | ||
@@ -43,3 +46,3 @@ | ||
* Building a xlsx (spannig multiple rows `A1:A4`) | ||
* Custom column width | ||
```js | ||
@@ -49,2 +52,13 @@ import xlsx from 'node-xlsx'; | ||
const data = [[1, 2, 3], [true, false, null, 'sheetjs'], ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux']] | ||
const option = {'!cols': [{ wch: 6 }, { wch: 7 }, { wch: 10 }, { wch: 20 } ]}; | ||
var buffer = xlsx.build([{name: "mySheetName", data: data}], option); // Returns a buffer | ||
``` | ||
* Spanning multiple rows `A1:A4` in every sheets | ||
```js | ||
import xlsx from 'node-xlsx'; | ||
// Or var xlsx = require('node-xlsx').default; | ||
const data = [[1, 2, 3], [true, false, null, 'sheetjs'], ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux']]; | ||
@@ -56,4 +70,18 @@ const range = {s: {c: 0, r:0 }, e: {c:0, r:3}}; // A1:A4 | ||
``` | ||
* Spanning multiple rows `A1:A4` in second sheet only | ||
```js | ||
import xlsx from 'node-xlsx'; | ||
// Or var xlsx = require('node-xlsx').default; | ||
const dataSheet1 = [[1, 2, 3], [true, false, null, 'sheetjs'], ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux']]; | ||
const dataSheet2 = [[4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14], ['baz', null, 'qux']]; | ||
const range = {s: {c: 0, r:0 }, e: {c:0, r:3}}; // A1:A4 | ||
const option = {'!merges': [ range ]}; | ||
var buffer = xlsx.build([{name: "myFirstSheet", data: dataSheet1}, {name: "mySecondSheet", data: dataSheet2, options: options}]); // Returns a buffer | ||
``` | ||
_Beware that if you try to merge several times the same cell, your xlsx file will be seen as corrupted._ | ||
### Troubleshooting | ||
@@ -66,3 +94,3 @@ | ||
Object.prototype.assign = require('object-assign'); | ||
``` | ||
``` | ||
@@ -69,0 +97,0 @@ |
@@ -24,3 +24,10 @@ | ||
const name = worksheet.name || 'Sheet'; | ||
const data = buildSheetFromMatrix(worksheet.data || [], options); | ||
// If worksheet has options, use this one ; if there's only one worksheet, use global options (for retro-compatibility) | ||
let optionsLocal = {}; | ||
if (worksheet.options) { | ||
optionsLocal = worksheet.options; | ||
} else if (worksheets.length === 1 && options) { | ||
optionsLocal = options; | ||
} | ||
const data = buildSheetFromMatrix(worksheet.data || [], optionsLocal); | ||
workBook.SheetNames.push(name); | ||
@@ -27,0 +34,0 @@ workBook.Sheets[name] = data; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85941
33
140
462
+ Addedadler-32@1.3.1(transitive)
+ Addedcfb@1.2.2(transitive)
+ Addedcodepage@1.14.0(transitive)
+ Addedcommander@2.17.1(transitive)
+ Addedxlsx@0.14.5(transitive)
- Removedcfb@1.0.8(transitive)
- Removedcodepage@1.13.1(transitive)
- Removedcommander@2.15.1(transitive)
- Removedxlsx@0.12.13(transitive)
Updatedxlsx@^0.14.1