diff --git a/src/views/Results.vue b/src/views/Results.vue index 740d198..0071a98 100644 --- a/src/views/Results.vue +++ b/src/views/Results.vue @@ -2,7 +2,7 @@ - +

Results

@@ -310,16 +310,22 @@ const downloadBlob = (data: Array, filename: string, mimeType: string) = a.download = filename a.click() window.URL.revokeObjectURL(url) + + // reset the export table button + exportas.value = null } const exportToCsv = () => { // export the table to CSV let csvRows = []; - // Add header - csvRows.push(headers.value.map(e => e.title).join(",")); + // Add header, use the original column name + csvRows.push(headers.value.map(e => e.key).join(",")); + + // get the selected rows or all rows if none selected + let rows = selected.value.length > 0 ? selected.value : data.value // Add data - selected.value.forEach(row => { + rows.forEach(row => { let rowData = headers.value.map(header => JSON.stringify(row[header.key], (_, value) => { // Custom formatting can go here return value @@ -334,8 +340,12 @@ const exportToCsv = () => { const exportToJson = () => { // export the table to JSON + + // get the selected rows or all rows if none selected + let rows = selected.value.length > 0 ? selected.value : data.value + const filename = "sdss_table_export.json" - const jsonContent = JSON.stringify(selected.value) + const jsonContent = JSON.stringify(rows, null, 2) downloadBlob(jsonContent, filename, "application/json") }