Last active
February 19, 2025 09:28
-
-
Save walkermatt/a29e69c1780e75527fcad40c292e5c0d to your computer and use it in GitHub Desktop.
Copy the data out of a Confluence table as CSV using Chrome devtools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function escapeAsCsv(str) { | |
// Double up double quotes and quote the entire string if necessary | |
if (str.includes(',') || str.includes('\n') || str.includes('"')) { | |
return '"' + str.replace(/"/g, '""') + '"'; | |
} | |
return str; | |
} | |
// Export Confluence table as CSV | |
// Select the tbody element in Chrome devtools Elements panel then run the | |
// following in the Console to copy the contents of the table as CSV to the | |
// clipboard. | |
copy(jQuery('tr', $0).get().map(function (row) { | |
return jQuery('p', row).get().map(function (elm) { | |
return escapeAsCsv(elm.textContent); | |
}).join(','); | |
}).join('\n')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment