-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复在维值缺失场景下导出数据占位符未解析的问题 (#2829)
* fix: 修复在维值缺失场景下导出数据占位符未解析的问题 * test: 更新快照
- Loading branch information
1 parent
c76a510
commit 077e823
Showing
6 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/s2-core/__tests__/spreadsheet/__snapshots__/miss-dimension-values-spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Miss Dimension Values Tests should replace empty dimension value placeholder when copy formatted data 1`] = ` | ||
"\\"一级维度\\" \\"二级维度\\" \\"三级维度\\" \\"数值\\" | ||
\\"总计\\" \\"-\\" \\"-\\" \\"1732771\\" | ||
\\"维值-1\\" \\"维值-2\\" \\"维度-3\\" \\"12222\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"维值-3\\" \\"11111\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"维度-3\\" \\"11111\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"小计\\" | ||
\\"维值-1\\" \\"小计\\" \\"456\\" | ||
\\"测试-1\\" \\"测试-2\\" \\"维度-3\\" \\"4444567\\" | ||
\\"测试-1\\" \\"测试-3\\" \\"-\\" \\"785222\\" | ||
\\"测试-1\\" \\"测试-4\\" \\"维度-3\\" \\"6455644\\" | ||
\\"测试-1\\" \\"测试-5\\" \\"维度-3\\" \\"1111\\" | ||
\\"测试-1\\" \\"小计\\" \\"125555\\" | ||
\\"测试-6\\" \\"测试-x\\" \\"-\\" \\"111111\\" | ||
\\"测试-6\\" \\"测试-7\\" \\"-\\" \\"67878\\" | ||
\\"测试-6\\" \\"测试-8\\" \\"-\\" \\"456.464\\" | ||
\\"测试-6\\" \\"小计\\" \\"123.416\\"" | ||
`; | ||
|
||
exports[`Miss Dimension Values Tests should replace empty dimension value placeholder when copy original data 1`] = ` | ||
"\\"一级维度\\" \\"二级维度\\" \\"三级维度\\" \\"数值\\" | ||
\\"总计\\" \\"-\\" \\"-\\" \\"1732771\\" | ||
\\"维值-1\\" \\"维值-2\\" \\"维度-3\\" \\"12222\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"维值-3\\" \\"11111\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"维度-3\\" \\"11111\\" | ||
\\"维值-1\\" \\"维值-3\\" \\"小计\\" \\"null\\" | ||
\\"维值-1\\" \\"小计\\" \\"456\\" | ||
\\"测试-1\\" \\"测试-2\\" \\"维度-3\\" \\"4444567\\" | ||
\\"测试-1\\" \\"测试-3\\" \\"-\\" \\"785222\\" | ||
\\"测试-1\\" \\"测试-4\\" \\"维度-3\\" \\"6455644\\" | ||
\\"测试-1\\" \\"测试-5\\" \\"维度-3\\" \\"1111\\" | ||
\\"测试-1\\" \\"小计\\" \\"125555\\" | ||
\\"测试-6\\" \\"测试-x\\" \\"-\\" \\"111111\\" | ||
\\"测试-6\\" \\"测试-7\\" \\"-\\" \\"67878\\" | ||
\\"测试-6\\" \\"测试-8\\" \\"-\\" \\"456.464\\" | ||
\\"测试-6\\" \\"小计\\" \\"123.416\\"" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { replaceEmptyFieldValue } from '../../facet/utils'; | ||
|
||
export function getCsvString(v: any): string { | ||
if (!v) { | ||
return v; | ||
} | ||
|
||
if (typeof v === 'string') { | ||
const out = 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 `"${v}"`; | ||
return `"${value}"`; | ||
} |