Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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?
Solved! Go to Solution.
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!
hello all,
i am trying to modify the layout file content using powershell script . When i m trying to user Set content with -Encoding "unicode" . After that pbix not able to open and display error corrpupted. Also in notpad ++ is shows "UTF-16 LE BOM encoding. But origial Layout ending was "utf-16 Little Endian.
Set-Content -Path "C:\PowerShell\newre\newRe\Report\Test" -Value $final -Encoding unicode
can somebody help me out to solve it.
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
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!
If it works
GREAT! Saved my week \o/
Thanks @Anonymous
Yes, This worked. Because of this so much time is saved. Don't know how to thank you.
This worked! Thanks so much! It saved me hours of having to rebuild the file
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).
This is what worked for me.
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;
}
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.
I don't believe that code is needed if you make edits with Notepad ++ and not Notepad. I kept getting a corrupt file despite thinking I'd followed the instructions exactly, then I came across this and realized Notepad was the culprit (and I later noted that the instructions above explicity say in all caps that it's VERY IMPORTANT to use Notepad ++ to make edits, yet I had somehow overlooked them 😀).
I hope this is what is causing your issue as well!
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.
Hey,
I tried your solution, it's working great !
many thanks !
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.
Try deleting the Security Bindings file rather than removing this code.
Also, when you say zipping the file... See my comment above. The extracted file should not be re-zipped. Instead, the extracted Layout file should be updated and then copied into the original .zip folder (Delete Security Bindings file from here). This should then be renamed back to .pbix
Its doen´t works for me
Sorry, it´s doesn´t work for me
Hey,
Its working!! thank you.
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.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
114 | |
94 | |
90 | |
35 | |
35 |
User | Count |
---|---|
154 | |
100 | |
82 | |
63 | |
53 |