You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

The Tableau Extensions API

Tableau Extensions can access data and components within a Tableau dashboard, using the Extensions API provided by Tableau. Anvil X gives you access to the Extensions API from Python, as the anvil.tableau module.

This gives you access to all the objects in the Extensions API from Python, as described in Tableau’s API documentation.

Using trexjacket

While it is entirely possible to create extensions with only the Tableau Extensions API, it is a fairly low-level API. Instead, you might want to consider the higher-level Trexjacket library, which is designed to make extension development easier.

You can use Trexjacket alongside the Extensions API, so you can mix and match – for example, you might use Trexjacket for common tasks, and the Extensions API for advanced operations not included in Trexjacket.

Using the Tableau Extension API directly

The anvil.tableau module is imported automatically in every Anvil X project:

from anvil import tableau

This gives you access to the full tableau.extensions API from Python. For example, in order to get the name of every worksheet in the current dashboard, you can write the following Python code:

worksheet_names = [
    worksheet.name for worksheet in
    tableau.extensions.dashboardContent.dashboard.worksheets
    ]

Similarly, you can register event listeners using Python functions, or methods of your Form class:

class Form1(Form1Template):
    def __init__(self, **properties);
        self.init_components()

        first_worksheet = tableau.extensions.dashboardContent.dashboard.worksheets
        first_worksheet.addEventListener("mark-selection-changed", self.print_mark)

    def print_mark(self, event):
        marks = event.getMarksAsync()
        print(f"{len(marks)} marks selected")

Learning more

To learn more about the Tableau Extensions API, please see the Tableau Extensions API Basics page and consult the API reference documentation.


Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.