Skip to content

Instantly share code, notes, and snippets.

@robertStrunk
Last active May 8, 2025 13:56
Show Gist options
  • Select an option

  • Save robertStrunk/1053b45a2fe9460d73b6e108120e8119 to your computer and use it in GitHub Desktop.

Select an option

Save robertStrunk/1053b45a2fe9460d73b6e108120e8119 to your computer and use it in GitHub Desktop.
dload from chatgpt
downloadCsv(lines, filename = 'export.csv') {
if (!lines || !lines.length) {
console.error('No data to export');
return;
}
const csvContent = lines.join('\n');
// Use a safe MIME type
const blob = new Blob([csvContent], { type: 'text/plain;charset=utf-8' });
// Create a download link
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.setAttribute('download', filename);
// Append, trigger download, and clean up
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(link.href);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment