Skip to content

Commit dc0c756

Browse files
committedJan 20, 2025·
docs: 更新导出文档
1 parent a52c1a3 commit dc0c756

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed
 

‎s2-site/docs/common/copy-export.zh.md

+49-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,31 @@ S2 会在复制的时候往剪贴板写入两种类型的元数据
1818
粘贴的时候,取决于`接收方选择什么类型的数据`,对于富文本一般来说接收的是 `text/html`, 对于 Excel 之类的就是 `text/plain`, 即带制表符 `\t` 的纯文本,支持自定义修改。
1919
:::
2020

21-
内置是三个 API, 详见 [下方文档](#api)
21+
内置三个 API, 详见 [下方文档](#api)
2222

2323
- `asyncGetAllData`
2424
- `asyncGetAllPlainData`
2525
- `asyncGetAllHtmlData`
2626

27+
```ts {10-13}
28+
const s2DataConfig = {
29+
fields: {
30+
rows: ['province', 'city'],
31+
columns: ['type', 'sub_type'],
32+
values: ['number'],
33+
},
34+
meta: [
35+
{
36+
field: 'number',
37+
name: '数量',
38+
formatter: (value, record, meta) => {
39+
return `${value / 100} %`
40+
}
41+
},
42+
]
43+
}
44+
```
45+
2746
#### 1.1 在 `@antv/s2` 中使用
2847

2948
```ts | pure
@@ -66,11 +85,24 @@ copyToClipboard(data)
6685

6786
##### 1.2.1 原始数据全量复制
6887

69-
<img alt="originFullCopy" src="https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*pfSsTrvuJ0UAAAAAAAAAAAAAARQnAQ" width="1000" />
88+
<img alt="originFullCopy" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*lh52Q69eTSwAAAAAAAAAAAAAemJ7AQ/original" width="1000" />
89+
90+
对应 `@antv/s2` 工具方法:
91+
92+
```ts {4-7}
93+
const data = await asyncGetAllData({
94+
sheetInstance: s2,
95+
split: '\t',
96+
formatOptions: {
97+
formatHeader: false,
98+
formatData: false
99+
},
100+
});
101+
```
70102

71103
##### 1.2.2 格式化数据全量复制
72104

73-
如果配置了 [`S2DataConfig.meta`](/api/general/s2-data-config#meta) 对数据有 [格式化处理](/manual/basic/formatter), 那么可以开启 `withFormat`, 这样复制时会拿到格式化之后的数据。
105+
如果配置了 [`S2DataConfig.meta`](/api/general/s2-data-config#meta) 对数据有 [格式化处理](/manual/basic/formatter), `s2DataConfig.meta` 中的 `name``formatter`那么可以开启 `withFormat`, 这样复制时会拿到格式化之后的数据。
74106

75107
```ts
76108
const s2Options = {
@@ -87,7 +119,20 @@ const s2Options = {
87119
}
88120
```
89121

90-
<img alt="formatFullCopy" src="https://gw.alipayobjects.com/mdn/rms_56cbb2/afts/img/A*mLSdTrAWZrwAAAAAAAAAAAAAARQnAQ" width="1000" />
122+
<img alt="formatFullCopy" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*AGkpQLhWo0AAAAAAAAAAAAAAemJ7AQ/original" width="1000" />
123+
124+
对应 `@antv/s2` 工具方法:
125+
126+
```ts {4-7}
127+
const data = await asyncGetAllData({
128+
sheetInstance: s2,
129+
split: '\t',
130+
formatOptions: {
131+
formatHeader: true,
132+
formatData: true
133+
},
134+
});
135+
```
91136

92137
### 2. 局部复制
93138

0 commit comments

Comments
 (0)
Please sign in to comment.