Can´t style stubs, or get empty strings to be recognized as empty cells in excel #3263

Open
opened 2024-11-29 16:40:46 +00:00 by GabrielNM12 · 0 comments

I am utilizing xlsx-js-style fork of sheetJS in which I'm just applying simple styles of border to each cell. When I create a cell of type 's'(str) with a empty value, it works fine, but for finding the empty cells in excel with f5 -> special -> get blank, excel cannot find them. I made some researches and discovered that this happens due to excel not interpreting empty strings/strings of length 0 as a blank cells. If I use the stub type, the styles are not applied to the cell. Do someone have any idea on how to apply the styles in a blank cell?
A sample code to try and generate the problem
const vstyle = {
border: {
left: { style: 'thin', color: "000000" },
top: { style: 'thin', color: "000000" },
right: { style: 'thin', color: "000000" },
bottom: { style: 'thin', color: "000000" }
},
}

let ws = XLSX.utils.aoa_to_sheet([
[
{t: "s", v: "", s: vstyle},
{t: "z", v: "", s: vstyle}
]
]);

const wb = XLSX.utils.book_new();

XLSX.utils.book_append_sheet(wb, ws, "Report");
XLSX.writeFile(wb, report.xlsx);

Note that only the stub cell with be identified as a blank cell, but it doesnt get the border style

I am utilizing xlsx-js-style fork of sheetJS in which I'm just applying simple styles of border to each cell. When I create a cell of type 's'(str) with a empty value, it works fine, but for finding the empty cells in excel with f5 -> special -> get blank, excel cannot find them. I made some researches and discovered that this happens due to excel not interpreting empty strings/strings of length 0 as a blank cells. If I use the stub type, the styles are not applied to the cell. Do someone have any idea on how to apply the styles in a blank cell? A sample code to try and generate the problem const vstyle = { border: { left: { style: 'thin', color: "000000" }, top: { style: 'thin', color: "000000" }, right: { style: 'thin', color: "000000" }, bottom: { style: 'thin', color: "000000" } }, } let ws = XLSX.utils.aoa_to_sheet([ [ {t: "s", v: "", s: vstyle}, {t: "z", v: "", s: vstyle} ] ]); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Report"); XLSX.writeFile(wb, `report.xlsx`); Note that only the stub cell with be identified as a blank cell, but it doesnt get the border style
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#3263
No description provided.