Reactでエクセルのダウンロード機能を実装
exceljsとaxios をインストールする必要がある
code:jsx
const HandleDownload = async () => {
const template_filename = '../../public/template.xlsx';
const res = await $axios.get("/template.xlsx", { responseType: "arraybuffer" });
const data = new Uint8Array(res.data);
let blob = new Blob(data, { type: "application/octet-binary" });
let link = document.createElement( "a" );
link.href = window.URL.createObjectURL( blob );
const date = new Date();
link.download = $Reactで作成したエクセルファイル_${date}.xlsx ;
link.click();
}