logo

S2

  • Manual
  • API
  • Examples
  • Playground
  • ChangeLog
  • Productsantv logo arrow
  • 2.x
  • Common Configuration
    • S2DataConfig
    • S2Options
      Updated
    • S2Theme
      Updated
    • S2Event
  • Basic Class
    • SpreadSheet
    • Interaction
      Updated
    • Store
    • BaseCell
      Updated
    • BaseDataSet
    • Node
    • BaseTooltip
    • BaseFacet
      Updated
    • Hierarchy
      New
    • BaseBBox
      New
    • CellData
      New
  • Components
    • table component
    • DrillDown
    • Switcher
    • Advanced Sort
    • Export
      Updated
  • Graphic style
  • 透视组合图拓展 S2Options

Export

Previous
Advanced Sort
Next
Graphic style

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

React export components

<SheetComponent
dataCfg={dataCfg}
options={options}
header={{ export: { open: true } }}
/>

ExportCfgProps

AttributesillustratetypeDefaultsrequired
openopen componentbooleanfalse✓
classNameclass namestring
icondisplay iconReactNode
copyOriginalTextCopy original data copystring
copyFormatTextcopy formatted data copystring
downloadOriginalTextDownload the original data copystring
downloadFormatTextDownload formatted data copystring
successTextSuccessful operation copystring
errorTextOperation failure copystring
fileNameCustomize the download file namestringsheet
asyncCopy data asynchronously (default is asynchronous)booleanfalse
drop downDropdown menu configuration, transparently passed to the Dropdown component of antdDropdownProps

original export method

Functions such as copying and exporting of the component layer are encapsulated based on a series of tools and methods exposed by the core layer @antv/s2 , which can be self-encapsulated based on tools and methods according to actual business

import { copyData, copyToClipboard, download } from '@antv/s2'
// 拿到复制数据
const data = copyData(spreadsheet, '\t', false)
// 复制数据到剪贴板
// 同步复制:copyToClipboard(data, false)
copyToClipboard(data)
.then(() => {
console.log('复制成功')
})
.catch(() => {
console.log('复制失败')
})
// 导出数据
download(data, 'filename')

copyData

parameterillustratetypeDefaultsrequired
spreadsheets2 instanceSpreadSheet✓
splitdelimiterstring✓
formatOptionsWhether to format, you can format the data cell and row header separately, and passing Boolean values will take effect on the cell and row header at the same time.boolean{ formatHeader?: boolean, formatData?: boolean}false

copyToClipboard

parameterillustratetypeDefaultsrequired
datadata sourcestring✓
asyncWhether to copy data asynchronously (default is asynchronous)booleantrue

download

parameterillustratetypeDefaultsrequired
datadata sourcestring✓
filenamefile namestring✓

Special Character Handling Rules

According to the CSV specification and Excel's handling rules, S2 will process special characters as follows:

  1. Field Wrapping Rule
    When a field contains any of the following characters, the entire field will be wrapped in double quotes:
    , " \r \n \t
  2. Double Quote Escaping Rule
    Any double quotes " within a field will be escaped as two double quotes "".
  3. Newline Handling Rule
    To be compatible with direct pasting into Excel cells:
    • Standalone \n will be replaced with \r\n
    • Existing \r\n will remain unchanged

Vue export component

In development, please look forward to