Invalid time value Exception
ilijaz opened this issue · 8 comments
I got the exception when i opened this https://yadi.sk/d/9RC1JcPY3S2kHa xlsx document template
null: RangeError: Invalid time value
message: "Invalid time value"
stack: "RangeError: Invalid time value
at Date.toISOString (<anonymous>)
at module.exports._format (/var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xform/simple/date-xform.js:17:21)
at module.exports.render (/var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xform/simple/date-xform.js:36:34)
at module.exports.render (/var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xform/core/core-xform.js:64:29)
at module.exports.toXml (/var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xform/base-xform.js:94:10)
at /var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xlsx.js:441:28
at new Promise (<anonymous>)
at new Promish (/var/www/wialon/agri/node_modules/promish/lib/promish-class.js:23:9)
at module.exports.addCore (/var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xlsx.js:439:12)
at /var/www/wialon/agri/node_modules/exceljs/dist/es5/xlsx/xlsx.js:608:55
at <anonymous>"
__proto__: Error {constructor: , name: "RangeError", message: "", …}
I did this dirty hack and now everything works fine
this._format = options.format || function (dt) {
try { return dt.toISOString(); }
catch(e) { console.log(e); return '' }
};
I don't know why it's happening because i'm newbee in js and don't have enough time to understand exceljs lib at all.
I had the same problem, this error will happen when you use datejs in exceljs options.
How to fix it? Anybody knows?
It is a file that makes the bug:
xlsx.helper.template.xlsx
I had the exact same problem and used @ilijaz suggestion to patch it. When will this be officially patched?
My current solution is to make a template through the google documents.
@ilijaz I know it's been a while, but do you remember what the original date/time value was that caused the exception? I'm reviewing a PR that will fix this (thanks to @dljenkins ) and would like to include a unit test that covers this
@guyonroche I've got some skills for that time. I've added a unit test and another PR without catching the exception.
In my case, it happens when exceljs parses 'cp:revision' option when it gets this model but source file has an integer value.
{tag: "cp:revision", attr: undefined, attrs: undefined, _format: , _parse: }
<cp:revision>45</cp:revision>
Where does it decide what type each option should have?
@ilijaz that explains it - cp:revision should be a number, not a date. I've merged the above mentioned PR and amended the cp:revision property. Will publish soon.
Published fix in v1.4.13