Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xlsx-write-stream

Package Overview
Dependencies
Maintainers
6
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xlsx-write-stream - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

6

dist/templates/cell.js

@@ -7,7 +7,7 @@ 'use strict';

exports.default = function (value, cell) {
exports.default = function (value, cell, shouldFormat) {
if ((0, _lodash.isDate)(value)) {
const unixTimestamp = value.getTime();
const officeTimestamp = unixTimestamp / 86400000 + 25569;
return `<c r="${cell}" t="n"><v>${officeTimestamp}</v></c>`;
return `<c r="${cell}" t="n" s="${shouldFormat && (0, _utils.getDateFormat)()}"><v>${officeTimestamp}</v></c>`;
} else if ((0, _lodash.isString)(value)) {

@@ -18,3 +18,3 @@ return `<c r="${cell}" t="inlineStr"><is><t>${(0, _utils.sanitize)(value)}</t></is></c>`;

} else if ((0, _lodash.isNumber)(value)) {
return `<c r="${cell}" t="n"><v>${value}</v></c>`;
return `<c r="${cell}" t="n" s="${shouldFormat && (0, _utils.getNumberFormat)(value)}"><v>${value}</v></c>`;
} else if (value) {

@@ -21,0 +21,0 @@ return `<c r="${cell}" t="inlineStr"><is><t>${(0, _utils.sanitize)(`${value}`)}</t></is></c>`;

@@ -17,7 +17,4 @@ 'use strict';

/* eslint quotes: 0 */
function row(index, values) {
return `
<row r="${index + 1}" spans="1:${values.length}" x14ac:dyDescent="0.2">
${values.map((cellValue, cellIndex) => (0, _cell2.default)(cellValue, (0, _utils.getCellId)(index, cellIndex))).join("\n\t\t\t")}
</row>`;
function row(index, values, shouldFormat) {
return ` <row r="${index + 1}" spans="1:${values.length}" x14ac:dyDescent="0.2">${values.map((cellValue, cellIndex) => (0, _cell2.default)(cellValue, (0, _utils.getCellId)(index, cellIndex), shouldFormat)).join("\n\t\t\t")} </row>`;
}

@@ -13,2 +13,5 @@ "use strict";

>
<numFmts count="1">
<numFmt numFmtId="170" formatCode="yyyy-mm-dd hh:mm:ss" />
</numFmts>
<fonts count="1" x14ac:knownFonts="1">

@@ -43,5 +46,10 @@ <font>

</cellStyleXfs>
<cellXfs count="1">
<cellXfs count="7">
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="1" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="2" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="3" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="4" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="11" fontId="0" fillId="0" borderId="0" xfId="0"/>
<xf numFmtId="170" fontId="0" fillId="0" borderId="0" xfId="0"/>
</cellXfs>

@@ -48,0 +56,0 @@ <cellStyles count="1">

@@ -9,2 +9,4 @@ 'use strict';

exports.timeoutPromised = timeoutPromised;
exports.getNumberFormat = getNumberFormat;
exports.getDateFormat = getDateFormat;
const baseString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

@@ -42,2 +44,17 @@ function getCellId(rowIndex, cellIndex) {

});
}
function getNumberFormat(n) {
const number = Math.abs(n);
if (number.toString().length >= 11) {
return 5;
}
if (number % 1 === 0) {
return number >= 1000 ? 3 : 1;
}
return number >= 1000 ? 4 : 2;
}
function getDateFormat() {
return 6;
}

@@ -13,5 +13,6 @@ 'use strict';

class XLSXRowTransform extends _stream.Transform {
constructor() {
constructor(shouldFormat) {
super({ objectMode: true });
this.rowCount = 0;
this.shouldFormat = shouldFormat;
}

@@ -23,3 +24,5 @@ /**

// eslint-disable-line
const xlsxRow = (0, _templates.Row)(this.rowCount, row);
if (!Array.isArray(row)) return callback();
const xlsxRow = (0, _templates.Row)(this.rowCount, row, this.shouldFormat);
this.rowCount++;

@@ -26,0 +29,0 @@ callback(null, xlsxRow);

@@ -29,4 +29,7 @@ 'use strict';

* Create new Stream
* @param options {Object}
* @param options.shouldFormat {Boolean} - If set to true writer is formatting cells with numbers and dates
*/
constructor() {
constructor(options = {}) {
this.options = options;
this.zip = (0, _archiver2.default)('zip', {

@@ -69,3 +72,3 @@ forceUTC: true

setInputStream(stream) {
const toXlsxRow = new _XLSXRowTransform2.default();
const toXlsxRow = new _XLSXRowTransform2.default(this.options.shouldFormat);
const transformedStream = stream.pipe(toXlsxRow);

@@ -72,0 +75,0 @@ this.sheetStream = new _stream.PassThrough();

{
"name": "xlsx-write-stream",
"version": "0.0.19",
"description": "XLSX stream writer",
"main": "dist/index.js",
"keywords": [
"apify",
"apifier",
"xslx",
"stream"
],
"author": {
"name": "Apify",
"email": "support@apify.com",
"url": "https://www.apify.com"
},
"contributors": [
"Jaroslav Hejlek <jaroslav@apify.com>"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/apifytech/xlsx-stream"
},
"bugs": {
"url": "https://github.com/apifytech/xlsx-stream"
},
"homepage": "https://github.com/apifytech/xlsx-stream",
"files": [
"dist"
],
"scripts": {
"start": "npm run build && node dist/index.js",
"build": "npm run clean && babel src --out-dir dist",
"test": "npm run build && mocha --compilers js:babel-core/register --recursive",
"test-cov": "npm run build && babel-node node_modules/isparta/bin/isparta cover --report html --report text node_modules/.bin/_mocha",
"prepare": "npm run build",
"clean": "rm -rf dist",
"lint": "eslint src test",
"prepublishOnly": "(test $RUNNING_FROM_SCRIPT || (echo \"You must use publish.sh instead of 'npm publish' directly!\"; exit 1)) && npm test && npm run lint"
},
"dependencies": {
"archiver": "^2.1.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"apify-jsdoc-template": "github:apifytech/apify-jsdoc-template",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-preset-node8": "^1.2.0",
"chai": "^4.1.2",
"eslint": "^4.9.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "7.4.0",
"isparta": "^4.0.0",
"mocha": "^4.0.1",
"sinon": "^4.0.1",
"sinon-stub-promise": "^4.0.0"
}
"name": "xlsx-write-stream",
"version": "0.0.20",
"description": "XLSX stream writer",
"main": "dist/index.js",
"keywords": [
"apify",
"apifier",
"xslx",
"stream"
],
"author": {
"name": "Apify",
"email": "support@apify.com",
"url": "https://www.apify.com"
},
"contributors": [
"Jaroslav Hejlek <jaroslav@apify.com>"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/apifytech/xlsx-stream"
},
"bugs": {
"url": "https://github.com/apifytech/xlsx-stream"
},
"homepage": "https://github.com/apifytech/xlsx-stream",
"files": [
"dist"
],
"scripts": {
"start": "npm run build && node dist/index.js",
"build": "npm run clean && babel src --out-dir dist",
"test": "npm run build && mocha --compilers js:babel-core/register --recursive",
"test-cov": "npm run build && babel-node node_modules/isparta/bin/isparta cover --report html --report text node_modules/.bin/_mocha",
"prepare": "npm run build",
"clean": "rm -rf dist",
"lint": "eslint src test",
"prepublishOnly": "(test $RUNNING_FROM_SCRIPT || (echo \"You must use publish.sh instead of 'npm publish' directly!\"; exit 1)) && npm test && npm run lint"
},
"dependencies": {
"archiver": "^2.1.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"apify-jsdoc-template": "github:apifytech/apify-jsdoc-template",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-preset-node8": "^1.2.0",
"chai": "^4.1.2",
"eslint": "^4.9.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "7.4.0",
"isparta": "^4.0.0",
"mocha": "^4.0.1",
"sinon": "^4.0.1",
"sinon-stub-promise": "^4.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc