Forum Discussion
Modifying the Layout file that is embedded in a pbix file
I know how to disassemble a pbix file by changing the extension to .zip and then oening it. If I then change the extension back to .pbix I can then open it in Power BI. However, I would like to modify the Layout file that is exposed when you disassemble the pbix. But when I do that and change the extension of the .zip to .pbix, I get a corrupted file message when I try to open in Power BI. This happens no matter how small and inocuous the change is.
Is there any way to do this without getting the corrupted file message?
- Anonymous5 years ago
I was struggling with this issue recently, and my solution is the following:
- Change the extension from ".pbix" to ".zip"
- Do not unzip the ".zip" file during this process
- Extract the "Layout" file from the "Report" folder in the ".zip" file
- Open the "Layout" file with Notepad++. (VERY IMPORTANT)
- Make your modifications in the Layout file
- Substitute the old "Layout" file with the new one
- Delete "SecurityBindings" file in the ".zip" file
- In the [Contents_type].xml delete the following text:
"<Override PartName="/SecurityBindings" ContentType="" />"
- Change the extension from ".zip to ".pbix"
- The file will open without breaks
Hope it helps!
33 Replies
- AnonymousNot applicable
I was struggling with this issue recently, and my solution is the following:
- Change the extension from ".pbix" to ".zip"
- Do not unzip the ".zip" file during this process
- Extract the "Layout" file from the "Report" folder in the ".zip" file
- Open the "Layout" file with Notepad++. (VERY IMPORTANT)
- Make your modifications in the Layout file
- Substitute the old "Layout" file with the new one
- Delete "SecurityBindings" file in the ".zip" file
- In the [Contents_type].xml delete the following text:
"<Override PartName="/SecurityBindings" ContentType="" />"
- Change the extension from ".zip to ".pbix"
- The file will open without breaks
Hope it helps!
- AnonymousNot applicable
Yes, This worked. Because of this so much time is saved. Don't know how to thank you.
- AnonymousNot applicable
This worked! Thanks so much! It saved me hours of having to rebuild the file
- AnonymousNot applicable
GREAT! Saved my week \o/
Thanks Anonymous
- AnonymousNot applicable
When I remove "<Override PartName="/SecurityBindings" ContentType="" />" in the [Content_Types].xml root file, I can edit the PBIX file and open it without problem.
- CBourletFrequent Visitor
Hey,
I tried your solution, it's working great !
many thanks !- AnonymousNot applicable
Hi
When I try to just remove the "<Override PartName="/SecurityBindings" ContentType="" />" in the [Content_Types].xml root file and try to re construct the pbix by zipping the file, still I am unable to open the file. Please advise.
- instinct46New Member
I found that when I was saving, the WriteAllTextAsync was prepending 2 extra bytes.. using FlexHex I could see that the original did not have that.
To fix this I just saved with WriteAllTextAsync with Encoding.Unicode. Re-opened as bytes and saved skipping the first 2 bytes in question.
var serializedFile = JsonConvert.SerializeObject(_layoutModel); await System.IO.File.WriteAllTextAsync(Filepath, serializedFile, Encoding.Unicode); var asBytes = await System.IO.File.ReadAllBytesAsync(Filepath); await System.IO.File.WriteAllBytesAsync(Filepath, asBytes.Skip(2).ToArray());Just as an FYI, as others have mentioned I also needed to edit [Content_Type].xml and remove the Override tag with the PartName == "/SecurityBindings". After that powerbi loaded it fine (ignoring the validation checks it did).
- instinct46New Member
After a little research I found that it's a marker for byte order of unicode (I'd gussed it was this, but didn't know for sure until now). Anyway, I've update the code pushed here yesterday. (Couldn't find an edit link for my previous post)
public async Task Save() { var layoutFile = JsonConvert.SerializeObject(_layoutModel); await System.IO.File.WriteAllTextAsync(Filepath, layoutFile, Encoding.Unicode); IEnumerable<byte> layoutAsBytes = await System.IO.File.ReadAllBytesAsync(Filepath); layoutAsBytes = StripUnicodeByteOrder(layoutAsBytes); await System.IO.File.WriteAllBytesAsync(Filepath, layoutAsBytes.ToArray()); } public static IEnumerable<Byte> StripUnicodeByteOrder(IEnumerable<byte> bytes) { if (bytes.ElementAt(0) == 0xFF && bytes.ElementAt(1) == 0xFE) bytes = bytes.Skip(2); return bytes; }- AnonymousNot applicable
Hi instinct46 ,
Could you explain where and how one should exactly run this code? In my case, I don't want to change the lay-out file but I want to change the datamodelschema to programmatically add measures.
Thanks in advance.
- FelipeCosta
Advocate II
This is what worked for me.
- AnonymousNot applicable
I would recommend you follow the instructions in the blog below to change layout.
https://powerbi.tips/2018/01/introducing-layouts/
Regards,
Lydia- maceyakRegular Visitor
Thanks, Lydia. But I am not asking about changing the visual layout of a page. I am asking about changing a particular file named "Layout" that is exposed when you deconsturuct a PBIX file. This file contains the formatting information for the page and the text that the designer has entered into it. To get to this file, you do the following to a PBIX file:
1. Changed the extension from ".pbix' to ".zip".
2. Open the zip file. You will see several folders. Go into the Report folder, and you will see the Layout file.
--Joey
- AnonymousNot applicable
maceyak,
What property do you change in the Layout file? There is no official articles stating that what we can do or can't do in the Layout file.
Regards,
Lydia
- AnonymousNot applicable
Hi, have you found a solution for this yet?
- maceyakRegular Visitor
No.
- vinayapNew Member
Did you find solution for this issue? I too am facing the same issue while making changes to a visual through layout file.
- AnonymousNot applicable
I have the same issue. I can open and modify the Layout file, but this corrupts the pbix file. My issue is that I used to use an arcgis esri map, but am not able to delete this custom visual via PBI Desktop (it doesn't show up in the delete visuals list). I was trying to change
\"singleVisual\":{\"visualType\":\"esriVisual\",\"objects\":{}
to
\"singleVisual\":{\"visualType\":\"map\",\"objects\":{}
If anybody has any idea how to delete the esri visual/component, I would be grateful.
EDIT: I have also disabled the "use esri maps" from the options, but still the esri map icon is visible in the visuals list. Is this normal? I don't want app viewers to get the esri map notification when they open the app for the first time.
- AnonymousNot applicable
I second this issue. Has anybody already opened an "idea" for this topic. Changing these parameters programmatically would be a huge enterprise BI update! Or it is quite a bummer that we can see all these parameters but not able to change it.
Anonymous in this case opening Power BI Desktop is definitely not a satisfying answer.
But which changes can we do so far, and everyone else which changes have you done in the zip?
E.g. changing the registeredresources is possible.
- AnonymousNot applicable
I created an Idea to address this question, please vote:
Renaming dataset measures can't break client reports (change reference from name to ID)
https://ideas.powerbi.com/ideas/idea/?ideaid=649ec802-682b-ec11-b76a-281878e608e9
- Ian_BRegular Visitor
I can change the Layout file by doing the following:
Change .pbix to .zip
Extract file
Amend and save extracted Layout file
Copy amended Layout file into original zipped folder *
Rename .zip to .pbix
*This is required. Re-zipping the extracted file will cause corruption
- CBourletFrequent Visitor
Same issue here, but even without rezipping the file, it causes corruption :(,
hope it will be possible to deal with the Layout directly one day. - AnonymousNot applicable
I created an Idea to address this question, please vote:
Renaming dataset measures can't break client reports (change reference from name to ID)
https://ideas.powerbi.com/ideas/idea/?ideaid=649ec802-682b-ec11-b76a-281878e608e9