# 导入导出

- Human documentation: [https://docs.univer.ai/zh-CN/guides/boards/features/import-export](https://docs.univer.ai/zh-CN/guides/boards/features/import-export)

- Agent Markdown: [https://docs.univer.ai/zh-CN/guides/boards/features/import-export.md](https://docs.univer.ai/zh-CN/guides/boards/features/import-export.md)

- Requested language: `zh-CN`

- Content language: `zh-CN`

- Documentation version: `1.0.0-rc.0`

- Source: [boards/features/import-export.zh-CN.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/boards/features/import-export.zh-CN.mdx)

---

#### Package metadata

```json
{
  "preset": [],
  "plugins": [
    {
      "client": "@univerjs-pro/exchange-client",
      "locale": "@univerjs-pro/exchange-client/locale/zh-CN",
      "style": "@univerjs-pro/exchange-client/lib/index.css",
      "facade": "@univerjs-pro/exchange-client/facade"
    },
    {
      "client": "@univerjs-pro/boards-exchange-client",
      "locale": "@univerjs-pro/boards-exchange-client/locale/zh-CN",
      "style": "@univerjs-pro/boards-exchange-client/lib/index.css",
      "facade": "@univerjs-pro/boards-exchange-client/facade"
    }
  ],
  "license": true,
  "server": true
}
```

通过 `@univerjs-pro/boards-exchange-client`，画板可以导入 Mermaid 源码并导出 PPTX 文件。

## 支持的格式

下表列出本页前端 API 支持的格式。Office 文件转换还需要后端支持对应的文档类型和格式。

| 导入           | 导出      |
| ------------ | ------- |
| Mermaid 源码文本 | `.pptx` |

Mermaid 导入通过 `insertMermaidAsync` 将源码插入为画板元素，不是 Office 文件导入。导出 API 生成 `.pptx`，需要转换后端；它们不提供 PPTX 导入或图片、PDF 导出。宿主应用自行注册的其他导出目标属于独立能力。

## 先注册画板运行时

```ts
univer.registerPlugin(UniverBoardsPlugin)
univer.registerPlugin(UniverBoardsUIPlugin)
univer.registerPlugin(UniverBoardsExchangeClientPlugin)
```

在导入可能包含可选元素的数据之前，请先注册相应的元素插件：

```ts
univer.registerPlugin(UniverBoardsTablePlugin)
univer.registerPlugin(UniverBoardsTableUIPlugin)
univer.registerPlugin(UniverBoardsMindPlugin)
univer.registerPlugin(UniverBoardsMindUIPlugin)
```

## 快照交接

如需实现应用级持久化，请保存并恢复画板快照：

```ts
const board = univerAPI.getActiveBoard()
const snapshot = board.getData()

univer.createUnit(UniverInstanceType.UNIVER_BOARD, snapshot)
```

## Facade 导出与 Mermaid 导入

```ts
import '@univerjs-pro/exchange-client/facade'
import '@univerjs-pro/boards-exchange-client/facade'

const file = await univerAPI.exportBoardByUnitIdAsync(board.getId())
if (file) univerAPI.downloadFile(file, 'board', 'pptx')
await board.insertMermaidAsync('flowchart LR\n  A[草稿] --> B[评审]')
```
