Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Raso_NC
Frequent Visitor

PBIX files and re-zipping so PBI Desktop can open it?

We have to script some changes to an amount of PBIX files and would like to change PBIX files in bulk in the future.

 

So we have been looking into unzipping the PBIX files, changing the text in the JSON files inside and rezipping/renaming the files back to a .pbix file again.

 

However PBI Desktop keeps claiming the file is corrupt after this process.

 

Things tested/tried,

 

- We have kept the UTF-16 LE format in the internal files and just changed a color, so we were sure the format and structure were kept intact in this test.

 

- We made sure the ZIPper were vanilla ZIP and looks to be the same algorithm as used during the PBIX unzipping.

 

- We also tried an in-archive edit via 7-Zip as we thought the zip/pbix file might have been signed or something, but that didn't work either. Probably changed the checksum?

 

Has anyone had success of scripting the unzipping of a PBIX file, change a trivial thing in text, re-zipping the archive and renaming to PBIX and then had it open in PBI Desktop without trouble?

 

Is it a signed-archive problem or are we using the wrong kind of re-zipping algorithm etc?

 

Edit: We found out PBIX uses the Xpress9 algorithm which is really LZ77+Huffman, so we tried differnet repacking methods to get PBI Desktop to eat the zip file but no luck yet.

 

Any input on what re-packing works?

4 REPLIES 4
Raso_NC
Frequent Visitor

For now, we have partially solved some of this blatant problem, that is fundamentally blocking any CI/CD approach to PBI developement.

 

Using "pbi-tools" one is able to "extract" a PBIX file, then make changes to the text files via script, and then re-pack the PBIX file using "compile", without data, but with the datamodel, as a PBIT file.

 

No data or data connection tokens/auth in the PBIT file so those will manually have to be updated, or so it looks.

 

But we can bulk change layout and theme changes to reports at least and diff versions with text based diff tools, handle Git versioning etc.

 

--------------------

 

So for the remaining problem:

 

Is there any way to bulk change PBIT reports and connect them with their connections, essentially creating the PBIX files that can be uploaded back to a PBI Premium on-prem Server?

 

(Edit: Since PBIT files cannot be uploaded to (an on-prem) PBI Server)

Raso_NC
Frequent Visitor

We have now been able to unzip a PBIX file and rezip it and open it fine in PBI Desktop, if we change nothing at all.

 

Also tried to unzip, remove the Securitybindings file and rezipping and that one opened fine as well.

 

Changing just a color in the Report/Layout file in Visual Code (To make sure we keep the original UTF-16 LE format) breaks the PBIX file though.

 

 

We also tried using this post, and making change in-file,

 

https://community.powerbi.com/t5/Desktop/Modifying-the-Layout-file-that-is-embedded-in-a-pbix-file/m...

 

... but it didn't work either.

 

I.e. removing the Security Bindings file and removing the tag in the XML file for security bindings.

 

 

So I think the problem can be reduced now to how we can change a PBIX file's content so PBI Desktop can open it as usual.

(Using a script to unzip, make changes and the rezip) 

 

Which seems to be a checksum thing or similar, but does anyone know how exactly PBI Desktop does work internally for checking the PBIX file integrity?

 

Is there a way to delete the checksum or reset an internal checksum or so?

v-yueyunzh-msft
Community Support
Community Support

Hi , @Raso_NC 

If you indeed want to modify the pbix file without Power BI desktop, you can rename file extension from pbix to zip, then open the folder to find Connections file, open it in Notepad, you can see reference information. You can modify it then save the file. Rename zip back to the pbix file. Please back up your pbix file before changing file extension.

For more information, you can refer to :
What makes up a Power BI Desktop PBIX File - FourMoo | Power BI | Data Analytics

Solved: Modifying the Layout file that is embedded in a pb... - Microsoft Power BI Community

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Thanks Aniya, but,

 

> Rename zip back to the pbix file.

 

This is what we did, and this is what does not work.

 

Not with regular zip, a zip-library (from code) or even 7-zip picking the different algorithms that most closely match either zip or LZMA77 etc. We tried all combinations, even WMI.

 

We keep getting PBI to complain about a corrupted file when we reopen it.

We even tried just unzip, rezip with no changes.

 

I understand PBIX zip compression (which we can easily unzip) is XPress9 format and we are (apparently/maybe) having trouble re-zipping it with that format.

 

So do you know a re-zipper program/API/library that 100% will work to repack the PBIX file correctly after editing it?

 

Thanks for getting back though, been trying things all yesterday!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.