question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] exceljs throws an error "Invalid range in character set" in IE11 due to the lib "xmlchars"

See original GitHub issue

🐛 Bug Report

Lib version: 3.8.2

Steps To Reproduce

  1. In IE11
require('regenerator/runtime');
const Excel = require('exceljs/dist/es5/exceljs.bare');
  1. Open the page that uses exceljs in IE11

The expected behaviour:

exceljs should work fine in IE11

Possible solution (optional, but very helpful):

The root cause is that exceljs uses saxes that uses xmlchars. And xmlchars uses regular expressions with the unicode flag (“u”) that cannot work in IE (so an error “Invalid range in character set” is thrown)

new RegExp(“^[”+t.NAME_START_CHAR+“]$”,“u”)


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
alubbecommented, Apr 1, 2020

Thanks for reporting this. As per https://github.com/exceljs/exceljs/pull/1193, you’ll need to polyfill unicode support in IE11, for example like this (before requiring exceljs):

const rewritePattern = require('regexpu-core');
const {generateRegexpuOptions} = require('@babel/helper-create-regexp-features-plugin/lib/util');

const {RegExp} = global;
try {
  new RegExp('a', 'u');
} catch (err) {
  global.RegExp = function(pattern, flags) {
    if (flags && flags.includes('u')) {
      return new RegExp(rewritePattern(pattern, flags, generateRegexpuOptions({flags, pattern})));
    }
    return new RegExp(pattern, flags);
  };
  global.RegExp.prototype = RegExp;
}
0reactions
alubbecommented, Apr 1, 2020

The above fixed the issue on my windows laptop running IE11

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why ExcelJs plugin is not working in IE11? - Stack Overflow
I am using Angular 9 and excelJs 4.1.1, this is working fine in chrome but only in IE11 giving Error: Invalid range in...
Read more >
DataGrid - The latest version of ExcelJS doesn't work in IE11
Hi Team, I imported latest version of ExcelJS in my JS file. ... ExcelJS throws an error "Invalid range in character set" in...
Read more >
Lintian Hints for People - Debian
We have the following e-mail addresses on file: pkg-javascript-devel@alioth-lists.debian.net; pkg-javascript-devel@lists.alioth.debian.org.
Read more >
invalid range in character class at offset [Solved] - YouTube
Error : Compilation failed: invalid range in character class at offset [Solved].
Read more >
"invalid range in character class": JavaScript Error Solved
Therein lies the problem. If you want a regular expression to test for the presence of a dash/minus sign as a dash/minus sign,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found