[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:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How do I, teach IE about modern regex in Angular 9 application
Hi @alubbe, i have the same question that @ahilangopal asked. How to get support of modern regex in angular 9 applications for IE11?