---
schema_version: "1"
id: fb24fea734dd2565c93b0aaafc83214015aea0afea5040b638fb9a75c858973c
title: Tableau 資料擷取命令列公用程式
collection: tableau
version: current
locale: zh-tw
portal_url: https://docs.salesforce.com/tableau/current/zh-tw/pro/desktop/extracting_TDE.md
canonical_url: https://help.tableau.com/current/pro/desktop/zh-tw/extracting_TDE.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 9938188c4b84021eaa2bec375db32a8f9fbcbe0d263e8fd2187b60c0fa646357
description: Automate extract refresh tasks using the Tableau Data Extract Command-Line Utility.
---
[跳至主要內容](#main-content)

# Tableau 資料擷取命令列公用程式

您可以使用 Tableau 資料擷取命令列公用程式自動執行擷取重新整理工作。這是 Tableau Desktop 隨附的一種命令列公用程式，您可以透過其重新整理發佈的擷取資料來源，或將資料從檔案附加到資料來源。

若要使用 Tableau 資料擷取命令列公用程式，需滿足以下要求：

- 它適用於 Windows 版 Tableau Desktop，並且只能在 Windows 系統上執行。
- 它不適用於試用版的 Tableau Desktop。
- 您可以為不使用 Oauth 的擷取資料來源使用它。
- 您只能使用它來重新整理單連線資料來源。它不適用於多連線資料來源。

**2022 年 10 月已棄用：**由於 Tableau Cloud 中要求使用[多重要素驗證](https://help.tableau.com/current/online/zh-tw/to_security_mfa.htm)，此公用程式在後續版本中不可用。若要重新整理 Tableau Cloud 無法直接存取的資料來源或虛擬連線，請改用 Tableau Bridge。有關詳情，請參閱[設定 Bridge 重新整理排程方式](https://help.tableau.com/current/online/zh-tw/to_sync_schedule.htm)。  
  
要使用指令碼啟動重新整理作業，請使用 tabcmd [refreshextracts](https://help.tableau.com/current/server/zh-tw/tabcmd_cmd.htm#refreshextracts-workbookname-or-datasourcename) 或 REST API [執行擷取重新整理工作](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref.htm#run_extract_refresh_task)。

## 執行公用程式

1. 以管理員身分開啟命令提示字元，並切換到 Tableau Desktop 資料桶目錄。例如：
    
    `cd C:\Program Files\Tableau\Tableau 2022.4\bin`
2. 使用下列命令之一，並新增下表中描述的參數。
    
    - `tableau refreshextract`
    - `tableau addfiletoextract`

**附註：**使用此公用程式時，始終要在命令列上或指令碼中指定 `tableau`，決不要指定 `tableau.exe`。

**備註**：若要疑難排解，請查看 \\我的 Tableau 存放庫\\Logs 資料夾中 tableaucom.txt 檔案的記錄。

**附註：** 在多網站環境中，請指定命令將套用的網站。

## tableau refreshextract 命令的語法和參數

使用 `tableau refreshextract` 可重新整理 Tableau Server 或 Tableau Cloud 上的擷取。重新整理擷取將會使用自上次重新整理後對資料來源所做的任何修改更新現有擷取。

要檢視此命令的說明，請在 Windows 命令提示字元處鍵入以下命令：

`tableau help refreshextract`

### 使用參數

- 所有選項都有一個與雙連字號結合使用的完整形式（例如，`--server`）。
- 有些選項還有一個與單連字號結合使用的短形式（例如，`-s`）。
- 如果選項的值包含空格，則用引號將選項值引起來。
- 要重新整理的來源必須是原始資料來源，而不是一個擷取（`.hyper`）。

### tableau refreshextract 命令選項

<table><colgroup><col style="width: 25%;"><col style="width: 30%;"><col style="width: 45%;"></colgroup><tbody><tr><td><b>短形式</b></td><td><b>完整形式</b></td><td><b>描述</b></td></tr><tr><td>&nbsp;</td><td><code>--source-username &lt;user name&gt;</code></td><td><p>資料來源連線的有效使用者名。</p><p>將此選項與 <code>--source-password</code> 結合使用，或使用</p><p><code>--original-file</code>，而不是使用者名和密碼選項。</p><p class="note"><b>附註：</b>在重新整理發佈的擷取時必須提供使用者和密碼，即使最初是利用嵌入式認證發佈資料來源的。</p></td></tr><tr><td>&nbsp;</td><td><code>--source-password "&lt;password&gt;"</code></td><td><p>資料來源使用者的密碼。</p></td></tr><tr><td>&nbsp;</td><td><p><code>--original-file &lt;path and file name&gt;</code></p><p>或</p><p><code>--original-file&nbsp;&lt;path and folder name&gt;</code></p></td><td><p>將在伺服器上進行重新整理的資料來源的路徑和檔案名。例如：<code>--original-file c:\folder\file.csv</code></p><p>若要重新整理多檔資料來源，請將路徑傳遞到包含資料檔案的資料夾。例如：<code>--original-file c:\folder</code>。</p><p>如果檔案位於網路共用上，請為路徑使用 UNC 格式：<code>\\server\path\filename.csv</code></p></td></tr><tr><td>&nbsp;</td><td><code>--force-full-refresh</code></td><td><p>如果資料來源設定為進行累加式重新整理，請使用此選項強制對擷取進行完整重新整理。如果不包括此選項，則執行累加式重新整理。並非所有資料來源都支援累加式重新整理。</p></td></tr><tr><td><code>-s &lt;server http address&gt;</code></td><td><code>--server  &lt;URL&gt;</code></td><td><p>在其中發佈資料的 Tableau Server 的 URL。</p><p>對於 Tableau Cloud，請指定 <code>https://online.tableau.com</code>。</p></td></tr><tr><td><code>-t &lt;site id&gt;</code></td><td><code>--site &lt;siteid&gt;</code></td><td><p>在多網站環境中，指定命令將套用於的網站。對於 Tableau Cloud，如果您的使用者名與一個以上的網站關聯，請使用此參數。對於 Tableau Server，如果未指定網站，則使用預設網站。</p><p>網站 ID 獨立於網站名稱，當您在瀏覽器中檢視網站時，它會顯示在 URL 中。例如，如果您登入到 Tableau Cloud 後看到的頁面的 URL 是</p><pre xml:space="preserve">https://online.tableau.com/t/vernazza/views</pre><p>網站 ID 是 <i>vernazza</i>。</p></td></tr><tr><td>&nbsp;</td><td><code>--datasource &lt;datasource&gt;</code></td><td><p>發佈到 Tableau Server 或 Tableau Cloud 的資料來源的名稱。</p></td></tr><tr><td>&nbsp;</td><td><code>--project &lt;projectname&gt;</code></td><td><p>資料來源所屬的專案。如果不包括此選項，則假定為預設專案。</p><p>如果要指定的專案是內嵌在專案階層內的子專案，則必須隨 <code>--parent-project-path</code> 參數一起使用此參數。</p></td></tr><tr><td>&nbsp;</td><td><code>--parent-project-path path/to/project</code></td><td><p>如果將資料來源發佈到的專案沒有位於專案階層的頂層，請隨 <code>--project</code> 參數一起使用此參數以指定巢狀專案的路徑。</p><p>使用正斜線字元&nbsp;(<code>/</code>) 來分隔階層中的專案層級。使用反斜線 (<code>\</code>) 對專案名稱中的正斜線或反斜線字元進行轉義。</p><p>例如，對於頂層「Marketing」下的專案「Social」中名為 Sandbox 的專案：</p><p><code>--project Sandbox --parent-project-path Marketing/Social</code></p></td></tr><tr><td><code>-u &lt;user name&gt;</code></td><td><code>--username &lt;username&gt;</code></td><td><p>有效的 Tableau Server 或 Tableau Cloud 使用者。</p></td></tr><tr><td><code>-p "&lt;password&gt;"</code></td><td><code>--password  "&lt;password&gt;"</code></td><td><p>指定的 Tableau Server 或 Tableau Cloud 使用者的密碼。</p></td></tr><tr><td>&nbsp;</td><td><code>--proxy-username &lt;username&gt;</code></td><td><p>代理伺服器的使用者名。</p></td></tr><tr><td>&nbsp;</td><td><code>--proxy-password "&lt;password&gt;"</code></td><td><p>代理伺服器的密碼。</p></td></tr><tr><td><code>-c "&lt;path and file name&gt;"</code></td><td><code>--config-file  "&lt;path and file name&gt;"</code></td><td><p>包含命令設定選項的檔案的路徑和檔案名資訊。始終將路徑括在雙引號內。有關詳情，請參閱下面的<a href="#Using" class="xref">使用組態檔</a>。</p></td></tr></tbody></table>

### tableau refreshextract 範例命令

以下命令可重新整理已發佈到本地 Tableau Server、名為 CurrentYrOverYrStats 的擷取。此命令指定以下內容：

- Tableau Server 的名稱。
- 伺服器的使用者名和密碼。
- 專案名稱。
- 要重新整理的資料來源的名稱，以及資料來源使用者名和密碼。

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --server https://our_server_name --username OurServerSignIn --password "OurServerPwd" --project "New Animations" --datasource "CurrentYrOverYrStats" --source-username OurDatabaseSignIn --source-password "OurDatabasePassword"   `

以下命令可重新整理已發佈到 Tableau Cloud、名為 CurrentYrOverYrStats 的擷取。此命令指定以下內容：

- Tableau Cloud 使用者和密碼。
- Tableau Cloud 網站和專案名稱。
- 資料來源以及用於登入託管資料來源的使用者名和密碼，在本例中，資料庫源由雲端資料來源提供商（例如 Salesforce.com）託管。

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --source-username database_user@hosted_datasource_provider.com --source-password "db_password"`

若要重新整理基於檔的資料來源的擷取，請提供您從中建立擷取的原始檔路徑。如果檔位於網路共用上，請使用 UNC 格式，而不是映射的驅動器。

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --original-file "\\server\path\filename.csv"`

## tableau addfiletoextract 的語法

使用 `tableau addfiletoextract` 將檔案內容附加到已發佈到 Tableau Server 或 Tableau Cloud 的擷取。此命令組合兩個檔案。

如果只想使用最新變更更新現有擷取，請使用 `refreshextract` 命令。使用 `addfiletoextract` 更新現有擷取將會複製資料。

要檢視此命令的說明，請在 Windows 命令提示字元處鍵入以下命令：

`tableau help addfiletoextract`

所有選項都有一個與雙連字號結合使用的完整形式（例如，`--server`）。有些選項還有一個與單連字號結合使用的短形式（例如，`-s`）。如果選項的值包含空格，則用引號將選項值引起來。

### tableau addfiletoextract 命令選項

<table><tbody><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><b>短形式</b></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><b>完整形式</b></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><b>描述</b></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--file &lt;path and file name&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>包含要追加的資料的資料檔案的路徑和檔案名資訊。該檔案可來自 Excel、Access、Tableau 資料，或者分隔符號分隔的文字檔。它不能受密碼保護。如果檔案位於網路共用上，請使用 UNC 格式。例如，<code>\\server\path\filename.csv</code></p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-s &lt;server http address&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--server  &lt;URL&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>在其中發佈資料的 Tableau Server 的 URL。</p><p>對於 Tableau Cloud，請指定 <code>https://online.tableau.com</code>。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-t &lt;site id&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--site &lt;site id&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>在多網站環境中，指定命令將套用於的網站。對於 Tableau Cloud，如果您的使用者名與一個以上的網站關聯，則必須包括此參數。對於 Tableau Server，如果未指定網站，則使用預設網站。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--datasource &lt;datasource&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>發佈到 Tableau Server 或 Tableau Cloud 的資料來源的名稱。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--project &lt;projectname&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>資料來源所屬的專案。如果不包括此選項，則假定為預設專案。</p><p>如果要指定的專案是內嵌在專案階層內的子專案，則必須隨 <code>--parent-project-path</code> 參數一起使用此參數。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--parent-project-path path/to/project</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>如果將資料來源發佈到的專案沒有位於專案階層的頂層，請隨 <code>--project</code> 參數一起使用此參數以指定巢狀專案的路徑。</p><p>使用正斜線字元&nbsp;(<code>/</code>) 來分隔階層中的專案層級。使用反斜線 (<code>\</code>) 對專案名稱中的正斜線或反斜線字元進行轉義。</p><p>例如，對於頂層「Marketing」下的專案「Social」中名為 Sandbox 的專案：</p><p><code>--project Sandbox --parent-project-path Marketing/Social</code></p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-u &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--username &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>有效的 Tableau Server 或 Tableau Cloud 使用者。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>-p "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--password  "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>指定的 Tableau Server 或 Tableau Cloud 使用者的密碼。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--proxy-username &lt;username&gt;</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>代理伺服器的使用者名。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyE-Column1-Body1">&nbsp;</td><td class="TableStyle-Basic-Border-BodyE-Column1-Body1"><code>--proxy-password "&lt;password&gt;"</code></td><td class="TableStyle-Basic-Border-BodyD-Column1-Body1"><p>代理伺服器的密碼。</p></td></tr><tr class="TableStyle-Basic-Border-Body-Body1"><td class="TableStyle-Basic-Border-BodyB-Column1-Body1"><code>-c "&lt;path and filename&gt;"</code></td><td class="TableStyle-Basic-Border-BodyB-Column1-Body1"><code>--config-file "&lt;path and filename&gt;"</code></td><td class="TableStyle-Basic-Border-BodyA-Column1-Body1"><p>包含命令設定選項的檔案的路徑和檔案名資訊。始終將路徑括在雙引號內。有關詳情，請參閱下面的<a href="#Using" class="xref">使用組態檔</a>。</p></td></tr></tbody></table>

### tableau addfiletoextract 範例命令

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau addfiletoextract --server https://our_server_name --username OurServerSignIn --password "OurServerPwd" --project "New Animations" --datasource "CurrentYrOverYrStats" --file "C:\Users\user1\Documents\DataUploadFiles\AprMay.csv"`

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau addfiletoextract --server https://online.tableau.com --username email@domain.com --password "OurServerPwd" --site vernazza --project "New Animations" --datasource "CurrentYrOverYrStats" --file "C:\Users\user2\Documents\DataUploadFiles\AprMay.csv"`

## 使用組態檔

可以使用純文字編輯器（例如記事本或文字編輯），來建立可用於 `tableau refreshextract` 或 `tableau addfiletoextract` 的組態檔。如果希望在一段時間內定期更新同一資料來源，組態檔可能非常有用。指定組態檔後，就無需在每次執行命令時都鍵入相同的選項。組態檔還有一個優勢，那就是不會在命令列上洩漏使用者名和密碼。

### 建立組態檔

例如，假設您建立了一個名為 config.txt 的檔案並將它儲存到您的 Documents 資料夾。在該檔案中，您包含了下面顯示的參數資訊。

對於發佈到 Tableau Server 的擷取：

`server=https://our_server_name   username=OurServerSignIn   password=OurServerPwd   project=New Animations   datasource=CurrentYrOverYrStats`

對於從託管資料來源發佈到 Tableau Cloud 的擷取（其中**伺服器**為 **https://online.tableau.com**）：

`server=https://online.tableau.com   site=vernazza   username=email@domain.com   password=OurPassword   project=New Animations   datasource=CurrentYrOverYrStats   source-username=database_user@hosted_datasource_provider.com   source-password=db_password`

### 在命令列中引用組態檔

建立組態檔後，可以執行 `tableau refreshextract` 或 `tableau addfiletoextract` 命令，指向組態檔，將其作為命令列中使用的唯一選項，並將組態檔的路徑括在雙引號內。語法如下：

`tableau refreshextract --config-file "<path>"`

例如，若要重新整理在[建立組態檔](#Create)部分的範例中指定的擷取，應執行以下命令（確保在 Tableau Desktop 版本的資料桶目錄中工作）：

`C:\Program Files\Tableau\Tableau 2022.4\bin>tableau refreshextract --config-file "C:\Users\user1\Documents\config.txt"`

### 組態檔的語法差異

用於在組態檔內指定選項的語法與命令列中使用的語法在以下方面有所不同：

- 選項名稱不以短橫線或連字號開頭。
- 可使用等號（不含空格）分隔選項名稱和選項值。
- 值不需要（或不允許）用引號引起來，即使它們包含空格也是如此（就像前面範例中的 `project` 選項）。

## 使用 Windows 工作排程器重新整理擷取

您可將 Windows 工作排程器與 Tableau 資料擷取命令列公用程式結合使用，以便從企業防火牆內自動執行對 Tableau Desktop 資料來源的定期更新。可將工作設定為每天、每週或每月執行一次，或者在發生特定系統事件後執行。例如，在電腦啟動時執行工作。

若要瞭解詳情，請參閱 Microsoft TechNet 庫中的[工作排程器使用指南](http://technet.microsoft.com/zh-cn/library/cc766428.aspx)頁。