Export to CSV
Download table data as CSV file
Preview
| Name | Role | |
|---|---|---|
| John Doe | [email protected] | Admin |
| Jane Smith | [email protected] | User |
{ window.Prism.highlightElement($refs.codeEl) }) }"
class="w-full flex items-center justify-between px-6 py-4 text-left bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer">
View Code
<button @click="
const data = [['Name', 'Email', 'Role'], ['John Doe', '[email protected]', 'Admin']];
const csv = data.map(row => row.join(',')).join('\n');
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'export.csv';
a.click();
" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700">
Export to CSV
</button>