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.

[Q] "Invalid range in character set" error on IE11

See original GitHub issue

šŸ’¬ Questions and Help

I setup exceljs, in my React/TypeScript project, following the es5 imports section and now Iā€™m getting a ā€œInvalid range in character setā€ error in IE11. I donā€™t have any issues in Chrome or firefox.

I setup a simple codesandbox here https://codesandbox.io/s/elegant-sinoussi-m6ml0?file=/src/index.js. The code below, is what Iā€™m actually using in my app.

In my index.tsx file I have

import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import 'core-js/modules/es.promise';
import 'core-js/modules/es.object.assign';
import 'core-js/modules/es.object.keys';
import 'regenerator-runtime/runtime';
// @ts-ignore
import rewritePattern from 'regexpu-core';
// @ts-ignore
import { generateRegexpuOptions } from '@babel/helper-create-regexp-features-plugin/lib/util';
import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';
// components
import App from 'components/App';

const { RegExp } = global as any;
try {
  new RegExp('a', 'u');
} catch (err) {
  // @ts-ignore
  global.RegExp = function (pattern: any, flags: any) {
    if (flags && flags.includes('u')) {
      return new RegExp(
        rewritePattern(
          pattern,
          flags,
          generateRegexpuOptions({ flags, pattern }),
        ),
      );
    }
    return new RegExp(pattern, flags);
  };
  // @ts-ignore
  global.RegExp.prototype = RegExp;
}

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();

In the component that Iā€™m using exceljs, I have.

/** @jsx jsx */

import { jsx, css } from '@emotion/core';
// @ts-ignore
import exceljs from 'exceljs/dist/es5/exceljs.browser';
import { saveAs } from 'file-saver';

// --- components (LabelValue) ---
// --- styles (Calculate) ---
const panelContainer = css`
  padding: 20px;
`;

// --- components (CalculateResults) ---
function CalculateResults() {
  async function downloadResults() {
    const workbook = new exceljs.Workbook();
    const worksheet = workbook.addWorksheet('sheet 1');
    worksheet.addRow(['a', 'b', 'c']);

    // download the file
    const buffer = await workbook.xlsx.writeBuffer();
    const blob = new Blob([buffer]);
    if (navigator.msSaveBlob) {
      navigator.msSaveBlob(blob, 'abc.xlsx');
    } else {
      saveAs(blob, 'abc.xlsx');
    }
  }

  return (
    <div css={panelContainer}>
      <button onClick={() => downloadResults()}>Download</button>
    </div>
  );
}

export default CalculateResults;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
ahilangopalcommented, Jun 29, 2020

Yes, for IE11 youā€™ll need to teach IE about modern regex, like outlined here: https://github.com/exceljs/exceljs#es5-imports Let us know if that doesnā€™t work!

How do I, teach IE about modern regex in Angular 9 application

2reactions
ashishsharma229commented, Jul 6, 2020

Hi @alubbe, i have the same question that @ahilangopal asked. How to get support of modern regex in angular 9 applications for IE11?

Read more comments on GitHub >

github_iconTop Results From Across the Web

why I am getting "SCRIPT5021: Invalid range in character set ...
I am receiving Error: SCRIPT5021: Invalid range in character set on page load in IE11. Try to click on the line number and...
Read more >
Internet Explorer uses wrong character set for an HTML page
Describes an issue where Internet Explorer may render an HTML page using the wrong character set even though the correct charset isĀ ...
Read more >
DataGrid - The latest version of ExcelJS doesn't work in IE11
It is basically not working with latest "excelJS" version in IE11. ... ExcelJS throws an error "Invalid range in character set" in IE11....
Read more >
[Solved]-Invalid Argument in IE 11 in Vue js-Vue.js
So for me the issue was that the innerHtml of an element contained some text but was changed by none-vue code which caused...
Read more >
"SyntaxError: invalid range in character class" with javascript ...
When I try to build the corresponding Regular Expression in javascript, I get the following error : SyntaxError: invalid range in character class...
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