7 Replies Latest reply on Dec 30, 2015 1:38 PM by Mark Pelletier

    Nasty trap when hacking the XML of a workbook

    Richard Leeke

      I just wasted a few hours tracking this one down and I as I haven't seen anyone else mention it I thought I'd pass it on.

       

      We often automate making minor changes to Tableau workbooks - things like changing connection details prior to publishing. I generally just do that with a Perl script and have never had any issues.

       

      But today we were doing the same sort of thing for automating publication of a workbook integrated into an application, written in .NET. So instead of scripting it in Perl we accessed and modified the workbook using a .NET framework XML parser.

       

      The modified workbook opens fine from Desktop, but won't publish to Server from tabcmd. It gives this error:

       

      [9372] ERROR  Sep-04 05:00:34,667: An unexpected error occurred opening the packaged workbook.

      Operation Canceled.

      [9372] DEBUG  Sep-04 05:00:34,667: Received ExitWithStatus, code 1

      [9372] DEBUG  Sep-04 05:00:34,667: file:/D:/Tableau/Tableau Server/8.0/bin/tabcmd.jar!/tabcmd/lib/multicommand.rb:100:in `run_each'

       

      To cut a long story short, it turns out that the Microsoft XML parser writes the modified file out as a UTF-8 file with a byte order mark (BOM). The Unicode standard allows a BOM on a UTF-8 file but recommends against it because it can break things, as discussed in this Wikipedia article. Evidently so.

       

      The BOM is just three non-printing bytes at the start of the file and can easily be stripped off (just not with an MS XML parser).

       

      BOM.png

       

      Of course hacking the workbook is unsupported - and this just goes to demonstrate why.