更新时间:2022-06-02 20:28:29
在JavaScript中以CSV文件的形式生成CSV文件的内容(我假设您并不是要求为您编写此代码),然后将其编码为Base64 并生成一个数据:URI ,其MIME类型为 text / csv
。将浏览器重定向到该URI,它应该为该用户触发一个下载对话框。
Generate the contents of the CSV file as a string in JavaScript (I assume you're not asking SO to just write this code for you), then encode it as Base64 and generate a data: URI with the MIME type text/csv
. Redirect the browser to that URI and it should trigger a download dialog for the user.