Skip to main content

I have a dashboard with a filter/parameter to display the chart for the selected segment. There's dozens of segments. Is there a way to export to ppt and have each segmentation be its own page?

 

I am trying to avoid creating ~50 sheets and dashboards in tableau.

1 resposta
  1. 2 de jul. de 2025, 14:42

    @Wes Patton​ 

    Hi, I think you may Tableau Server Client to generate a PDF (I currently don't have a PPT code).

    import tableauserverclient as TSC

    import os

    import numpy as np

    from io import BytesIO

    import PyPDF2

     

    # source information

    SOURCE_SERVER_NAME = "https://www.yourserver.com"

    SOURCE_SITE_NAME = 'yoursite'

    SOURCE_WORKBOOK_NAME = "RestApi2"

    PROJECT_NAME = "RestApi"

     

    # destination info

    TMPDIR = "PDF Merged"

    PREVIEW_FOLDER_LOCATION = os.getcwd() + "/" + TMPDIR + "/"

    PREVIEW_FILE_EXTENSION = ".pdf"

     

    ⌗Login info

    TOKEN_NAME = 'Test'

    TOKEN = 'neOMFA+Tyvw==:p48kScoLBZQILB'

    #Each element in the filter array will generate a PDF. in the element, separate with comma the values e.g. 'Material de oficina,Mobiliario'. if you want to filter several values at the same time. This will generate two PDFs, one with Material de oficina and Mobiliario, and other, filtered with Tecnologia

    FILTERS = np.array(['Material de oficina,Mobiliario', 'Tecnología'])

     

    source_server = TSC.Server(SOURCE_SERVER_NAME, use_server_version=True)

     

    ⌗Use the following to sign in with PAT

    source_tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME,TOKEN,SOURCE_SITE_NAME)

     

    with source_server.auth.sign_in(source_tableau_auth):

    print('Logged in to source server successfully')

    all_workbooks = source_server.workbooks.filter(name=SOURCE_WORKBOOK_NAME, project_name=PROJECT_NAME)

    print(len(all_workbooks))

    ⌗Download workbook to a temp directory

    if len(all_workbooks) == 0:

    print('No workbook named {} found.'.format(SOURCE_WORKBOOK_NAME))

    exit()

    elif len(all_workbooks) >= 2:

    print('Several workbooks named {} found.'.format(SOURCE_WORKBOOK_NAME))

    exit()

    elif len(all_workbooks) == 1:

    isExist = os.path.exists(TMPDIR)

    print(isExist)

    if not isExist:

    # Create a new directory because it does not exist

    os.makedirs(TMPDIR)

    print("The new directory is created!")

    try:

    for j in all_workbooks:

    ##create a pdf merger object

    PDFMerger = PyPDF2.PdfMerger()

    for k in FILTERS:

    try:

    source_server.workbooks.populate_views(j)

    print("Connected to wb")

    for i in j.views:

    # set the image request option

    pdf_req_option = TSC.PDFRequestOptions(page_type=TSC.PDFRequestOptions.PageType.Unspecified)

    # (optional) set a view filter

    print("Setting filters")

    pdf_req_option.vf('Categoría', k)

    #pdf_req_option.vf('Parameters.Year', '2018')

    source_server.views.populate_pdf(i, pdf_req_option)

    stream = BytesIO(i.pdf)

    PDFMerger.append(stream)

    except:

    pass

    PDFMerger.write(PREVIEW_FOLDER_LOCATION+PREVIEW_FILE_NAME)

    print(PREVIEW_FOLDER_LOCATION+PREVIEW_FILE_NAME)

    except:

    pass

    # Sign out

    source_server.auth.sign_out()

    If working with default site use:

    SOURCE_SITE_NAME = ''

    Note this approach needs the workbook published in Tableau Server or Tableau Cloud. Also, note this code uses PAT (Personal Access Token authentication).

    https://help.tableau.com/current/online/en-us/security_personal_access_tokens.htm

     

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000