From 7461389d49029afb8ba4ad5fcc671958e5253f70 Mon Sep 17 00:00:00 2001 From: godu Date: Thu, 13 Aug 2015 16:30:09 +0200 Subject: [PATCH 1/3] Adds cheerio dependencie for tests/test-style.js --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b1053b0..d62c944 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "commander":"" }, "devDependencies": { + "cheerio":"^0.19.0", "mocha":"", "xlsjs":"", "uglify-js":"" From 905c51206bc107ffc981e07514f39850e71ed76f Mon Sep 17 00:00:00 2001 From: godu Date: Thu, 13 Aug 2015 16:43:29 +0200 Subject: [PATCH 2/3] Adds tests --- tests/test-style.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test-style.js b/tests/test-style.js index bb62103..bc7a4a2 100644 --- a/tests/test-style.js +++ b/tests/test-style.js @@ -690,5 +690,26 @@ describe("Export styles", function () { assert(basicallyEquals(workbook.Sheets.Main,wb2.Sheets.Main)); }); + it('should edit style of one cell without applie modification on other cell', function () { + var wb2 = XLSX.read(XLSX.write(workbook, {type:"buffer", bookType: 'xlsx'}), {cellStyles: true, cellNF: true}) + + var A6s = wb2.Sheets.Main.A6.s; + var B6s = wb2.Sheets.Main.B6.s; + + Object.keys(A6s).forEach(function(key) { + if(A6s[key]) + assert(A6s[key] !== B6s[key]); + }); + + assert(A6s.border.top === undefined); + assert(B6s.border.top === undefined); + + A6s.border.top = {}; + assert(B6s.border.top === undefined); + + XLSX.writeFile(wb2, '/tmp/wb2.xlsx', { defaultCellStyle: defaultCellStyle }); + assert(basicallyEquals(workbook.Sheets.Main,wb2.Sheets.Main)); + }); + }); From 599f285dfdb2172027d42be84fd8d2db882d0fa1 Mon Sep 17 00:00:00 2001 From: godu Date: Thu, 13 Aug 2015 16:46:31 +0200 Subject: [PATCH 3/3] Breaks ref in style object --- bits/66_wscommon.js | 2 +- xlsx.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bits/66_wscommon.js b/bits/66_wscommon.js index 980297f..d58e7ab 100644 --- a/bits/66_wscommon.js +++ b/bits/66_wscommon.js @@ -56,7 +56,7 @@ function get_cell_style_csf(cellXf) { } - return s; + return JSON.parse(JSON.stringify(s)); } return null; } diff --git a/xlsx.js b/xlsx.js index b44fe15..11b83fe 100644 --- a/xlsx.js +++ b/xlsx.js @@ -7497,7 +7497,7 @@ function get_cell_style_csf(cellXf) { } - return s; + return JSON.parse(JSON.stringify(s)); } return null; }