首页 > 解决方案 > 从节点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>

我希望它以可读的格式来验证内容。我该如何解析这个?

标签: javascriptnode.js

解决方案


您可以使用库来解析数据。https://www.npmjs.com/package/xlsx可以帮助你。


推荐阅读