MS Excel has problems with sheet name with leading underscore and length > 22 #992

Closed
opened 2018-02-14 12:45:00 +00:00 by samusstrike · 0 comments
samusstrike commented 2018-02-14 12:45:00 +00:00 (Migrated from github.com)

The title says it all. Here is code to reproduce the issue. The comments describe the fail/pass cases.
Node v8.9.4
xlsx: 0.12.0

//Fail: If an underscore is used as the beginning character in the sheet name and the name length > 22, then it fails.
//Pass1: If an underscore is used as the beginning character in the sheet name and the length <= 22, then it passes.
//Pass2: If an no underscore is used as the beginning character in the sheet name and the length > 22, then it passes.
//NOTE: Sheet name limit is 31 which is not in question for this issue.
//Failure means that when opening the file in MS Excel (2016), it states: "We found a problem with some content in 'fail.xlsx'. Do you want us to try to recover..."
//Repair message: Repaired Records: Worksheet properties from /xl/worksheets/sheet1.xml part
const xlsx = require("xlsx");
var sheetName_Fail = "_UnderscoreStart_moreThan22Char";
var sheetName_Pass1 = "_UndStart_less23Chars";
var sheetName_Pass2 = "noUnderscoreStart_moreTh22Char";
testCreateWorkbook(sheetName_Fail,"fail.xlsx");
testCreateWorkbook(sheetName_Pass1,"pass1.xlsx");
testCreateWorkbook(sheetName_Pass2,"pass2.xlsx");

function testCreateWorkbook(sheetName,fileName) {
    const wb = xlsx.utils.book_new();
    const data = [[]];
    const sheet = xlsx.utils.aoa_to_sheet(data);
    xlsx.utils.book_append_sheet(wb, sheet, sheetName);
    xlsx.writeFile(wb, __dirname + "/" + fileName);
}
The title says it all. Here is code to reproduce the issue. The comments describe the fail/pass cases. Node v8.9.4 xlsx: 0.12.0 ```javascript //Fail: If an underscore is used as the beginning character in the sheet name and the name length > 22, then it fails. //Pass1: If an underscore is used as the beginning character in the sheet name and the length <= 22, then it passes. //Pass2: If an no underscore is used as the beginning character in the sheet name and the length > 22, then it passes. //NOTE: Sheet name limit is 31 which is not in question for this issue. //Failure means that when opening the file in MS Excel (2016), it states: "We found a problem with some content in 'fail.xlsx'. Do you want us to try to recover..." //Repair message: Repaired Records: Worksheet properties from /xl/worksheets/sheet1.xml part const xlsx = require("xlsx"); var sheetName_Fail = "_UnderscoreStart_moreThan22Char"; var sheetName_Pass1 = "_UndStart_less23Chars"; var sheetName_Pass2 = "noUnderscoreStart_moreTh22Char"; testCreateWorkbook(sheetName_Fail,"fail.xlsx"); testCreateWorkbook(sheetName_Pass1,"pass1.xlsx"); testCreateWorkbook(sheetName_Pass2,"pass2.xlsx"); function testCreateWorkbook(sheetName,fileName) { const wb = xlsx.utils.book_new(); const data = [[]]; const sheet = xlsx.utils.aoa_to_sheet(data); xlsx.utils.book_append_sheet(wb, sheet, sheetName); xlsx.writeFile(wb, __dirname + "/" + fileName); } ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#992
No description provided.