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.

[BUG] Typescript error from getColumn.eachCell

See original GitHub issue

🐛 Bug Report

Typescript error when using Worksheet.getColumn().eachCell - TS2722: Cannot invoke an object which is possibly 'undefined'.

Lib version: 3.8.0

Steps To Reproduce

Code example

const wb = new ExcelJS.Workbook();
const ws = wb.addWorksheet('XYZ');
...
ws.getColumn(1).eachCell((cell, rowNum) => {
  cell.fill = headerFill;
});

The expected behaviour:

There should be no error.

Possible solution (optional, but very helpful):

Is it possible to clearly define the functions and properties that are available from getColumn?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
weelilladcommented, Feb 18, 2020

Sorry, there was a typo when copying the code. I checked and my code is like what you posted, and the TS error still shows. I have edited my original post to fix my code snippet.

0reactions
nywleswoeycommented, Jun 16, 2021

No problem, glad to have been of help to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

exceljs giving an error in lines for worksheet.columns = [] array ...
This is a known bug in the exceljs library when used in typescript, you can try this workaround: ... worksheet.columns = [ {...
Read more >
exceljs/README.md - UNPKG
This fixes <a href="https://github.com/exceljs/exceljs/issues/1357">[BUG] 4.1.0 causes TypeScript compilation errors - addRows styleOption should be optional? # ...
Read more >
Beginner's Guide to exceljs. Handling spreadsheet data in ...
This will throw an error when you are calling it within ... Similar to column, you can iterate over each cell of the...
Read more >
Github GitHub - exceljs/exceljs: Excel Workbook Manager
It helps me know what features are desired or what bugs are causing the most pain. ... This should fix [BUG] Typescript error...
Read more >
exceljs | Yarn - Package Manager
Fixes [BUG] Errors when opening file in Excel after saving a file with conditional ... getColumn('id'); const nameCol = worksheet. ... getColumn(4).
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