From be4381ac51e513bed3ee9afec7ab77c272024b18 Mon Sep 17 00:00:00 2001 From: "Kwon, Seohee | Sophie | ECDA" Date: Wed, 31 Jul 2019 10:53:47 +0900 Subject: [PATCH 1/2] Exclude Infinity on createInputStream Character such as `6E10000` becomes Infinity with `Number()` but it's not `NaN`, so just returns it. It causes error for excel file so can't open generated file. We need to check if it's Infinity or not. --- lib/csv/csv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/csv/csv.js b/lib/csv/csv.js index 645cfd701..f20a5ad23 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -68,7 +68,7 @@ CSV.prototype = { return null; } const datumNumber = Number(datum); - if (!Number.isNaN(datumNumber)) { + if (!Number.isNaN(datumNumber) && datumNumber !== Infinity) { return datumNumber; } const dt = moment(datum, dateFormats, true); From b1f924bd8da39b7a07228dbf17cefd924be8fcd2 Mon Sep 17 00:00:00 2001 From: Sophie Kwon Date: Thu, 5 Sep 2019 20:12:52 +0900 Subject: [PATCH 2/2] Adding tests --- spec/unit/xlsx/xform/sheet/cell-xform.spec.js | 86 +++++++++++++------ 1 file changed, 59 insertions(+), 27 deletions(-) diff --git a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js index 15ff180e2..0659a0a86 100644 --- a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js @@ -16,7 +16,7 @@ const fakeStyles = { getStyleModel(styleId) { switch (styleId) { case 1: - return { numFmt: 'mm-dd-yy' }; + return {numFmt: 'mm-dd-yy'}; default: return null; } @@ -33,9 +33,9 @@ const expectations = [ create() { return new CellXform(); }, - preparedModel: { address: 'A1', type: Enums.ValueType.Null, styleId: 1 }, + preparedModel: {address: 'A1', type: Enums.ValueType.Null, styleId: 1}, xml: '', - parsedModel: { address: 'A1', type: Enums.ValueType.Null, styleId: 1 }, + parsedModel: {address: 'A1', type: Enums.ValueType.Null, styleId: 1}, tests: ['render', 'renderIn', 'parse'], }, { @@ -43,8 +43,8 @@ const expectations = [ create() { return new CellXform(); }, - preparedModel: { address: 'A1', type: Enums.ValueType.Number, value: 5 }, - parsedModel: { address: 'A1', type: Enums.ValueType.Number, value: 5 }, + preparedModel: {address: 'A1', type: Enums.ValueType.Number, value: 5}, + parsedModel: {address: 'A1', type: Enums.ValueType.Number, value: 5}, xml: '5', tests: ['render', 'renderIn', 'parse'], }, @@ -58,7 +58,7 @@ const expectations = [ type: Enums.ValueType.Boolean, value: true, }, - parsedModel: { address: 'A1', type: Enums.ValueType.Boolean, value: true }, + parsedModel: {address: 'A1', type: Enums.ValueType.Boolean, value: true}, xml: '1', tests: ['render', 'renderIn', 'parse'], }, @@ -70,12 +70,12 @@ const expectations = [ preparedModel: { address: 'A1', type: Enums.ValueType.Error, - value: { error: '#N/A' }, + value: {error: '#N/A'}, }, parsedModel: { address: 'A1', type: Enums.ValueType.Error, - value: { error: '#N/A' }, + value: {error: '#N/A'}, }, xml: '#N/A', tests: ['render', 'renderIn', 'parse'], @@ -85,21 +85,53 @@ const expectations = [ create() { return new CellXform(); }, - initialModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo' }, + initialModel: {address: 'A1', type: Enums.ValueType.String, value: 'Foo'}, preparedModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo', }, xml: 'Foo', - parsedModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo' }, + parsedModel: {address: 'A1', type: Enums.ValueType.String, value: 'Foo'}, reconciledModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo', }, tests: ['prepare', 'render', 'renderIn', 'parse', 'reconcile'], - options: { hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles }, + options: {hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles}, + }, + { + title: 'String with Invalid Number', + create() { + return new CellXform(); + }, + initialModel: { + address: 'A1', + type: Enums.ValueType.String, + value: '6E1000', + }, + preparedModel: { + address: 'A1', + type: Enums.ValueType.String, + value: '6E1000', + }, + xml: '6E1000', + parsedModel: { + address: 'A1', + type: Enums.ValueType.String, + value: '6E1000', + }, + reconciledModel: { + address: 'A1', + type: Enums.ValueType.String, + value: '6E1000', + }, + tests: ['prepare', 'render', 'renderIn', 'parse', 'reconcile'], + options: { + hyperlinkMap: fakeHyperlinkMap, + styles: fakeStyles, + }, }, { title: 'Inline String with plain text', @@ -107,14 +139,14 @@ const expectations = [ return new CellXform(); }, xml: 'Foo', - parsedModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo' }, + parsedModel: {address: 'A1', type: Enums.ValueType.String, value: 'Foo'}, reconciledModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo', }, tests: ['parse', 'reconcile'], - options: { hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles }, + options: {hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles}, }, { title: 'Inline String with RichText', @@ -126,8 +158,8 @@ const expectations = [ type: Enums.ValueType.String, value: { richText: [ - { font: { color: { argb: 'FF0000' } }, text: 'red' }, - { font: { color: { argb: '00FF00' } }, text: 'green' }, + {font: {color: {argb: 'FF0000'}}, text: 'red'}, + {font: {color: {argb: '00FF00'}}, text: 'green'}, ], }, }, @@ -136,8 +168,8 @@ const expectations = [ type: Enums.ValueType.String, value: { richText: [ - { font: { color: { argb: 'FF0000' } }, text: 'red' }, - { font: { color: { argb: '00FF00' } }, text: 'green' }, + {font: {color: {argb: 'FF0000'}}, text: 'red'}, + {font: {color: {argb: '00FF00'}}, text: 'green'}, ], }, }, @@ -148,8 +180,8 @@ const expectations = [ type: Enums.ValueType.String, value: { richText: [ - { font: { color: { argb: 'FF0000' } }, text: 'red' }, - { font: { color: { argb: '00FF00' } }, text: 'green' }, + {font: {color: {argb: 'FF0000'}}, text: 'red'}, + {font: {color: {argb: '00FF00'}}, text: 'green'}, ], }, }, @@ -158,20 +190,20 @@ const expectations = [ type: Enums.ValueType.RichText, value: { richText: [ - { font: { color: { argb: 'FF0000' } }, text: 'red' }, - { font: { color: { argb: '00FF00' } }, text: 'green' }, + {font: {color: {argb: 'FF0000'}}, text: 'red'}, + {font: {color: {argb: '00FF00'}}, text: 'green'}, ], }, }, tests: ['prepare', 'render', 'renderIn', 'parse', 'reconcile'], - options: { hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles }, + options: {hyperlinkMap: fakeHyperlinkMap, styles: fakeStyles}, }, { title: 'Shared String', create() { return new CellXform(); }, - initialModel: { address: 'A1', type: Enums.ValueType.String, value: 'Foo' }, + initialModel: {address: 'A1', type: Enums.ValueType.String, value: 'Foo'}, preparedModel: { address: 'A1', type: Enums.ValueType.String, @@ -179,7 +211,7 @@ const expectations = [ ssId: 0, }, xml: '0', - parsedModel: { address: 'A1', type: Enums.ValueType.String, value: 0 }, + parsedModel: {address: 'A1', type: Enums.ValueType.String, value: 0}, reconciledModel: { address: 'A1', type: Enums.ValueType.String, @@ -219,7 +251,7 @@ const expectations = [ address: 'A1', type: Enums.ValueType.Date, value: new Date('2016-06-09T00:00:00.000Z'), - style: { numFmt: 'mm-dd-yy' }, + style: {numFmt: 'mm-dd-yy'}, }, tests: ['prepare', 'render', 'renderIn', 'parse', 'reconcile'], options: { @@ -248,7 +280,7 @@ const expectations = [ ssId: 0, }, xml: '0', - parsedModel: { address: 'H1', type: Enums.ValueType.String, value: 0 }, + parsedModel: {address: 'H1', type: Enums.ValueType.String, value: 0}, reconciledModel: { address: 'H1', type: Enums.ValueType.Hyperlink, @@ -322,7 +354,7 @@ const expectations = [ result: 7, }, tests: ['render', 'renderIn', 'parse'], - options: { formulae: {}, siFormulae: 0 }, + options: {formulae: {}, siFormulae: 0}, }, { title: 'Shared Formula', pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy