1 2 Previous Next 15 Replies Latest reply on Jan 9, 2018 7:02 PM by Rowel Zantua

    Create a twbx dynamically.

    Erol Beynam

      Hello,

       

      I want to be able to create a twbx file from a program on a virtual machine by using Desktop edition.

      Then I want a client to connect to the virtual machine and open up that twbx using a reader.

      I can open from the virtual machine or maybe transfer the twbx file to the client machine.

      Can I do this? How?

       

      Can I embed reader to a .NET app or a web app as a separate tab?

       

      Thanks,

       

      Erol

        • 1. Re: Create a twbx dynamically.

          Hey Erol,

           

          While I don't know how you would automate such a task, there shouldn't be any issue with exporting a packaged workbook then sending it to your users so they can use reader. Sorry if i'm not FULLY grasping what you're trying to do.

           

          -Diego

          • 2. Re: Create a twbx dynamically.
            Erol Beynam

            Hi Diego,

             

            Here is what I am trying:

             

            I will create few reports on the desktop and create a twbx package,

            Then I will copy these packages to few client machines.

             

            Now -

            1 - I want to be able to open these reports with the reader and curious if the reader can be embedded into our .NET app, or can be opened in a frame from our app.

            2- I want to be able to send new data to these clients rather than a package. So maybe unzip twbx and replace extract in there. How about using a local file on the client as data connection (maybe an access or excel file) and rewrite this file?

             

            Bottom line, I want this process to be as dynamic as possible without a human interaction of copying, moving, opening, etc.

             

            Thanks,

             

            Erol

            • 4. Re: Create a twbx dynamically.
              Tom W

              1. Tableau Reader cannot connect to live data sources, only packaged.

              2. A Tableau Packaged Workbook is effectively a zip file. Open one up in winzip (or another zip tool) and you'll notice there is a data directory. You could write a program to unzip, insert data extract, rezip.

              3. As far as I know there are no .NET / Windows controls to embed Tableau into an existing Winforms application. If you want to embed it within a webapp, you have a number of options but you would need a Tableau Server.

              • 5. Re: Create a twbx dynamically.
                Steve Berndt

                Tom W,

                 

                If you are in a situation where you need to have the workbook repackaged, how do you do that? We've been able to script the unpackaging and the updating, but the repackaged file doesn't seem to be recognized by the server.

                 

                ANY insight to this would be amazing.

                • 6. Re: Create a twbx dynamically.
                  Tom W

                  Steve,

                  Take the temporary folder structure and zip it then rename the extension to .twb or .twbx depending on the type of workbook it was originally.

                  • 7. Re: Create a twbx dynamically.
                    Steve Berndt

                    Tom W,

                    I really appreciate the quick reply, this really helped up figure out how to correctly script our loading process. I'm also learning python as we go, so it's been an adventure.

                     

                    Thank you again!!!

                    • 8. Re: Create a twbx dynamically.
                      Chetan Patil

                      Hi Tom,

                       

                      I am also looking for solution of  same problem definition, in order to send .twbx file to user machines using Python.

                       

                      Could you please post the solution if you have.

                       

                      Thank you!

                      • 9. Re: Create a twbx dynamically.
                        Tom W

                        Chetan,

                        Are you trying to dynamically generate a TWBX or send a TWBX to a user through Python? The two are very different things.

                         

                        If you're looking to generate a TWBX dynamically, you should rename your .twbx file to .zip, extract the contents and you can do whatever you want with those in Python to dynamically create or adjust a workbook file. The structure / definition of the workbook file is just XML so no special code needed to read and parse that.

                        • 10. Re: Create a twbx dynamically.
                          Chetan Patil

                          Tom,

                           

                          Thank you for quick response.

                           

                          My workflow would have below steps -

                          1) Copy & paste saved template workbook into new folder (Python)

                          2) Change data source dynamically in pasted workbook (Python)

                          3) Save updated workbook with new data source as .twbx into new folder (Python)

                          4) Send saved .twbx to user machine (TBD)

                           

                          I already tried saving .twb with .twbx after changing data source but  new file was not usable as gets open with error.

                           

                          Thank you once again.

                          • 11. Re: Create a twbx dynamically.
                            Tom W

                            You cannot just rename a TWB to TWBX. You would need to zip the TWB file and rename the zip as TWBX.

                            To validate you are doing things correctly, as a test you should export a workbook as TWBX from Tableau, rename it to zip and unzip it. Take a look at the folder structure. This is exactly the same folder structure you need to replicate out of Python.

                            • 12. Re: Create a twbx dynamically.
                              Chetan Patil

                              Appreciate your response Tom.

                              • 13. Re: Create a twbx dynamically.
                                Allan Thompson

                                You can create workbooks programmatically (dynamically) since workbooks are really XML. I've done this and shared about it here: https://www.linkedin.com/pulse/create-tableau-visualizations-programmatically-allan-thompson

                                 

                                I used Python and the Pandas and Jinja2 libraries to create the TWB file and then to package it and the data into a TWBX file.

                                 

                                If you want to embed your visualization into an application, as far as I know, you need Tableau server.

                                 

                                With your workbook on Tableau server, you now have access to the embed code that you can plug into any HTML or .NET WebBrowser control, if that's what you're trying to do. You can also use the control from Tableau server to embed the authoring view into IE or a .NET desktop application. The authoring view gives users similar capabilities as Tableau Desktop.

                                 

                                To publish to Tableau server, you can use the RESTful API that Tableau provides. They provide code examples for using the API with either Java or Python.

                                 

                                Summary: it is possible to manage the creation and publishing of workbooks on behalf of a user from beginning to end and give users access to view and interact with those workbooks within your custom app.

                                • 14. Re: Create a twbx dynamically.
                                  Allan Thompson

                                  Thanks for sharing this detail about the license agreement for Reader. I think generating and updating workbooks programmatically makes the most sense when the intent is to publish to Tableau server.

                                  1 2 Previous Next