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

🐛下载格式化数据内容有,逗号的会在Excel中按逗号拆分成多个单元格,但是复制格式化数据就不会出现这种情况 #2880

Open
2 tasks
1542769387 opened this issue Aug 28, 2024 · 1 comment
Labels
next 2.0-next 版本的问题

Comments

@1542769387
Copy link

🏷 Version

Package Version
@antv/s2 2.0.0-next.27
@antv/s2-react ^2.0.0-next.26

Sheet Type

  • PivotSheet
  • TableSheet

🖋 Description

下载格式化数据内容有,逗号的会在Excel中按逗号拆分成多个单元格,但是复制格式化数据就不会出现这种情况

⌨️ Code Snapshots

const s2DataConfig: S2DataConfig = {
fields: {
rows: ['province', 'city'],
columns: ['type', 'sub_type'],
values: ['number'],
},
meta: [
{
"field": "number",
"name": "数量",
formatter: (value, record, meta) => {
return Number(value).toFixed(3).toString().replace(/(\d)(?=(\d{3})+.)/g,"$1,")
// return ${value / 100} %
},
},
{
"field": "province",
"name": "省份"
},
{
"field": "city",
"name": "城市"
},
{
"field": "type",
"name": "类别"
},
{
"field": "sub_type",
"name": "子类别"
}
],
data: res.data,
};

🔗 Reproduce Link

(https://s2.antv.antgroup.com/examples/react-component/export/#export)

🤔 Steps to Reproduce

将上面的s2DataConfig替换掉链接中的s2DataConfig 点击下载格式化数据和复制格式化数据,会发现下载格式化数据内容有,逗号的会在Excel中按逗号拆分成多个单元格,但是复制格式化数据就不会出现这种情况

😊 Expected Behavior

😅 Current Behavior

💻 System information

Environment Info
System
Browser
@github-actions github-actions bot added the next 2.0-next 版本的问题 label Aug 28, 2024
@1542769387
Copy link
Author

1.X 使用S2/packages/s2-core/src/utils/export/export-worker.ts 文件中的
export function getCsvString(v: any): string {
if (!v) {
return v;
}

const value = replaceEmptyFieldValue(v);

if (typeof value === 'string') {
const out = value;
// 需要替换", https://en.wikipedia.org/wiki/Comma-separated_values#Example
return "${out.replace(/"/g, '""')}";
}

return "${value}";
}
方法进行格式化后导出的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next 2.0-next 版本的问题
Projects
None yet
Development

No branches or pull requests

5 participants
@1542769387 and others