react 导出 excel

    科技2023-10-03  77

    HTTP({

          method: 'post',

          url: '',

          data: {

            ids: this.state.selectArr.length ? this.state.selectArr : null,

          },

          responseType: 'arraybuffer'

        }).then(res=>{

          const url = window.URL.createObjectURL(

          new Blob([res], {

            type:

              'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'

          })

        );

     

        const link = document.createElement('a');

        link.href = url;

        link.setAttribute(

          'download',

          `文件标题${moment().format('YYYY-MM-DD')}`

        );

        document.body.appendChild(link);

        link.click();

    Processed: 0.012, SQL: 8