Skip to content

col-cache.js: Unhandled rejection TypeError: Cannot read property '0' of null #140

Open
@graycrow

Description

@graycrow

My code worked fine with exceljs up to v. 0.2.4 but doesn't work with recent exceljs versions (0.2.6 and above) with following error:

Unhandled rejection TypeError: Cannot read property '0' of null
    at Object.module.exports.decodeAddress (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\utils\col-cache.js:111:36)
    at Object.module.exports.decodeEx (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\utils\col-cache.js:179:21)
    at Object.CellMatrix.addCell (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\utils\cell-matrix.js:36:29)
    at D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\doc\defined-names.js:176:16
    at Array.forEach (native)
    at Function._.each._.forEach (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\underscore\underscore.js:78:11)
    at D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\doc\defined-names.js:175:9
    at Array.forEach (native)
    at Function._.each._.forEach (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\underscore\underscore.js:78:11)
    at Object.model (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\doc\defined-names.js:173:7)
    at Object.model (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\doc\workbook.js:146:30)
    at D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\exceljs\lib\xlsx\xlsx.js:579:31
    at tryCatcher (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\bluebird\js\release\promise.js:504:31)
    at Promise._settlePromise (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\bluebird\js\release\promise.js:561:18)
    at Promise._settlePromiseCtx (D:\PROJECTS\DPHKH\src\node-dphkh\node_modules\bluebird\js\release\promise.js:598:10)

Line 111 of col-cache.js is part of decodeAddress function:

var col = value.match(/[A-Z]+/)[0];

Basically, what happens here, is that decodeEx function for some reason gets 'Some Text'!$1:$1 as a parameter, then splits it two times to get "$1" string and then sends it to the decodeAddress. In that function it gets evaluated against regexp and that search returns null because there is no uppercase letters in the "$1" string. And then it takes first item from null, which obviously throws an exception.

I hope that my explanation is clear and it will help to solve this issue.
Btw, thank you for the library, it helps a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy