导出csv

export const exportCsv = (title: string, data: any[]) => {
const dataValue = data.map(val => ${Array.isArray(val) ? val.map((valItem: string) => String(valItem)).join(',') : val}\n);
const blob = new Blob([\uFEFF${dataValue.join('')}], { type: 'text/csv;charset=gb2312;' });
const a = document.createElement('a');
a.download = ${title}.csv;// 这里替换为你需要的文件名
a.href = URL.createObjectURL(blob);
a.click();
};

你可能感兴趣的:(导出csv)