AddTableView (arcpy.mapping)

Récapitulatif

Provides the ability to add a table to a data frame within a map document (.mxd).

Discussion

AddTableView provides a way to add a table into a map document. A reference to a TableView object must exist first. It can be a reference to a table in another map document by using the ListTableViews function, or it can be a reference to a table in a workspace by using the TableView function.

Syntaxe

AddTableView (data_frame, add_table)
ParamètreExplicationType de données
data_frame

A reference to a DataFrame object within a map document.

DataFrame
add_table

A reference to a TableView object representing the table to be added. This reference can point to a table within an existing map document or it can reference a table in a workspace via the TableView function.

TableView

Exemple de code

AddTableView example

The following script will add three tables from three different workspaces to a single data frame in a map document. The different workspaces are shapefile/dBASE, file geodatabase, and SDE.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
dbf_Table = arcpy.mapping.TableView(r"C:\Project\Data\customers.dbf")
fGDB_Table = arcpy.mapping.TableView(r"C:\Project\Data\fGBD.gdb\customers")
SDE_Table = arcpy.mapping.TableView(r"C:\PathToSDEConnectionfile.sde\customers")
arcpy.mapping.AddTableView(df, dbf_Table)
arcpy.mapping.AddTableView(df, fGDB_Table)
arcpy.mapping.AddTableView(df, SDE_Table)
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
9/12/2013