@atomictech/xlsx-write-stream
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -19,6 +19,8 @@ "use strict"; | ||
* @param {Object} [options] | ||
* @param {Boolean} [options.format=true] - If set to false writer will not format cells with number, date, boolean and text. Default: true. | ||
* @param {Boolean} [options.headers=false] - If set to true writer will output first row with an header style. | ||
* @param {Boolean} [options.format=true] - If set to false writer will not format cells with number, date, boolean and text. | ||
* @param {Styles} [options.styles=new Styles()] - If set you can overwrite default standard type styles by other standard ones or even define custom `formatCode`. | ||
*/ | ||
constructor({ | ||
headers = false, | ||
format = true, | ||
@@ -31,4 +33,6 @@ styles = new _templates.Styles() | ||
this.rowCount = 0; | ||
this.headers = headers; | ||
this.format = format; | ||
this.styles = styles; | ||
if (this.headers) throw new Error('Headers special style output not yet implemented.'); | ||
} | ||
@@ -41,4 +45,2 @@ /** | ||
_transform(row, encoding, callback) { | ||
if (!Array.isArray(row)) return callback(); // TODO: Handle row as Object with column headers as keys | ||
const xlsxRow = (0, _templates.Row)(this.rowCount, row, this.format, this.styles); | ||
@@ -52,2 +54,2 @@ this.rowCount++; | ||
exports.default = XLSXRowTransform; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9YTFNYUm93VHJhbnNmb3JtLmpzIl0sIm5hbWVzIjpbIlhMU1hSb3dUcmFuc2Zvcm0iLCJUcmFuc2Zvcm0iLCJjb25zdHJ1Y3RvciIsImZvcm1hdCIsInN0eWxlcyIsIlN0eWxlcyIsIm9iamVjdE1vZGUiLCJyb3dDb3VudCIsIl90cmFuc2Zvcm0iLCJyb3ciLCJlbmNvZGluZyIsImNhbGxiYWNrIiwiQXJyYXkiLCJpc0FycmF5IiwieGxzeFJvdyJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQUFBOztBQUNBOztBQUVBOzs7QUFHZSxNQUFNQSxnQkFBTixTQUErQkMsaUJBQS9CLENBQXlDO0FBQ3REOzs7Oz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B3aXRoIG51bWJlciwgZGF0ZSwgYm9vbGVhbiBhbmQgdGV4dC5cbiAgICogQHBhcmFtIHtTdHlsZXN9IFtvcHRpb25zLnN0eWxlcz1uZXcgU3R5bGVzKCldIC0gSWYgc2V0IHlvdSBjYW4gb3ZlcndyaXRlIGRlZmF1bHQgc3RhbmRhcmQgdHlwZSBzdHlsZXMgYnkgb3RoZXIgc3RhbmRhcmQgb25lcyBvciBldmVuIGRlZmluZSBjdXN0b20gYGZvcm1hdENvZGVgLlxuICAgKi9cbiAgY29uc3RydWN0b3IoeyBoZWFkZXJzID0gZmFsc2UsIGZvcm1hdCA9IHRydWUsIHN0eWxlcyA9IG5ldyBTdHlsZXMoKSB9KSB7XG4gICAgc3VwZXIoeyBvYmplY3RNb2RlOiB0cnVlIH0pO1xuXG4gICAgdGhpcy5yb3dDb3VudCA9IDA7XG4gICAgdGhpcy5oZWFkZXJzID0gaGVhZGVycztcbiAgICB0aGlzLmZvcm1hdCA9IGZvcm1hdDtcbiAgICB0aGlzLnN0eWxlcyA9IHN0eWxlcztcblxuICAgIGlmICh0aGlzLmhlYWRlcnMpIHRocm93IG5ldyBFcnJvcignSGVhZGVycyBzcGVjaWFsIHN0eWxlIG91dHB1dCBub3QgeWV0IGltcGxlbWVudGVkLicpO1xuICB9XG5cbiAgLyoqXG4gICAqIFRyYW5zZm9ybSBhcnJheSB0byByb3cgc3RyaW5nXG4gICAqL1xuICBfdHJhbnNmb3JtKHJvdywgZW5jb2RpbmcsIGNhbGxiYWNrKSB7XG4gICAgY29uc3QgeGxzeFJvdyA9IFJvdyh0aGlzLnJvd0NvdW50LCByb3csIHRoaXMuZm9ybWF0LCB0aGlzLnN0eWxlcyk7XG4gICAgdGhpcy5yb3dDb3VudCsrO1xuICAgIGNhbGxiYWNrKG51bGwsIHhsc3hSb3cpO1xuICB9XG59XG4iXX0= |
@@ -8,2 +8,4 @@ "use strict"; | ||
var _defaultsDeep = _interopRequireDefault(require("lodash/defaultsDeep")); | ||
var _archiver = _interopRequireDefault(require("archiver")); | ||
@@ -23,17 +25,18 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const isBoolean = value => value === !!value; | ||
/** | ||
* XLSX Write Stream base class | ||
*/ | ||
class XLSXWriteStream extends _stream.Transform { | ||
/** | ||
* Create new Stream | ||
* Create new stream transform that handles Array or Object as input chunks. | ||
* Be aware that first row chunk is determinant in the transform configuration process for further row chunks. | ||
* @class XLSXWriteStream | ||
* @extends Transform | ||
* @param {Object} [options] | ||
* @param {Array|Boolean} [options.headers=false] - If set to an array they will be printed in first row, no matter what is streamed in input. | ||
* If receiving objects from input stream, only properties given in headers will be printed following headers order. | ||
* If set to true it only has effect when streaming objects in order to print inferred headers in first place. | ||
* @param {Boolean} [options.format=true] - If set to false writer will not format cells with number, date, boolean and text. | ||
@@ -47,9 +50,30 @@ * @param {Object} [options.styleDefs] - If set you can overwrite default standard type styles by other standard ones or even define custom `formatCode`. | ||
}); | ||
this.pipelineInitialized = false; | ||
this.initialized = false; | ||
this.options = Object.assign({ | ||
this.arrayMode = null; | ||
this.options = (0, _defaultsDeep.default)({}, options, { | ||
headers: false, | ||
format: true, | ||
immediateInitialization: false | ||
}, options); | ||
}); | ||
if (this.options.immediateInitialization) this._initializePipeline(); | ||
} | ||
_transform(chunk, encoding, callback) { | ||
if (!this.initialized) this._initialize(chunk); | ||
this.toXlsxRow.write(this.normalize(chunk), encoding, callback); | ||
} | ||
_initialize(chunk) { | ||
this._initializePipeline(); | ||
this._initializeHeaders(chunk); | ||
if (chunk) { | ||
this.arrayMode = Array.isArray(chunk); | ||
this.normalize = this.arrayMode ? chunk => this.options.headers.map((value, index) => chunk[index]) : chunk => this.options.headers.map(key => chunk[key]); | ||
} | ||
this.initialized = true; | ||
} | ||
/** | ||
@@ -61,2 +85,3 @@ * Initialize pipeline with xlsx archive common files | ||
_initializePipeline() { | ||
if (this.pipelineInitialized) return; | ||
this.zip = (0, _archiver.default)('zip', { | ||
@@ -85,5 +110,6 @@ forceUTC: true | ||
this.zip.on('data', data => this.push(data)).on('warning', err => this.emit('warning', err)).on('error', err => this.error('error', err)); | ||
this.toXlsxRow = new _XLSXRowTransform.default(_objectSpread({}, this.options, { | ||
this.toXlsxRow = new _XLSXRowTransform.default({ | ||
format: this.options.format, | ||
styles | ||
})); | ||
}); | ||
this.sheetStream = new _stream.PassThrough(); | ||
@@ -95,12 +121,29 @@ this.sheetStream.write(templates.SheetHeader); | ||
}); | ||
this.initialized = true; | ||
this.pipelineInitialized = true; | ||
} | ||
_transform(chunk, encoding, callback) { | ||
if (!this.initialized) this._initializePipeline(); | ||
this.toXlsxRow.write(chunk, encoding, callback); | ||
_initializeHeaders(chunk = []) { | ||
const shouldPrintHeaders = !!this.options.headers; | ||
if (Array.isArray(chunk)) { | ||
if (isBoolean(this.options.headers)) { | ||
// Cannot infer headers from an Array | ||
// => Ignore `headers` option silently. | ||
this.options.headers = chunk.map(() => undefined); | ||
return; | ||
} | ||
} else { | ||
if (isBoolean(this.options.headers)) { | ||
// Init headers from chunk | ||
this.options.headers = [...Object.keys(chunk)]; | ||
} | ||
} | ||
if (shouldPrintHeaders) { | ||
this.toXlsxRow.write(this.options.headers); | ||
} | ||
} | ||
_flush(callback) { | ||
if (!this.initialized) this._initializePipeline(); | ||
if (!this.initialized) this._initialize(); | ||
@@ -124,2 +167,2 @@ this._finalize().then(() => { | ||
exports.default = XLSXWriteStream; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9YTFNYV3JpdGVTdHJlYW0uanMiXSwibmFtZXMiOlsiWExTWFdyaXRlU3RyZWFtIiwiVHJhbnNmb3JtIiwiY29uc3RydWN0b3IiLCJvcHRpb25zIiwib2JqZWN0TW9kZSIsImluaXRpYWxpemVkIiwiT2JqZWN0IiwiYXNzaWduIiwiZm9ybWF0IiwiaW1tZWRpYXRlSW5pdGlhbGl6YXRpb24iLCJfaW5pdGlhbGl6ZVBpcGVsaW5lIiwiemlwIiwiZm9yY2VVVEMiLCJjYXRjaEVhcmx5RXhpdEF0dGFjaGVkIiwiYXBwZW5kIiwidGVtcGxhdGVzIiwiQ29udGVudFR5cGVzIiwibmFtZSIsIlJlbHMiLCJXb3JrYm9vayIsIldvcmtib29rUmVscyIsInN0eWxlcyIsIlN0eWxlcyIsInN0eWxlRGVmcyIsInJlbmRlciIsIm9uIiwiZGF0YSIsInB1c2giLCJlcnIiLCJlbWl0IiwiZXJyb3IiLCJ0b1hsc3hSb3ciLCJYTFNYUm93VHJhbnNmb3JtIiwic2hlZXRTdHJlYW0iLCJQYXNzVGhyb3VnaCIsIndyaXRlIiwiU2hlZXRIZWFkZXIiLCJwaXBlIiwiX3RyYW5zZm9ybSIsImNodW5rIiwiZW5jb2RpbmciLCJjYWxsYmFjayIsIl9mbHVzaCIsIl9maW5hbGl6ZSIsInRoZW4iLCJlbmQiLCJTaGVldEZvb3RlciIsImZpbmFsaXplIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQUE7O0FBQ0E7O0FBQ0E7O0FBQ0E7Ozs7Ozs7Ozs7Ozs7O0FBRUE7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xuICAgICAgICB0aGlzLm9wdGlvbnMuaGVhZGVycyA9IGNodW5rLm1hcCgoKSA9PiB1bmRlZmluZWQpO1xuICAgICAgICByZXR1cm47XG4gICAgICB9XG4gICAgfSBlbHNlIHtcbiAgICAgIGlmIChpc0Jvb2xlYW4odGhpcy5vcHRpb25zLmhlYWRlcnMpKSB7XG4gICAgICAgIC8vIEluaXQgaGVhZGVycyBmcm9tIGNodW5rXG4gICAgICAgIHRoaXMub3B0aW9ucy5oZWFkZXJzID0gWy4uLk9iamVjdC5rZXlzKGNodW5rKV07XG4gICAgICB9XG4gICAgfVxuXG4gICAgaWYgKHNob3VsZFByaW50SGVhZGVycykge1xuICAgICAgdGhpcy50b1hsc3hSb3cud3JpdGUodGhpcy5vcHRpb25zLmhlYWRlcnMpO1xuICAgIH1cbiAgfVxuXG4gIF9mbHVzaChjYWxsYmFjaykge1xuICAgIGlmICghdGhpcy5pbml0aWFsaXplZCkgdGhpcy5faW5pdGlhbGl6ZSgpO1xuICAgIHRoaXMuX2ZpbmFsaXplKCkudGhlbigoKSA9PiB7XG4gICAgICBjYWxsYmFjaygpO1xuICAgIH0pO1xuICB9XG5cbiAgLyoqXG4gICAqIEZpbmFsaXplIHRoZSB6aXAgYXJjaGl2ZVxuICAgKi9cbiAgX2ZpbmFsaXplKCkge1xuICAgIHRoaXMuc2hlZXRTdHJlYW0uZW5kKHRlbXBsYXRlcy5TaGVldEZvb3Rlcik7XG4gICAgcmV0dXJuIHRoaXMuemlwLmZpbmFsaXplKCk7XG4gIH1cbn1cbiJdfQ== |
{ | ||
"name": "@atomictech/xlsx-write-stream", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Stream huge amount of data into an XLSX generated file stream with minimum memory footprint.", | ||
@@ -50,2 +50,3 @@ "main": "dist/index.js", | ||
"archiver": "^3.1.1", | ||
"lodash": "^4.17.15", | ||
"xml-escape": "^1.1.0" | ||
@@ -52,0 +53,0 @@ }, |
@@ -19,4 +19,5 @@ # ⏩ XLSX Write Stream ⏩ | ||
- [🦄 Usage](#%f0%9f%a6%84-usage) | ||
- [Basic](#basic) | ||
- [Custom Styles](#custom-styles) | ||
- [Basic pipe](#basic-pipe) | ||
- [Basic write](#basic-write) | ||
- [Custom styles](#custom-styles) | ||
- [🔧 API](#%f0%9f%94%a7-api) | ||
@@ -35,3 +36,3 @@ - [XLSXWriteStream ⇐ `Transform`](#xlsxwritestream-%e2%87%90-transform) | ||
```sh | ||
npm install '@atomictech/xlsx-write-stream' | ||
npm install @atomictech/xlsx-write-stream | ||
``` | ||
@@ -41,7 +42,26 @@ | ||
### Basic | ||
For all usages keep in mind that you should feed your `XLSXWriteStream` instance one row at a time, where a row could be an array or an object. | ||
```js | ||
import XLSXWriteStream from 'xlsx-write-stream'; | ||
const row = [1, '02', new Date('2015-10-21T16:29:00.000Z'), true, false, '🦄']; | ||
``` | ||
or | ||
```js | ||
const row = { | ||
'A Number Column': 1, | ||
'A Text Column': '02', | ||
'A Date Column': new Date('2015-10-21T16:29:00.000Z'), | ||
'A Boolean Column': true, | ||
'Another Boolean Column': false, | ||
'Another Text Column': '🦄' | ||
}; | ||
``` | ||
### Basic pipe | ||
```js | ||
import XLSXWriteStream from '@atomictech/xlsx-write-stream'; | ||
// Initialize the writer | ||
@@ -54,9 +74,19 @@ const xlsxWriter = new XLSXWriteStream(); | ||
// xlsxWriter should be feed with chunks representing a row as an array of values. | ||
// Cell values type supported are: string, number, boolean and date. | ||
// Pipe the writer into a Stream.Writable output stream in order to retrieve XLSX file data, | ||
// write it into file or send it as HTTP response. | ||
const writeStream = fs.createWriteStream('file.xlsx'); | ||
xlsxWriter.pipe(writeStream); | ||
``` | ||
// Alternatively you can use the writer `write(chunk)` method in order to fill your xlsx. | ||
const row = [1, '02', new Date('2015-10-21T16:29:00.000Z'), true, false]; | ||
xlsxWriter.write(row); | ||
### Basic write | ||
```js | ||
import XLSXWriteStream from '@atomictech/xlsx-write-stream'; | ||
// [optional] Define some headers | ||
const headers = ['A Number Column', 'A Text Column', 'A Date Column', 'A Boolean Column', 'Another Boolean Column', 'Another Text Column']; | ||
// Initialize the writer | ||
const xlsxWriter = new XLSXWriteStream({ headers }); | ||
// Pipe the writer into a Stream.Writable output stream in order to retrieve XLSX file data, | ||
@@ -66,10 +96,20 @@ // write it into file or send it as HTTP response. | ||
xlsxWriter.pipe(writeStream); | ||
// Write rows one by one with | ||
const row = [1, '02', new Date('2015-10-21T16:29:00.000Z'), true, false, '🦄']; | ||
xlsxWriter.write(row); | ||
xlsxWriter.end(); // Do not forget to end the stream! | ||
``` | ||
### Custom Styles | ||
⚠️ **Caution** ⚠️ | ||
If you are not familiar with streams, in order to take advantage of the smallest memory footprint possible with this form, you need to be aware of backpressure concept and use the boolean returned by the write function! | ||
> See explanations here: [writable.write(chunk[, encoding][, callback])](https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback) | ||
### Custom styles | ||
An `options.styleDefs` parameter is available in order to redefine type style formats. | ||
```js | ||
import { TypeStyleKey } from 'xlsx-write-stream'; | ||
import { TypeStyleKey } from '@atomictech/xlsx-write-stream'; | ||
@@ -93,7 +133,11 @@ // Declare custom styles definitions | ||
Create new stream transform that handles Array or Object as input chunks. | ||
Be aware that first row chunk is determinant in the transform configuration process for further row chunks. | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [options] | `Object` | | | | ||
| [options.headers] | `Array|Boolean` | `false` | If set to an array they will be printed in first row, no matter what is streamed in input. If receiving objects from input stream, only properties given in headers will be printed following headers order. If set to true it only has effect when streaming objects in order to print inferred headers in first place.| | ||
| [options.format] | `Boolean` | `true` | If set to false writer will not format cells with number, date, boolean and text. | | ||
| [options.styleDefs] | [`StyleDefs`](###styledefs) | | If set you can overwrite default standard type styles by other standard ones or even define custom `formatCode`. | | ||
| [options.styleDefs] | [`StyleDefs`](#styledefs) | | If set you can overwrite default standard type styles by other standard ones or even define custom `formatCode`. | | ||
| [options.immediateInitialization] | `Boolean` | `false` | If set to true writer will initialize archive and start compressing xlsx common stuff immediately, adding subsequently a little memory and processor footprint. If not, initialization will be delayed to the first data processing. | | ||
@@ -170,3 +214,3 @@ | ||
- comments | ||
- ... and a myriad of other OOXML features. It's strictly an CSV replacement. | ||
- ... and a myriad of other OOXML features. It's strictly a CSV replacement. | ||
@@ -173,0 +217,0 @@ ## 👥 Authors |
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
82098
531
232
3
+ Addedlodash@^4.17.15