I'm also keenly interested in automating Workbook operations. My client has a very specific need to generate very high quality PDFs, including 14 separate PDFs of a Worksheet, one for each specific value of a filter. In this situation generating the PDFs using Tableau Server's automation isn't really an option; if nothing else, the different visual renderings between the desktop and server make it ponderous.
I've recommended the keystroke record-and-playback approach, and agree with Richard that it's a stopgap measure.
Tableau's undo-redo capability suggests that there's a command processing mechanism that could be leveraged for implementing at least those operations that can be undone/redone.
If you do go down the record/playback route I'm happy to share what I've found - there are a few obstacles that make it tricky to get it reliable. I can even let you have a copy of the utility I've put together if you want - though where I've got to wouldn't fully handle your need as I haven't found a generic way to drive the shelf controls - so it wouldn't handle changing filter values. That's possible - but I can't see how to avoid making that very specific to a particular worksheet - and the result probably wouldn't be very resilient in the face of sheet changes.
What I've done uses a freeware tool called AutoIt, which has a fairly complete scripting language and lets you build standalone executables. So I have a command line tool that supports a few basic operations (open workbook, close workbook, select sheet, refresh sheet, refresh extract, clone workbook, print PDF, etc) - but it's not 100% reliable, because of the issues I mentioned in my original posting.
I suspect some of the commercial automation tools will do a better job of recognising GUI objects and GUI states - I had a quick go with one of the high-end automated testing tools just now and it seemed a bit more promising. I just tried to do it with a free tool so I could use it at different client sites.
I'm definitely going to persevere with this - even at it's current level of reliability it can be a big time saver. I set up a script to refresh a couple of extracts and 10 or so worksheets in a workbook yesterday. That takes about an hour and a half, and needs a few mouse clicks every 5 or 10 minutes. Just being able to run a script before going to a meeting and come back and it's done is great.
I'll look into AutoIt and see what it offers.
Hi Chris — did you have any success with Autoit?
One other pitfall with this which I didn't mention in my original posting is that the scripts are quite susceptible to breakage with new versions of Tableau. I originally scripted this with 5.0 and had to make quite a few (very minor) changes when 5.1 came out. Some of these were user-visible changes in the interface (a couple of menu options changed name) and also the internal names for a few windows controls changed.
So only go this way if you're prepared to do a bit of maintenance to keep it working as new releases come out.
Re: ... detecting when Tableau had finished processing the latest request
If using together Autoit and Python Image Library, the following code snippet may be useful:
from win32api import GetSystemMetrics
width = GetSystemMetrics (0)
height = GetSystemMetrics (1)
from PIL import Image, ImageGrab
def wait_stale_screenshot(tick=2, timeout=30):
"""Take sequence of screenshots separated by tick(seconds) and wait for
two identical screenshots.
Return number of screenshots taken (less by one) or 0 in case of timeout"""
time_start = time.time()
h0 = ImageGrab.grab( (0, 0, width, height,) ).histogram()
tick_count = 0
while time.time()<time_start + timeout:
tick_count += 1
h = ImageGrab.grab( (0, 0, width, height,) ).histogram()
if h == h0:
h0 = h
This works fairly reliable vs. rotating wait cursor. With carefully chosen parameters should also work for various progress indicators.
Wonderful - I'll try to figure out how to use that. If I can get that going I'll happily share the little command-line automation tool I've put together - I've been a bit hestitant just to post it so far because of the trouble with trying to make it robust.
Any pointers on how to go about using the Python Image Library with Autoit, Vladimir? That's new territory for me.
We have also built an automation app to meet our needs. It might be interesting to have this group discuss what we are doing and what we would like to be able to do. I am more than willing to facilitate that conversation if anyone is interested.
I have also been bitten by the new Tableau version bug - between 5.0 and 5.1 and am going to the same issue with the move to 6.0. It is not a lot of fun...
I'm certainly interested to hear how others have tacked it, what you've managed to achieve, what issues you've hit etc. I'm also very happy to share what I've done.
I would just reiterate my earlier comments that this sort of approach really is a band-aid - so I'd encourage people not to invest too much time and effort in something which will keep going out of date as new releases come out. There are often other ways of coming at things within the supported capabilities, so I tend to view it as a last-resort approach.
Casting my vote for automation features or language. Even command line parameters would be a good start.
+1 from me too.
A proper API would be even nicer.
I'm a new user of Tableau, working in a French company.
I'm also interested in a way to automate refreshing and PDF printing with Tableau. I looked for ways to do it on the Internet, but nothing is posted about that. I'd be happy if one of you could give me some tips on this.
I've been asking for this since version 2.0 (five years ago). This type of automation component was crucial to Microsoft's success with Excel and Word (and it was WordBasic that did a lot to help Word supplant WordPerfect as the preeminent word processing program.) In any case, I'd love to see this.
I can see this being very useful to my organisation. The example that Chris Gerrard mentions, printing a number of graphs based on different filter selections, would be useful to me straigh away.