Skip to content

[BUG] Cannot read properties of undefined reading getColumn #2190

Closed
@Mathiaszero

Description

@Mathiaszero

🐛 Bug Report

An error occurred after I was trying to get a column of data that I had stored manually on the first column of the worksheet, and was planning to push each row to an array until the very last low with data before whitespace.

Error log:

const col = worksheet.getColumn(1);
                          ^

TypeError: Cannot read properties of undefined (reading 'getColumn')
    at Object.<anonymous>[at const col...]
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47

Lib version: 4.3.0

Steps To Reproduce

const ExcelJS = require('exceljs');

const workbook = new ExcelJS.Workbook();
workbook.xlsx.readFile('data.xlsx');
const worksheet = workbook.getWorksheet(1);
const col = worksheet.getColumn(1);

The expected behaviour:

There should be no error and script continues as normal. I did not log anything yet so cannot visually verify the data was gotten.

Possible solution (optional, but very helpful):

Tried referencing by 'A', but got same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions