Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(n-data-table): chinese garbled characters when exporting CSV #5821

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fix `useModal` setting `card` preset without corresponding props in `n-card` slots, closes [#5746](https://github.com/tusen-ai/naive-ui/issues/5746).
- Fix `Submenu` component's wai-aria role setting error of `n-menu`,closes [#5729](https://github.com/tusen-ai/naive-ui/issues/5729).
- Fix the `common` type error in the `theme-overrides` prop when modifying components' themes.
- Fix `n-data-table` Chinese garbled characters when exporting `CSV`, closes [#5819](closes https://github.com/tusen-ai/naive-ui/issues/5819)

### Features

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- 修复 `n-dialog` / `n-modal` 调用 `destroy` 方法时可能会报错
- 修复 `useModal` 设置 `card` 预设时 `n-card` 插槽缺少相应属性,关闭 [#5746](https://github.com/tusen-ai/naive-ui/issues/5746)
- 修复组件调整主题时 `theme-overrides` 属性中的 `common` 类型报错
- 修复 `n-data-table` 导出 `CSV` 时中文乱码问题,关闭 [#5819](https://github.com/tusen-ai/naive-ui/issues/5819)

### Features

Expand Down
2 changes: 1 addition & 1 deletion src/data-table/src/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
const downloadCsv = (options?: CsvOptionsType): void => {
const { fileName = 'data.csv', keepOriginalData = false } = options || {}
const data = keepOriginalData ? props.data : rawPaginatedDataRef.value
const csvData = generateCsv(props.columns, data)
const csvData = '\uFEFF' + generateCsv(props.columns, data)
const blob = new Blob([csvData], { type: 'text/csv;charset=utf-8' })
const downloadUrl = URL.createObjectURL(blob)
download(
Expand Down
Loading