Download Tableau Reports from the Commandline

Sun, Feb 26, 2017 - Read in 2 Min

Navigation and clicking on a Tableau server could be time consuming. That’s why I created this script to quickly download finished PDF reports from Tableau workbooks quickly.

This post originally appeared on Yizhe’s Source of all wonders

Introduction

Use this script to export the views of a workbook as pdfs or pngs, or export the data as a csv file, all you need to know is the name of that workbook and name of the views and your credentials. Currently this script is only tested with windows machine.

What do you need to know?

  • Your tableau server address
  • Username and password (this is what you use to log in online).
  • The name of your workbook and the pdf you want to download
  • Properly install tabcmd on you machine.
    • Windows: follow the instruction here
    • Linux: follow this from here (not yet tested)
    • Mac: follow this (I have not yet tested)

And here’s the link to tabcmd documentation.

Script

Copy and paste the full script to a directory where you want to run it. Modify the $server, $twb, $pdfs with your own information.

# Modify the following parameters

$server="https://your/tableau/server/address.com/"
$twb="NameofYourWorkbook"
$pdfs = "NameofYourView-1","NameofYourView-2"

# login tableau server
tabcmd login -s $server --no-certcheck

# create a directory
$path=".\"
mkdir $path$twb

for ($i=0; $i -le $pdfs.Length-1; $i++) {
  $remote=$twb+"/"+$pdfs[$i]
  $locale=$path+$twb+"\"+$pdfs[$i]+".pdf"
  tabcmd export $remote --pdf -f $locale --no-certcheck
}

# logout tableau server
tabcmd logout

Example

The script will create a new directory with the name of your tableau workbook in the directory where you have the script saved, and place the pdfs in there:

>> .\dl-reports.ps1
===== redirecting to https://your/tableau/server/address.com/
===== Signed out
===== Creating new session

=====     Server:   https://your/tableau/server/address.com/
=====     Username: myUserName
Password:
===== Connecting to the server...
===== Signing in...
===== Succeeded


    Directory: C:\Users\Myself\Script\Directory


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        2/22/2017  11:05 AM                NameofYourWorkbook
===== Continuing previous session
=====     Server:   https://your/tableau/server/address.com/
=====     Username: myUserName
===== Requesting 'NameofYourWorkbook/NameofYourView-1' from the server...
===== Saved NameofYourWorkbook/NameofYourView-1 to '.\NameofYourWorkbook\NameofYourView-1.pdf'
===== Continuing previous session
=====     Server:   https://your/tableau/server/address.com/
=====     Username: myUserName
===== Requesting 'NameofYourWorkbook/NameofYourView-2' from the server...
===== Saved NameofYourWorkbook/NameofYourView-2 to '.\NameofYourWorkbook\NameofYourView-2.pdf'
===== redirecting to https://your/tableau/server/address.com/auth
===== Signed out

comments powered by Disqus