title: How to export paginated table data in CSV?
body: <p>I have a problem exporting the paginated table in csv file. It cannot export the whole paginated table, just only export the first paginated table data.</p>
  <p>Below is my coding:</p>
  <p><code>HTML</code></p>
  <pre class="lang-html prettyprint-override"><code>&lt;button onclick=&quot;exportTableToCSV('manufacturer_brand.csv')&quot;&gt;Export&lt;/button&gt;
  &lt;table id=&quot;table_js&quot; class=&quot;table table-bordered table-striped&quot;&gt;
                      &lt;thead&gt;
                          &lt;tr&gt;
                              &lt;th style=&quot;width: 10%;&quot;&gt;Action&lt;/th&gt;
                              &lt;th style=&quot;width: 5%;&quot;&gt;No.&lt;/th&gt;
                              &lt;th style=&quot;&quot;&gt;Brand Name&lt;/th&gt;
                      &lt;/thead&gt;
                      &lt;tfoot&gt;
                          &lt;tr&gt;
                              &lt;th style=&quot;width: 10%;&quot;&gt;Action&lt;/th&gt;
                              &lt;th style=&quot;width: 5%;&quot;&gt;No.&lt;/th&gt;
                              &lt;th style=&quot;&quot;&gt;Brand Name&lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/tfoot&gt;
                  &lt;/table&gt;
  </code></pre>
  <p><code>Javascript</code></p>
  <pre class="lang-html prettyprint-override"><code>function downloadCSV(csv, filename) {
      var csvFile;
      var downloadLink;
  
      // CSV file
      csvFile = new Blob([csv], {type: &quot;text/csv&quot;});
  
      // Download link
      downloadLink = document.createElement(&quot;a&quot;);
  
      // File name
      downloadLink.download = filename;
  
      // Create a link to the file
      downloadLink.href = window.URL.createObjectURL(csvFile);
  
      // Hide download link
      downloadLink.style.display = &quot;none&quot;;
  
      // Add the link to DOM
      document.body.appendChild(downloadLink);
  
      // Click download link
      downloadLink.click();
  }
  
  
      function exportTableToCSV(filename) {
          var csv = [];
          var rows = document.querySelectorAll(&quot;table tr&quot;);
          
          for (var i = 1; i &lt; rows.length; i++) {
              var row = [], cols = rows[i].querySelectorAll(&quot;td, th&quot;);
              
              for (var j = 1; j &lt; cols.length; j++) 
                  row.push(cols[j].innerText);
              
              csv.push(row.join(&quot;,&quot;));        
          }
  
          // Download CSV file
          downloadCSV(csv.join(&quot;\n&quot;), filename);
  }
  </code></pre>
  <p>Export CSV file result like below, just can export first paginated page table, other paginate cannot export:</p>
  <p><a href="https://i.stack.imgur.com/jMft5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jMft5.png" alt="csv" /></a></p>
  <p>Below is my table, actually I have a total of 7 paginated pages in the table<a href="https://i.stack.imgur.com/UomTB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UomTB.png" alt="csv2" /></a></p>
  <p>How someone can guide me on how to export paginate table in a CSV file.</p>