How to Validate Excel Documents in Power Automate

Cloudmersive
4 min readDec 9, 2024

--

When we work with a high volume of Excel documents, we might expect to encounter a few workbooks with errors — and when that happens, we’ll want to know right away.

Our workbooks can have corruption errors, unexpected password protection measures (sometimes a sign of malicious activity), invalid formatting or broken formulas, and, at the extreme end of the spectrum, issues related to Macros (an even more worrying sign of malicious activity).

Validate Excel Documents in Power Automate

Thankfully, in Power Automate, we can validate our Excel documents easily using the Cloudmersive Document Conversion connector.

The Document Conversion connector library carries a specialized Excel validation API that checks XLSX workbooks for numerous possible errors and warnings, leaving us with the information we need to prevent downstream stakeholders from accessing invalid documents and causing potential problems (or unwittingly triggering attacks) in their system.

To see this API in action, we’ll build a quick instant cloud flow in Power Automate.

We’ll first grab a test Excel document from our system. In my example, I’ll be using text file that was saved to my system with an .xlsx extension. This makes the file invalid — though it appears valid at first glance in my SharePoint folder.

Next, we’ll add a new action and search for the Cloudmersive Document Conversion connector.

Once we find it, we’ll click “See more” to view the full actions list, and from there, we’ll search for an action called Validate a Excel document (XLSX).

To use this action (or any other Document Conversion action), we’ll first need to create and authorize our third-party app connection.

In this case, we’ll need a Cloudmersive API key to accomplish that. We can get one for free by visiting the Cloudmersive website and creating a free account (free API keys allow up to 800 API calls per month with zero additional commitments).

Once we’ve finished creating and authorizing our connection, we’ll provide our file content and file name (note — this doesn’t have to be the real file name) in our two request parameters.

Now we’ll save our flow and run a quick test.

When we open our Validate Excel action, we’ll find our response object in the Outputs section.

If we tested with a (safe) invalid file like I did, we’ll likely get a generic DocumentIsValid: false value in our API response body without any error description.

My test file didn’t have any serious corruption issues — it was just a text file saved with an improper extension. However, if we test Excel files with more dangerous errors or corruptions, we’ll find those errors described and documented in a nested ErrorsAndWarnings array (as shown in the full JSON response model below).

{
"DocumentIsValid": true,
"PasswordProtected": true,
"ErrorCount": 0,
"WarningCount": 0,
"ErrorsAndWarnings": [
{
"Description": "string",
"Path": "string",
"Uri": "string",
"IsError": true
}
]
}

It’s a good idea to validate Excel documents before automatically sharing or processing them in downstream flow actions. That will prevent sending broken files to flow stakeholders and ensure other Excel processing APIs only attempt to operate on valid XLSX workbooks.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet