Download data from a paginated <table>

Asked

Viewed 33 times

1

I have this script that downloads data from an entire table in the format. xls, it turns out that I do an entire listing on one page and it is not usual because it has listing that goes beyond 2000 lines. I made a page table that shows 10 results at a time and wanted to independent of the current pagination when clicking the download button to download the complete list, because it only makes the current pagination.

Note: I did not find anything that treats something similar, only entire listing in the current pagination.

Thanks in advance!

<script type="text/javascript">
function salvaPlanilha() {
var htmlPlanilha = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>PlanilhaConciliador</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>' + document.getElementById("tabela").innerHTML + '</table></body></html>';

var htmlBase64 = btoa(htmlPlanilha);
var link = "data:application/vnd.ms-excel;base64," + htmlBase64;

var hyperlink = document.createElement("a");
hyperlink.download = "ArquivoConciliador";
hyperlink.href = link;
hyperlink.style.display = 'none';

document.body.appendChild(hyperlink);
hyperlink.click();
document.body.removeChild(hyperlink); } </script>
  • Novaes, could you give more details on how this pagination works? You display the spreadsheet that has data from a source, to export everything, you have to have the complete table inevitably, so you could think about contacting the data source and request the complete spreadsheet to save in the file.

  • Thanks, I’ll try that there

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.