Empty cells don't have a style
See original GitHub issueHello everyone,
I hope this is the right place to ask this. I am not quite sure if this is a bug or this is not yet implemente or I am doing something wrong.
Well to the problem: I am trying to read the style of a cell which is empty. The workbook gets loaded via this command:
this.workbook = XLSX.readFile(path, {
cellStyles: true
});
And it also works great except that empty cells (value wise) won’t have any styles. I get it that worksheet[‘P15’].v == undefined, but why this is the case worksheet[‘P15’] == undefined.
Can you tell me if I am doing something wrong. If yes, what am I doing wrong? Or is there an alternative way to read the cell style? In my example the cell P15 has a blue background.
if(cell_ref == "P15"){
console.log(cell_ref);
console.log(this.currentWorksheet[cell_ref]);
}
The output is: P15 undefined.
Thanks in advance for any assistance.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Empty cells don't have a style · Issue #524 · SheetJS ... - GitHub
The workbook gets loaded via this command: this.workbook = XLSX.readFile(path, { cellStyles: true });. And it also works great except that empty ......
Read more >empty-cells - CSS: Cascading Style Sheets - MDN Web Docs
The empty-cells CSS property sets whether borders and backgrounds appear around <table> cells that have no visible content.
Read more >How to shade or color blank cells or nonblank cells in Excel?
With this method you can quickly color the empty cells in the worksheet. 1. Select the specified range where you will shade all...
Read more >Excel conditional formatting for blank cells - Ablebits
Tip. To highlight non-empty cells, select Format only cells that contain > No blanks. Note. The inbuilt conditional formatting for ...
Read more >How to Apply Conditional Formatting to Blank Cells | Excelchat
We can use the conditional formatting approach for “cells that do not contain any value or for blank cells”. This step by step...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If anyone else has this particular problem. I fixed it with using the xslx-style Library. Thanks to the person who gave me the hint.
https://www.npmjs.com/package/xlsx-style
@Schmitda thanks for the report! If you pass
sheetStubs:true
to readFile it should generate objects for those blank cells.@sheetjsdev
sheetStubs
does not appear to be consistent across formats. I made a simple sheet in Excel 2016 following the CSV:and bolded all 9 cells and saved in various formats. When sheetStubs is not set to true, no objects are generated. Here’s what happens when sheetStubs is set:
{ t: 's', v: undefined }
{ t: 'stub' }
undefined (no object)
undefined (no object)
undefined (no object)
recommendation: keep a separate type for stub cells, maybe call it
blank