WeStandWithUkraine

27 Posts
claudioalfonso
5 days ago
0
Topic

Hello

I'm not posting a doubt, but a solution: exporting search data to csv. 1. Create custom html module 2. Insert in highlighted code 3. Publish the module on the search page in a position at the end of the search

----- code

<script>

function exportTableToCSV(filename) {

var csv = [];

var rows = document.querySelectorAll("table tr");

for (var i = 0; i < rows.length; i++) {

var row = [], cols = rows[i].querySelectorAll("td, th");

for (var j = 0; j < cols.length; j++)

row.push(cols[j].innerText);

csv.push(row.join(","));

}

// Download CSV file

downloadCSV(csv.join("\n"), filename);

}

function downloadCSV(csv, filename) {

var csvFile;

var downloadLink;

// CSV file

csvFile = new Blob([csv], {type: "text/csv"});

// Download link

downloadLink = document.createElement("a");

// File name

downloadLink.download = filename;

// Create a link to the file

downloadLink.href = window.URL.createObjectURL(csvFile);

// Hide download link

downloadLink.style.display = "none";

// Add the link to DOM

document.body.appendChild(downloadLink);

// Click download link

downloadLink.click();

}

</script>

<button onclick="exportTableToCSV('SinDab_query.csv')">Baixar planilha de resultados</button>

Get a VIP membership