question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty cells don't have a style

See original GitHub issue

Hello 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:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Schmitdacommented, Feb 1, 2017

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

1reaction
reviewhercommented, Jan 6, 2017

@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:

1,2,3
4,,6
7,8,9

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:

format Sheets.Sheet1.B2 with sheetStubs:true
xlsb { t: 's', v: undefined }
xlsx { t: 'stub' }
xls undefined (no object)
xml undefined (no object)
xls5.0 undefined (no object)

recommendation: keep a separate type for stub cells, maybe call it blank

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found