# 匯入匯出

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

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

- Requested language: `zh-TW`

- Content language: `zh-TW`

- Documentation version: `1.2.0`

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

---

#### Package metadata

```json
{
  "preset": [],
  "plugins": [
    {
      "client": "@univerjs-pro/exchange-client",
      "facade": "@univerjs-pro/exchange-client/facade"
    },
    {
      "client": "@univerjs-pro/boards-exchange-client",
      "locale": "@univerjs-pro/boards-exchange-client/locale/zh-TW",
      "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` |

## 先註冊 Board 執行環境

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

匯入可能包含選用元素的資料前，請先註冊對應的元素外掛程式：

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

## 快照交接

若要在應用程式層級保存資料，請儲存並還原 Board 快照：

```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[審閱]')
```

匯出 PPTX 時，請透過 [Univer Server SDK](https://docs.univer.ai/zh-TW/server/import-export.md) 整合轉換後端，並確認其支援 Board 快照。[用戶端授權](https://docs.univer.ai/zh-TW/server/license.md)需另外設定；註冊前端外掛不會自動提供轉換介面。

## 移除內建匯出選單和 UI 互動

Univer 移除了內建的匯出選單和 UI 互動，底層服務及 Facade API 繼續保留。

如果你的應用程式需要保留原有的匯出選單和 UI 互動，可以參考[內建匯出選單和 UI 互動遷移方案](https://office.univer.ai/showcase/boards/custom-import-export)，透過自訂外掛完成遷移。範例提供完整原始碼，支援線上檢視和下載。
