import React from 'react';
import ReactExport from 'react-data-export';
const ExcelFile = ReactExport.ExcelFile;
const ExcelSheet = ReactExport.ExcelFile.ExcelSheet;
ExcelData = [{
columns:
[
[{ title: "Header1" }],
[{ title: "Header2" }],
[{ title: "Header3" }],
[{ title: "Header4" }],
],
data:
[
[ {..}, {..}, {..}, {..} ],
[ {..}, {..}, {..}, {..} ],
[ {..}, {..}, {..}, {..} ],
[ {..}, {..}, {..}, {..} ],
],
}]
1.如果我想将另一个对象FinalData以给定格式(如对象数组)附加到数据数组,则在 Header1 下,从 Data01 到 Data04 的数据同样应该出现。我们怎样才能做到这一点?FinalData的格式为
FinalData = [
[{ value: "Data01" },
{ value: "Data02" },
{ value: "Data03" }
{ value: "Data04" }],
[{ value: "Data21" },
{ value: "Data22" },
{ value: "Data23" }
{ value: "Data24" }],
[{ value: "Data31" },
{ value: "Data32" },
{ value: "Data33" }
{ value: "Data34" }],
[{ value: "Data41" },
{ value: "Data42" },
{ value: "Data43" }
{ value: "Data44" }],
]
我想要将 FinalData 映射到 ExcelData 中的数据的函数,格式应该相同。因为我需要在 dataSet={ExcelData} 中传递相同的结构以获得预期的输出 Excel。
export default function ExcelExportTwo() {
return (
<div>
<ExcelFile element={<button>ExcelExportThree</button>}>
<ExcelSheet dataSet={ExcelData} name="Organization" />
</ExcelFile>
</div>
);
}
Excel 工作表中的预期输出应该是
隔江千里
相关分类