About the problem of exporting table data of vue+element to excel.

problem description

now I need to export the displayed table data to excel, but I have encountered a problem. I have a total of 11 pieces of data, paged, showing 10 pieces of data per page, but there are only 10 pieces of data after exporting to excel, and the data has not been exported, and why it has been repeated three times. I don"t know why. Please take a look at what the problem is.

the environmental background of the problems and what methods you have tried

I found a way on the Internet to enlarge the number of data bars per page before export, then export them, and then change the number of data bars per page back, but it didn"t work. Attach a link to this method https://blog.csdn.net/oStormy.. I don"t know how you solved it

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
first click on the event
< el-button type= "primary" @ click= "fileSaver ()" > {{$t ("public.fileSaver")}} < / el-button >

here is the method
/ to export table data as excel /

      fileSaver(){
          this.$nextTick(function () {
              let wb = XLSX.utils.table_to_book(document.querySelector(".tb-edit"));
              let wbout = XLSX.write(wb, { bookType: "xlsx", bookSST: true, type: "array" });
              try {
                FileSaver.saveAs(new Blob([wbout], { type: "application/octet-stream" }), ".xlsx")
              } catch (e) {
                if (typeof console !== "undefined") console.log(e, wbout)
              }
              return wbout;
          });
      },

then attach a screenshot of the question:
first table data (a total of 11 pieces of data, and one page):

clipboard.png

excel:

clipboard.png

Please take a look at it

Dec.21,2021

isn't this exported according to your wishes? your plug-in is looking for table data rendered on the page, which has only 10 items, and there is another item, which is not on the page at all.


just export the data of all the data-bound tables, as I did before.

clipboard.png


exceljsonexcel



clipboard.png


see if el-table has a fixed column, that is, whether the property of fixed is set.
https://blog.csdn.net/WYA1993.

Menu