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: 导出复制时处理特殊字符 #3093

Open
wants to merge 8 commits into
base: next
Choose a base branch
from
Open

fix: 导出复制时处理特殊字符 #3093

wants to merge 8 commits into from

Conversation

Alexzjt
Copy link
Contributor

@Alexzjt Alexzjt commented Feb 7, 2025

👀 PR includes

✨ Feature

  • New feature

🎨 Enhance

  • Code style optimization
  • Refactoring
  • Change the UI
  • Improve the performance
  • Type optimization

🐛 Bugfix

🔧 Chore

  • Test case
  • Docs / demos update
  • CI / workflow
  • Release version
  • Other ()

📝 Description

导出CSV时,若数据本身带逗号,则用Excel打开时错列

🖼️ Screenshot

Before After
image image

🔗 Related issue link

🔍 Self-Check before the merge

  • Add or update relevant docs.
  • Add or update relevant demos.
  • Add or update test case.
  • Add or update relevant TypeScript definitions.

@github-actions github-actions bot added the pr(fix) bug fix label Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

你好 @Alexzjt,非常感谢你的贡献.
为了让代码更健壮, 请根据 贡献指南 补充相应单元测试 (文档改动或其他特殊场景除外), 如果有 API 改动, 请修改 相应的文档.
同时请检查 linttest 相关 CI 是否通过, 如果失败, 请点击 [Details] 按钮查看, 并根据日志修复.

Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes.
At the same time, please check whether the CI related to lint and test passes. If the CI fails, please click [Details] button to check and repair according to the log.

@github-actions github-actions bot added the next 2.0-next 版本的问题 label Feb 7, 2025
Copy link

Walkthrough

This PR addresses issues with CSV export functionality, specifically handling special characters like commas and newline characters. The changes ensure that data containing these characters is correctly formatted for Excel, preventing column misalignment.

Changes

File Summary
packages/s2-core/__tests__/unit/utils/export/copy-spec.ts Updated test cases to reflect changes in CSV export handling, ensuring correct formatting of special characters.
packages/s2-core/__tests__/unit/utils/export/export-pivot-spec.ts Added tests for escaping CSV fields, ensuring special characters are handled correctly.
packages/s2-core/__tests__/unit/utils/export/method-spec.ts Introduced tests for the new escapeField function, verifying its behavior with various inputs.
packages/s2-core/src/utils/export/copy/base-data-cell-copy.ts Modified to use escapeField for handling special characters in data matrix.
packages/s2-core/src/utils/export/copy/common.ts Removed trimTabSeparator usage, aligning with new CSV handling logic.
packages/s2-core/src/utils/export/copy/pivot-data-cell-copy.ts Updated to remove convertString usage, aligning with new CSV handling logic.
packages/s2-core/src/utils/export/copy/table-copy.ts Updated to remove convertString usage, aligning with new CSV handling logic.
packages/s2-core/src/utils/export/method.ts Replaced convertString and trimTabSeparator with escapeField for improved CSV export handling.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 79.79%. Comparing base (ecdc9c8) to head (107c407).
Report is 614 commits behind head on next.

Files with missing lines Patch % Lines
packages/s2-core/src/utils/export/method.ts 80.00% 0 Missing and 3 partials ⚠️
...-core/src/utils/export/copy/base-data-cell-copy.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3093      +/-   ##
==========================================
+ Coverage   75.77%   79.79%   +4.02%     
==========================================
  Files         257      211      -46     
  Lines       11994    11628     -366     
  Branches     2464     2618     +154     
==========================================
+ Hits         9088     9279     +191     
+ Misses       1398      782     -616     
- Partials     1508     1567      +59     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Size Change: -50 B (-0.01%)

Total Size: 619 kB

Filename Size Change
./packages/s2-core/dist/s2-extends.min.js 154 kB -53 B (-0.03%)
./packages/s2-core/dist/s2.min.js 257 kB +3 B (0%)
ℹ️ View Unchanged
Filename Size
./packages/s2-core/dist/s2.min.css 581 B
./packages/s2-react-components/dist/s2-react-components.min.css 2.55 kB
./packages/s2-react-components/dist/s2-react-components.min.js 124 kB
./packages/s2-react/dist/s2-react.min.css 1.74 kB
./packages/s2-react/dist/s2-react.min.js 38.3 kB
./packages/s2-vue/dist/s2-vue.min.css 2.05 kB
./packages/s2-vue/dist/s2-vue.min.js 38.3 kB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next 2.0-next 版本的问题 pr(fix) bug fix
Projects
None yet
2 participants