From 3c134556326eb6d2f51df95251cb7446ccc5317b Mon Sep 17 00:00:00 2001 From: Alanscut Date: Thu, 2 Jan 2020 19:09:33 +0800 Subject: [PATCH 1/2] Fix problems caused by case of worksheet names --- lib/doc/workbook.js | 2 +- spec/integration/worksheet.spec.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/doc/workbook.js b/lib/doc/workbook.js index 2373a5b58..bee0e5360 100644 --- a/lib/doc/workbook.js +++ b/lib/doc/workbook.js @@ -51,7 +51,7 @@ class Workbook { console.warn(`Worksheet name ${name} exceeds 31 chars. This will be truncated`); } name = (name || `sheet${id}`).substring(0, 31); - if (this._worksheets.find(ws => ws && ws.name === name)) { + if (this._worksheets.find(ws => ws && ws.name.toLowerCase() === name.toLowerCase())) { throw new Error(`Worksheet name already exists: ${name}`); } diff --git a/spec/integration/worksheet.spec.js b/spec/integration/worksheet.spec.js index 40bf6c98f..450ca56d1 100644 --- a/spec/integration/worksheet.spec.js +++ b/spec/integration/worksheet.spec.js @@ -403,6 +403,18 @@ describe('Worksheet', () => { }); context('when worksheet name already exists', () => { + it('throws an error', () => { + const wb = new ExcelJS.Workbook(); + + const validName = 'thisisaworksheetnameiuppercase'; + const invalideName = 'THISISAWORKSHEETNAMEINUPPERCASE'; + const expectedError = `Worksheet name already exists: ${invalideName}`; + + wb.addWorksheet(validName); + + expect(() => wb.addWorksheet(invalideName)).to.throw(expectedError); + }); + it('throws an error', () => { const wb = new ExcelJS.Workbook(); From 6d0d06ad483ccfc765bc7cde3304ce2452891684 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Thu, 2 Jan 2020 19:37:35 +0800 Subject: [PATCH 2/2] Fix errors --- spec/integration/worksheet.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/worksheet.spec.js b/spec/integration/worksheet.spec.js index 450ca56d1..2e1b81225 100644 --- a/spec/integration/worksheet.spec.js +++ b/spec/integration/worksheet.spec.js @@ -406,7 +406,7 @@ describe('Worksheet', () => { it('throws an error', () => { const wb = new ExcelJS.Workbook(); - const validName = 'thisisaworksheetnameiuppercase'; + const validName = 'thisisaworksheetnameinuppercase'; const invalideName = 'THISISAWORKSHEETNAMEINUPPERCASE'; const expectedError = `Worksheet name already exists: ${invalideName}`; 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