11 lines
423 B
TypeScript
11 lines
423 B
TypeScript
/** Download CSV (UTF-8 BOM) so Excel opens Chinese columns correctly. */
|
|
export function downloadExcelCsv(csv: string, filename: string) {
|
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = filename.endsWith('.csv') ? filename : `${filename}.csv`;
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
}
|