Export to CSV Component - LaraCoreKit

Export data to CSV component using JavaScript. Table data download for Laravel applications.

Export to CSV

Download table data as CSV file

Preview

Name Email Role
John Doe[email protected]Admin
Jane Smith[email protected]User
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>