为用户提供一个excel文件,以便他们可以用react js将其下载到自己的系统中



我们如何允许用户以react redux甚至vanilla javascript下载excel文件?我不想为此使用jquery。如何使用react或vanialla javascript实现同样的效果?我们应该把可下载的文件放在哪里?我只是无意中发现了这个要求,但在谷歌上我得到了需要jquery的结果。

我看到这个w3school链接,但它不支持IE。

您可以通过以下方式在reactjs中下载excel:

<a ref={(ref) => downloadRef = ref}>
<Button onClick={()=> handleExportList()}>
Export
</Button>
</a>
let downloadRef;
const handleExportList = () => {
let excelExportUrl = `http://......`;
downloadRef.href = excelExportUrl;
downloadRef.download = 'download';
}

最新更新