Fix Power Automate Unrecognized Excel File Extension Error
Question details
The user needs to resolve an intermittent error in Power Automate where an Excel file's format or extension is not recognized when attempting to run an Office Script.

- Product
- Power Automate & Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running an Office Script on a SharePoint Excel file via a Power Automate flow.
- Observed behavior
- The flow intermittently fails, reporting that the file format or extension is not valid or unrecognized by the system.
Ensure that the target Excel file is saved in the .xlsx format, as older formats like .xls are not supported by Office Scripts in Power Automate.
Use Dynamic File Identifiers and Extension Checks
Prevent extension errors by configuring the flow to verify the .xlsx format and using dynamic file identifiers instead of hardcoded file names.
When a Power Automate trigger receives multiple file types from a SharePoint folder, it may attempt to run an Excel-specific Office Script on non-Excel files. By filtering for the correct extension and dynamically targeting the file's unique identifier, you can eliminate format recognition errors.
Before the 'Run script' action, insert a 'Condition' control. Set it to check if the incoming file name ends with '.xlsx' to ensure the script only triggers for valid Excel files.
In the 'Run script' action, click on the File parameter field. Instead of typing a fixed name like Book.xlsx, select the dynamic '{identifier}' token from the dynamic content menu.
If your flow processes multiple files inside an 'Apply to each' loop, use a 'Compose' action. Enter the expression items('Apply_to_each')?['{identifier}'] to safely reference the dynamic file identifier.
If your flow is designed to only process a single file per trigger, drag your actions outside the 'Apply to each' block and delete the loop. This simplifies the flow and reduces variable reference errors.

Need a Lightweight Alternative for Your Spreadsheets? Try WPS Office
If you frequently manage spreadsheets and are looking for a fast, reliable, and completely free alternative to Microsoft Office, WPS Office is an excellent choice. It offers seamless format compatibility and a familiar interface for smooth workflow transitions.

Frequently Asked Questions
Why does Power Automate say my Excel file extension is not valid?
This usually happens if the file parameter in your 'Run script' action uses a static name that doesn't match the dynamically changing file, or if the flow encounters a non-Excel file (like .doc or .ppt) in the same SharePoint folder without filtering it first.
Can I run Office Scripts on older .xls files in Power Automate?
No, Office Scripts only support modern Excel file formats like .xlsx and .xlsm. You must convert older .xls files to .xlsx before attempting to run an Office Script on them.
How do I extract the file extension in a Power Automate flow?
You can use an expression in a Compose action, such as last(split(triggerOutputs()?['body/{FilenameWithExtension}'], '.')), to extract just the file extension for your condition checks.




