javascript - 从节点js中的服务器读取excel文件的内容
问题描述
以下是我读取 excel 文件的 api 请求 -
function getExportContents(exportId) {
return api.req(path + exportId, {
method: 'GET',
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0'
},
json: true
});
}
let exportFileContent=await this.getExportContents('5916');
console.log(exportFileContent);
输出
PK��R_rels/.rels���J1��}�0�n�D�i/E�M�>����a7����}{�遇到�af���$。 ��G�F)�l�ˮ������TGd�B���F����>fU !�D���v�1W)�N�ɣ�2�:��% ��[��3
U'g ���SKb
�;��y� �4.�~��M�[:�}��J�l���KƱ}L\V1����I(8r�X(I_ ���tsE�r��9-����$�P�:7�?��~�PK�y/�PPK��R[Content_Types].xml�SMO1��+6��m�� 1���G%@mgä~�S���MDL0�S;yo�{3i�Ӎ����6�CV�WA�h�����ef鵴�Cö�l:��� XQ�džu9�;!Pu�$��҆�d�2-D�j) �������s��#�h����~���Q2S0���@��+ ��`g"^�U�D(2q��ag�K�-'�</p>
我希望它以可读的格式来验证内容。我该如何解析这个?
解决方案
您可以使用库来解析数据。https://www.npmjs.com/package/xlsx可以帮助你。
推荐阅读
- php - 用其他列关闭然后打开的情况下 MySQL
- flutter - 应用小部件未生成路线 | 火力基地注册
- javascript - 如何在我的 ReactJS 应用程序中包含外部脚本?
- strftime - strftime 的两个不同的联机帮助页?
- python - 为循环目的组合月-年列
- javascript - 一元运算符语法错误提示“必须使用括号来消除运算符优先级的歧义”
- java - 如何将整数数组传递给java中的队列接口
- atom-editor - hunspell 接受以 s 结尾的词的所有格(s 后的尾撇号)
- vue.js - Laravel如何在Vuejs中获取嵌套对象值
- android - 为什么统一 2020.1.10 在 Oculus 的 Android 版本上冻结?