I have some data from a REST API server and I want to export them into an excel file. I saw in another question that it can be done using react-export-excel. but when I tried it like the example code, it gives this error even though I already included the jszip dependencies (3.10.0):
Could not find module in path: 'jszip/2.4.0' relative to '/node_modules/xlsx/xlsx.js'
if I changed the jszip into the 2.4.0 version, it gives this error instead:
Could not find module in path: 'jszip' relative to '/node_modules/xlsx/xlsx.js'
here's my code (and here's the codesandbox)
import "./styles.css";
import React from "react";
import ReactExport from "react-export-excel";
const ExcelFile = ReactExport.ExcelFile;
const ExcelSheet = ReactExport.ExcelFile.ExcelSheet;
const ExcelColumn = ReactExport.ExcelFile.ExcelColumn;
const dataSet1 = [
{
name: "Johson",
amount: 30000,
sex: "M",
is_married: true
},
{
name: "Monika",
amount: 355000,
sex: "F",
is_married: false
},
{
name: "John",
amount: 250000,
sex: "M",
is_married: false
},
{
name: "Josef",
amount: 450500,
sex: "M",
is_married: true
}
];
const dataSet2 = [
{
name: "Johnson",
total: 25,
remainig: 16
},
{
name: "Josef",
total: 25,
remainig: 7
}
];
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}