javascript - 从 BASE 64 编码重新创建 Excel 文件
问题描述
我有一个将 Excel 文件发送到服务器的客户端(React Client - with DropZone)
const onDrop = useCallback(acceptedFiles => {
// ... Some code
const reader = new FileReader();
reader.onabort = () => console.log("file reading was aborted");
reader.onerror = () => console.log("file reading has failed");
reader.onload = async () => {
// Send file the Server
const result = reader.result;
const body = {
url: result
};
await axiosInstance.post("/api/upload", body);
};
acceptedFiles.forEach(file => reader.readAsDataURL(file));
}, []);
Node JS 服务器将其接收为:
router.post("/", async (req, res) => {
// ... Some code
console.log(req.body.url);
}
req.body.url:
data:application/vnd.ms-excel;base64,0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAADA ...
如何创建与客户端相同的 Excel 文件?
解决方案
推荐阅读
- html - 调整窗口大小时在图像顶部重新定位和重新缩放可点击项目
- javascript - 当用户单击每一行时将数据附加到 json
- java - 保证流上的过滤器+迭代器
- python - 用数据库中的数据填充字段以在 django-admin 上进行验证
- flutter - 如何 BoxFit.cover 具有特定纵横比的全屏 VideoPlayer 小部件
- python - Python multiprocessing.managers.BaseManager 依次运行注册的可调用函数
- ios - 不带括号的字典中的 Swift 键值
- php - 如何编写 PHP 按钮以从数据库中选择行并运行 python 代码
- c# - Sprite 更改了特定值 - 无法弄清楚如何计算该值
- abap - 将文本和变量的组合存储在单个变量中