欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

原生js 导出excel

程序员文章站 2024-03-20 17:14:58
...
 var timestamp = new Date().getTime();
      var xmlResquest = new XMLHttpRequest();
      xmlResquest.open('POST', _this.hnss + `/sheshui/yjjc/exportCompanyList?pageNum=${_this.page}&pageSize=${_this.pageSize}`);
      xmlResquest.setRequestHeader('Content-type', 'application/json');
      xmlResquest.responseType = 'blob';
      xmlResquest.onload = function (oEvent) {
        var content = xmlResquest.response;
        var elink = document.createElement('a');
        elink.download = '企业详情导出模板' + timestamp + '.xlsx';
        elink.style.display = 'none';
        var blob = new Blob([content]);
        elink.href = URL.createObjectURL(blob);
        document.body.appendChild(elink);
        elink.click();
        document.body.removeChild(elink);
      };
      xmlResquest.send();
``
相关标签: js