内容:

Microsoft Excel

  • 版本 :2022.1 及更高版本

本文介绍如何将 Tableau 连接到 Microsoft Excel 文件数据并设置数据源。Tableau 连接到.xls和.xlsx文件。 若要连接到.csv文件,请使用文本文件连接器。

建立连接并设置数据源

  1. 打开 Tableau 后,在“连接”下,单击“Excel”。

  2. 选择要连接到的 Excel 工作簿,然后单击“打开”。

    注意:从 Tableau 2020.2 开始,不再支持旧版 Excel 和文本连接。请参阅 Tableau 社区中的旧版连接备选方案文档,了解使用旧版连接的替代方法。

  3. 在“数据源”页上,执行以下操作:

    注意:Tableau 不支持 Excel 中的数据透视表。

    1. (可选)选择页面顶部的默认数据源名称,然后输入要在 Tableau 中使用的唯一数据源名称。例如,使用数据源命名约定,帮助数据源的其他用户确定要连接到哪个数据源。

    2. 如果 Excel 文件有一个表,请单击工作表选项卡以开始分析。

      使用自定义 SQL 连接到特定查询,而不是整个数据源。有关详细信息,请参阅连接到自定义 SQL 查询

      还可以像连接到工作表一样连接到命名区域或 Excel 表(也称为 Excel 列表)。命名区域和 Excel 表在 Tableau 中都用作表。

      通过在 Excel 中创建命名区域,方法是选择单元格区域,然后在“公式”选项卡上选择“定义名称”。与命名区域类似,可以通过选择单元格区域,然后选择“插入>表”,在 Excel 中创建 Excel 。在 Tableau 中连接到命名区域或 Excel 表时,“数据源”页面中工作表旁边会显示一个图标,如下所示。

      只要数据源中的每个连接都有唯一的名称,就可以同时连接到多个 Excel 工作簿。

Microsoft Excel 数据源示例

下面是 Microsoft Excel 数据源的一个示例。

注意:如果 Excel 文件包含的列的宽度超过 254 个字符,则 Tableau Desktop 不能将这些字段用于在 Tableau Desktop 8.2 之前创建的工作簿。此外,不能使用旧连接连接到此数据。删除列,在 Tableau Desktop 中连接之前将其修改为 254 个字符以内,或者升级 Excel 数据源。有关升级数据源的详细信息,请参阅升级数据源

获取更多数据

通过添加更多表或连接到其他数据库中的数据,将更多数据放入数据源。

  • 从当前文件添加更多数据:从左窗格中,将其他表拖到画布上,以使用联接或并集合并数据。有关详细信息,请参阅联接数据合并数据

  • 从不同的数据库添加更多数据:在左窗格中,单击“连接”旁边的“添加”。有关详细信息,请参阅联接数据

    如果所需的连接器未在左窗格中列出,请选择“数据>”新建数据源“以添加新数据源。有关详细信息,请参阅混合数据

设置 Excel 表格选项

Excel 表选项的作用域限定为连接。若要更改表选项,请在画布上单击表下拉箭头,然后指定数据是否在第一行中包含字段名称。如果是这样,这些名称将成为 Tableau 中的字段名称。如果未包括字段名称,Tableau 将自动生成这些字段名称。您可以稍后重命名这些字段。

Use Data Interpreter to clean your data

If Tableau detects that it can help optimize your data source for analysis, it prompts you to use Data Interpreter. Data Interpreter can detect sub-tables that you can use and remove unique formatting that might cause problems later on in your analysis. For more information, see Clean Data from Excel, CSV, PDF, and Google Sheets with Data Interpreter.

About .ttde and .hhyper files

You might notice .ttde or .hhyper files when navigating your computer's directory. When you create a Tableau data source that connects to your data, Tableau creates a .ttde or .hhyper file. This file, also known as a shadow extract, is used to help improve the speed your data source loads in Tableau Desktop. Although a shadow extract contains underlying data and other information similar to the standard Tableau extract, a shadow extract is saved in a different format and can't be used to recover your data.

In certain situations, you might need to delete a shadow extract from your computer. For more information, see Low Disk Space because of shadow extract in the Tableau Knowledge Base.

Changes to the way values are computed

Starting from version 10.5, when you are working with extract data sources as well as data sources that use live connections to file-based data like Excel, the values in your data can be computed differently from previous versions of Tableau. This change means that you might see differences between the data and the marks in your view between version 10.4 (and earlier) and version 10.5 (and later). The purpose of this change is to improve the efficiency and scalability of your Excel data source. For more information, see Changes to values and marks in the view.

In the case of an Excel data source, one example of this change is with case sensitivity. In version 10.4 (and earlier), for comparing and sorting purposes, string values are treated as case insensitive and therefore treated the same and stored as a single string value. In version 10.5 (and later), for sorting and comparing purposes, values remain case insensitive. However, values are case sensitive for storing purposes. This becomes evident when values are displayed on the data source page.

For example, suppose you have a column in your data that contains the values "House," "HOUSE," and "houSe." You see the following string values depending on the version of Tableau you are using:

  • In version 10.4 and earlier, both on the data source page and view, you see: "House," "House," and "House."

  • 在版本 10.5 及更高版本中,在数据源页面上,您会看到:“House”、“HOUSE”和“houSe”。但是在视图中,您会看到:“房子”,“房子”和“房子”。

如果需要在执行联接时保持数据区分大小写,则可以从“数据”菜单中启用“保持字符大小写 (Excel)”选项。有关此选项的详细信息,请参阅联接您的数据(链接在新窗口中打开).

另请参见

本节中的其他文章