Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid time value Exception #488

Closed
ilijaz opened this issue Feb 2, 2018 · 8 comments
Closed

Invalid time value Exception #488

ilijaz opened this issue Feb 2, 2018 · 8 comments

Comments

@ilijaz
Copy link
Contributor

ilijaz commented Feb 2, 2018

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.

@navidshad
Copy link

I had the same problem, this error will happen when you use datejs in exceljs options.

@optimistex
Copy link

How to fix it? Anybody knows?

It is a file that makes the bug:
xlsx.helper.template.xlsx

@dljenkins
Copy link
Contributor

I had the exact same problem and used @ilijaz suggestion to patch it. When will this be officially patched?

@optimistex
Copy link

My current solution is to make a template through the google documents.

dljenkins added a commit to dljenkins/exceljs that referenced this issue May 24, 2018
Fix Issue exceljs#488 where dt is an invalid time format, catch the exception and return blank string.
@dljenkins dljenkins mentioned this issue May 24, 2018
@guyonroche
Copy link
Collaborator

@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

ilijaz added a commit to ilijaz/exceljs that referenced this issue Jun 11, 2018
…alue and return blank string. Add unit test.
@ilijaz
Copy link
Contributor Author

ilijaz commented Jun 11, 2018

@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?

guyonroche added a commit that referenced this issue Jun 12, 2018
@guyonroche
Copy link
Collaborator

@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.

@guyonroche
Copy link
Collaborator

Published fix in v1.4.13

guyonroche added a commit that referenced this issue Sep 4, 2018
Fix Issue #488 where dt is an invalid date format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants