tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.
https://www.naiveui.com
MIT License
16.24k stars 1.68k forks source link

DataTable downloadCsv result error #6409

Open andyyxw opened 1 month ago

andyyxw commented 1 month ago

Describe the bug

  1. The display is abnormal when using Chinese in Excel and the number of columns is incorrect. This should be an Excel problem. It can be solved by adding a BOM header image image image

  2. Columns with commas will be divided into multiple columns. image image image

Steps to reproduce

Based on the official Export CSV demo, only the data and column titles are modified. You can view it at the reproduction link below.

Link to minimal reproduction

https://codesandbox.io/p/sandbox/naive-ui-datatable-downloadcsv-zr9lsq?workspaceId=57d0f124-0776-4304-a229-b0c28c9a6672

System Info

System:
  OS: Windows 11 10.0.22631
  CPU: (28) x64 Intel(R) Core(TM) i7-14700K
  Memory: 28.13 GB / 63.77 GB
Binaries:
  Node: 20.17.0 - ~\AppData\Local\fnm_multishells\120800_1727579661607\node.EXE
  Yarn: 1.22.22 - ~\.npm_global\yarn.CMD
  npm: 10.8.2 - ~\AppData\Local\fnm_multishells\120800_1727579661607\npm.CMD
Browsers:
  Edge: Chromium (127.0.2651.86)
  Internet Explorer: 11.0.22621.3527

Used Package Manager

npm

Validations

andyyxw commented 1 month ago

download

https://mega.co.nz/#!qq4nATTK!oDH5tb3NOJcsSw5fRGhLC8dvFpH3zFCn6U2esyTVcJA Archive codepass: changeme

you may need to install the c compiler

@07akioni He always provides some unknown files that are identified as dangerous in the issue. What is he doing?

jahnli commented 1 month ago

我已经将问题标记为垃圾评论,https://github.com/tusen-ai/naive-ui/pull/5821 关于逗号问题需要测试下

jahnli commented 1 month ago

Sandbox not found

andyyxw commented 1 month ago

Sandbox not found

sorry, it's accessible now

ksharplee commented 1 week ago

According to what I searched, there's a tiny problem with windows csv bom header, add a certain bom header when forming the data will fix the problem: const blob = new Blob(['\uFEFF' + csvData], { type: 'text/csv;charset=utf-8' })