🐛下载格式化数据内容有,逗号的会在Excel中按逗号拆分成多个单元格,但是复制格式化数据就不会出现这种情况
🏷 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 |
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}";
}
方法进行格式化后导出的
:tada: This issue has been resolved in version @antv/s2-v2.1.11 :tada:
The release is available on:
Your semantic-release bot :package::rocket: