Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

TypeError: Cannot read property 'match' of null #218

Closed
aavanzyl opened this issue Aug 13, 2018 · 3 comments
Closed

TypeError: Cannot read property 'match' of null #218

aavanzyl opened this issue Aug 13, 2018 · 3 comments
Labels
Milestone

Comments

@aavanzyl
Copy link

When adding a null value to a cell, you get an TypeError: Cannot read property 'match' of null error.

Example

var xl = require('excel4node');

//Create Workbook
var wb= new xl.Workbook();
let sheet1= wb.addWorksheet('Test');
sheet1.cell(1,1).string('Test');

//set empty cell
sheet1.cell(2, 1).string(null);

I expected the lib to handle null values or give a more descriptive error when they happen.

@natergj
Copy link
Owner

natergj commented Aug 15, 2018

I'm going to mark this as a bug. I think the best solution for this one would be to forcibly coerce any value sent to cell.string() to a string. This would print out the word "null" in the cell when the method is passed a null value. This would also would put strings like "undefined" and "[object Object]".

@natergj natergj added the bug label Aug 15, 2018
@natergj natergj added this to the 1.5.1 milestone Sep 9, 2018
@natergj
Copy link
Owner

natergj commented Sep 9, 2018

it turns out I had already had code to handle non-string values being passed to the string method but a bug was preventing that code from being applied. That is resolved in version 1.5.1. non-string values will be replaced with empty strings and a warning will be logged to the console if the workbook was initialized with a log level above warn.

@natergj natergj closed this as completed Sep 9, 2018
@aavanzyl
Copy link
Author

Awesome man, great that you where able to find and fix it, This will help alot. Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants