Reputation: 83
I am using Excel Export with custom cells style from react-export-excel examples. Whenever I click on Export button in my frontend,the following error is thrown.
Uncaught TypeError: s.t.match is not a function
at write_sst_xml (xlsx.js:4334)
at write_sst (xlsx.js:8914)
at write_zip (xlsx.js:11784)
at write_zip_type (xlsx.js:11860)
at Object.writeSync [as write] (xlsx.js:11874)
at ExcelFile.download (ExcelFile.js:104)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)
at executeDispatch (react-dom.development.js:389)
at executeDispatchesInOrder (react-dom.development.js:411)
at executeDispatchesAndRelease (react-dom.development.js:3278)
at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287)
at forEachAccumulated (react-dom.development.js:3259)
at runEventsInBatch (react-dom.development.js:3304)
at runExtractedPluginEventsInBatch (react-dom.development.js:3514)
at handleTopLevel (react-dom.development.js:3558)
at batchedEventUpdates$1 (react-dom.development.js:21871)
at batchedEventUpdates (react-dom.development.js:795)
at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568)
at attemptToDispatchEvent (react-dom.development.js:4267)
at dispatchEvent (react-dom.development.js:4189)
at unstable_runWithPriority (scheduler.development.js:653)
at runWithPriority$1 (react-dom.development.js:11039)
at discreteUpdates$1 (react-dom.development.js:21887)
at discreteUpdates (react-dom.development.js:806)
at dispatchDiscreteEvent (react-dom.development.js:4168)
The code I am using is as follows:
import React, {Component} from 'react';
import ReactExport from 'react-export-excel';
import './App.css';
const ExcelFile = ReactExport.ExcelFile;
const ExcelSheet = ReactExport.ExcelFile.ExcelSheet;
const styledMultiDataSet = [
{
columns: [
{
value: "Headings",
widthPx: 160,
style: { font: { sz: "24", bold: true } },
},
{
value: "Text Style",
widthPx: 180,
style: { font: { sz: "24", bold: true } },
},
{
value: "Colors",
style: { font: { sz: "24", bold: true } }, // if no width set, default excel column width will be used ( 64px )
},
],
data: [
[
{ value: "H1", style: { font: { sz: "24", bold: true } } },
{ value: "Bold", style: { font: { bold: true } } },
{
value: "Red",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FFFF0000" } },
},
},
],
[
{ value: "H2", style: { font: { sz: "18", bold: true } } },
{ value: "underline", style: { font: { underline: true } } },
{
value: "Blue",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FF0000FF" } },
},
},
],
[
{ value: "H3", style: { font: { sz: "14", bold: true } } },
{ value: "italic", style: { font: { italic: true } } },
{
value: "Green",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FF00FF00" } },
},
},
],
[
{ value: "H4", style: { font: { sz: "12", bold: true } } },
{ value: "strike", style: { font: { strike: true } } },
{
value: "Orange",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FFF86B00" } },
},
},
],
[
{ value: "H5", style: { font: { sz: "10.5", bold: true } } },
{ value: "outline", style: { font: { outline: true } } },
{
value: "Yellow",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FFFFFF00" } },
},
},
],
[
{ value: "H6", style: { font: { sz: "7.5", bold: true } } },
{ value: "shadow", style: { font: { shadow: true } } },
{
value: "Light Blue",
style: {
fill: { patternType: "solid", fgColor: { rgb: "FFCCEEFF" } },
},
},
],
],
},
];
class App extends Component {
render() {
return (
<div>
<ExcelFile element={<button>Download Data With Styles</button>}>
<ExcelSheet dataSet={multiDataSet} name="Organization"/>
</ExcelFile>
</div>
);
}
}
P.S: Please help! I searched other answers related to this issue on github as well, but they didn't help.
Upvotes: 0
Views: 1588
Reputation: 41
Try react-data-export (https://www.npmjs.com/package/react-data-export), I faced this issue even after using react-data-export turns out my columns and rows were not matching, some of the rows had undefined data or complex js object so make sure your columns and rows are one to one mapped with only string data if there is a boolean convert it to string as well
Upvotes: 2