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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JoeAnalyst
Frequent Visitor

We were unable to load this Excel file because we couldn't understand its format.

Hi,

I have a automated solution in place about 10 months but few days ago, the scheduled refresh of the report published to Powerbi Service started to not finish the refresh and stooppped on error: "DataFormat.Error: We were unable to load this Excel file because we couldn't understand its format. File contains corrupted data.. Microsoft.Data.Mashup.ErrorCode = 10942. ;We were unable to load this Excel file because we couldn't understand its format. File contains corrupted data.. The exception was raised by the IDbCommand interface. ".

The solution uses scheduled exports from the company application , the exported files have xlsx format and are saved using Power Automate to the sharepoint folder. The exported data file is not corrupted, it has no password, sensitivity label and it seems it did not change formating at all (I compared older exports = looked the same). I tried many times to export file, change data in the report. The powerBI desktop works fine with that xlsx fomat, I can reload data, all steps in power query work. I tried to republish to the other workspace but no change. The scheduled refresh on service simply stopps on the error message. It worked I think until Friday 13th 2025 (the date? :-). I have noticed new PowerBI version was released on June 10th with some new features about sensitivity lableling but this should not be the case. Why does it work in Dektop but not after publish? Any good advice from anyone? Thank you in advance.

1 ACCEPTED SOLUTION
fr_jc
Advocate II
Advocate II

@JoeAnalyst  Managed to get a work around which works for me by running an empty office script in the power automate flow to act as an open and save.  

After the create file action, use an excel Run Script action.

function main(workbook: ExcelScript.Workbook) {
  // This script doesn't need to make any explicit changes or call a 'save' method.
  
  // You can add a simple log to confirm it ran if you wish, but it's not strictly necessary.
  console.log("Office Script ran successfully for workbook: " + workbook.getName());
}

 

View solution in original post

42 REPLIES 42
mcasetellano
Regular Visitor

I don't understand the root of the problem. My files come from Service Now. Some of the users here don't use a flow from Power Automate but get the same error, so the flow is not the problem. In fact, my flows run successfully and I opened the files and confirmed the data is updated. How do we raise a ticket with Microsoft? 

 

Hi, the power automate flow is not the problem, in this case it is the advantage to use flow because there is only one working workaround - to add to the flow one small step that after file is saved to the sharepoint it will open/close file automaticaly and it does all the magic. It is enouch open and close (with some void action) and the structure of the xlsx file will be corrected. Power BI is then able to load the file as before. I am not an expert on the xlsx versions but the xlsx export that I use from other sources are ok, only SalesForce generates these 'incorrect' files. I dont know whether Microsoft is troublemaker here, yes, they changed something on PowerBI side on June 10th but if other xlsx versions are fine, maybe the SalesForce app shoud be fixed instead. Anyway the workaround works for now, you can find the guide here in this discussion how to add one more step "Run Script" to the flow with dynamic way how to get file ID so it shoud work olso on your side. From your first post I understood that you already impelented it but it is not working, now it seems you did not yet, so just try to impelent it and you should be safe.

Yes I tend to aggree with "I dont know whether Microsoft is troublemaker here." 
I too am no expert but if you look at the Content_Types xml on a new file and an older xlsx file you where getting before the problem started you get,

fr_jc_0-1750894128535.png

Look at one from when the problem started and you get a whole lot of <overide> custom entries.

fr_jc_1-1750894188844.png

I'd suspect that this is where the query conncetors excel loader fails to read and understand the format.

The open and save action is simply rebuilding the xml back to the orignal state where the excel loader can understand it.


mcasetellano
Regular Visitor

I am experiencing the same problem. The excel files are not corrupted. I have two power automate flows to update the files on sharepoint, one triggers when I get the email with the data extract and another flow triggers daily 4.30am as a backup. The flows run successfuly but when Bi runs the schedule refreshes it fails and I get the same error described by JoeAnalys

Hi, Can you see the files are really updated by the flow? I am able to see in the file Version History that the flow did its job and created new version and also the size of the file is a bit higher (about 200kB). From when I implemneted this workaround about a week ago I havo no more issues. I have 10 files updated daily, all work perfectly. 

Hi Joe, thanks for your prompt response. Yes, I can see the files get updated. I will try implementing the work around you used but it is a lot of files, would prefer that whatever is causing this, got fixed. I had no problems before, my report have been running and refreshing with no issues for months. 

pb1051
Advocate II
Advocate II

The script solution didn't work for me. Even the action doesn't recognize the file type. I'm submitting a ticket.

leaves5887
Regular Visitor

Is there an issue reported for this? We are experiencing the same issue and would like to report it to Microsoft.

samtrapp
New Member

I am also having this same issue, running a scheduled Salesforce export as an Excel file, Power Automate pulls it out of Outlook and creates a SharePoint file source for Power Bi. Issue started on June 7, 2025 with no issues for the previous 2 months. 

gbroughton
New Member

Exact same problem for me, also Salesforce data.

Poojara_D12
Super User
Super User

Hi @JoeAnalyst 

You're encountering a frustrating issue where a previously stable Power BI report—automated for over 10 months—suddenly fails to refresh in the Power BI Service, despite working flawlessly in Power BI Desktop. The error message points to a DataFormat.Error with code 10942, indicating that the Excel file is seen as having a corrupted format or unreadable structure. However, you’ve confirmed that the file is structurally sound, has no password protection or sensitivity labels, and opens fine in Power BI Desktop, which suggests the file itself is not actually corrupted. The XLSX files are generated via scheduled exports from your company application and stored on SharePoint via Power Automate, and nothing significant has changed in the export logic or formatting.

 

Given that everything works in Desktop but fails in the Service, the issue likely stems from how the Power BI Service is attempting to parse or access the Excel file in the cloud environment. A key difference could be the version of the mashup engine or stricter validation in the Service following the June 10th Power BI update, which may have introduced changes to how the service handles Excel files, possibly around metadata, internal structure, or SharePoint file locking. One possible root cause is that the exported Excel file—though appearing normal—might be slightly malformed or still being written or locked when Power BI Service attempts to access it, especially if the refresh schedule overlaps closely with file generation.

 

To mitigate this, try the following steps: (1) introduce a buffer time between file export and dataset refresh, (2) check if opening and saving the Excel file manually (e.g., via Excel desktop or online) "fixes" the issue, and (3) consider using CSV format instead, which is less error-prone in automated workflows. If the issue persists, it might be worth opening a support case with Microsoft—even if you're on Power BI Pro, this type of regression affecting file compatibility might be considered for escalation if enough users report it.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Our first failure was on June 11th. So this is align with what you have said in your post.

 

I tried a delay action in my Power Automate, but this did not solve the issue.

 

I have attempted the script solution that @JoeAnalyst suggested, but my trigger is a SharePoint "When a file is created or modifed (properties only)" and the script doesn't work for us. 

 

We can open the file manually and make a small change and save the file and then Power BI service can read the file properly.

 

I have now opened a ticket under our Pro/Premium support.

 

All to say, you are most likely right in the root cause.

fr_jc
Advocate II
Advocate II

@JoeAnalyst  Managed to get a work around which works for me by running an empty office script in the power automate flow to act as an open and save.  

After the create file action, use an excel Run Script action.

function main(workbook: ExcelScript.Workbook) {
  // This script doesn't need to make any explicit changes or call a 'save' method.
  
  // You can add a simple log to confirm it ran if you wish, but it's not strictly necessary.
  console.log("Office Script ran successfully for workbook: " + workbook.getName());
}

 

Could you please describe the flow in more detail? Preferably with a screenshot? Unfortunately, I don't know where I need to enter the code after adding the additional action.

@Olze-Kay  
start with Excel and go to the Automate tab and click on ‘New Script’

fr_jc_0-1750227111401.png

 

In the editor that will pop up on the left, delete everything and replace it with,

function main(workbook: ExcelScript.Workbook) {}

then save the script with a name of your choice, the script will save in your office scripts folder of your OneDrive

 

fr_jc_1-1750227237566.png

 

In your power automate flow, add a new activity, Excel Online (Business) Run script after your create file action which is likely a SharePoint or OneDrive create file action.

Fill in the four fields for the Runs script action as,

 

Location: the location where you created the file, choose OneDrive for business if you created the file on your one drive, else the sharepoint location you created it.
Document Library: should be Documents

File: use dynamic content and add body/Id     when you over it should show something like the below,  assuming your previous create file action is labelled Create file,

outputs('Create_file')?['body/Id']

 

Script: you should find the script you just created in here, select that one.

fr_jc_3-1750227504057.png

 

That is it..  good luck..

Hi @fr_jc ,

I'm facing same issue and did change my flow as per your screenshot. However, i'm still encounter the error at Run Script where "The file format is not recognized". My flow is trigger when receive an email with attachment (File from Salesforce) and save in SharePoint Folder. is there any workaround can be followed?

Hi @90_eryka 

assuming your saving action is storing an exact copy of the attachment, that copy will still have the custom overide entries in the xml.  at this point if you open it and save it the power query connector will read it ok.  This is where the run script action automates that for you.

your flow should look something like the below, the for each loop will iterate through all the emails attachments.

Confirm that what the flow saves in your sharepoint is actualy what you are expecting, the xlsx file.

Your condition logic should only select the attachment you are after, you can add something like,  item()?['name']     ends with    .xlsx    or use the exact name of the attachment to be more precise. 

fr_jc_1-1753154822155.png

If there are images like logo's ect in the signature, these are also attachments, make sure you are not picking those up and storing them.  For example if the body of the email had 2 images in the signature and one excel attachment, without the logic your create item will save each one with the same name in the same location so only the last one will exist which could actually be an image which is causing your problem.

fr_jc_0-1753153788003.png

 

Hi @fr_jc ,

I’ve confirmed that there is no extra image, and I’m storing the exact file as per the attachment.

I’ve also added the condition you suggested, along with an additional step to delay the flow by 5 seconds (as recommended by Co-pilot) to ensure the file is fully created before the script runs. However, the Run Script step still fails. Is there any step I might be missing?

Thank you.

 

Screenshot 2025-07-22 151146.png

@90_eryka that looks to be right from what I can see with actions.  
can you maybe share the actual error description that you are getting?

Just checking on the Run Script actions location and doc library.
The location should be the same site you used in the previous create file action

if you look at the code view you should see the source name for the run script should match the dataset name of the create file. 

fr_jc_1-1753188754382.png

 

The Document library normaly defaults to Documents, I see you have Analytics.  Did you slect this from the availble drop down or did you add as a custom value?

 

 

 

 

Hi @fr_jc ,

 

The error message is "Flow run failed". My script in excel is 

"function main(workbook: ExcelScript.Workbook) { }". Should we modified this?
 
Here is my code view:
90_eryka_2-1753252935572.png

Also I did select "Documents" for Document Library but the flow still failed

90_eryka_3-1753253037245.png

 

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.