How to Get Cell Styles from an Excel Workbook in Power Automate

Cloudmersive
4 min readNov 19, 2024

--

In Excel, applying Cell Styles to rows & cells can be an aesthetic choice, and it can also be a practical way of visually categorizing content — such as denoting Good, Bad, or Neutral cell values.

By programmatically extracting structured Cell Style information from the styles.xml file in XLSX file structure, we can easily reapply styles to other Excel documents, and we can even make dynamic flow decisions based on a workbook’s color-coding.

{
"Successful": true,
"CellStyles": [
{
"Path": "[root]:[5](cellStyles):[0](cellStyle)",
"Name": "60% - Accent1",
"FormatID": 4,
"BuiltInID": 32
},
{
"Path": "[root]:[5](cellStyles):[1](cellStyle)",
"Name": "Bad",
"FormatID": 1,
"BuiltInID": 27
},
{
"Path": "[root]:[5](cellStyles):[2](cellStyle)",
"Name": "Good",
"FormatID": 2,
"BuiltInID": 26
},
{
"Path": "[root]:[5](cellStyles):[3](cellStyle)",
"Name": "Neutral",
"FormatID": 3,
"BuiltInID": 28
}
]
}

Thanks to Power Automate, we can build workflows to extract Cell Styles without writing a line of code.

Get Cell Styles in Power Automate

In this article, we’ll walk through a quick example flow in Power Automate that uses the Cloudmersive Document Conversion connector to get Cell Style information from an example workbook.

The example workbook I’ll be using in this walkthrough contains several Themed Cell Styles and several Good, Bad, and Neutral Cell Styles.

We’ll build an instant cloud flow in this context so we can easily control our data when we run our test later on.

To begin, we’ll use a Get file content action to grab our example Excel file.

Next, we’ll add a new action, and we’ll search for Cloudmersive connectors. We’ll locate the Cloudmersive Document Conversion connector (this has a green logo), and we’ll then click “See more” to view the actions list.

From here, we’ll CTRL+F search for an action called Get styles from a Excel XLSX spreadsheet, worksheet, and we’ll select it once we find it.

If it’s our first time using this Cloudmersive connector, we’ll need to create and authorize our connection before we can begin configuring our API request. To do that, we’ll need a free Cloudmersive API key, and we can get one by visiting the Cloudmersive website & creating a free account. Free API keys allow a monthly limit of 800 API calls (this limit resets each month in perpetuity).

After we successfully create our connection, we’ll click “Show all” to view the advanced parameters. We’ll then enter our Excel workbook’s dynamic content bytes in the Input/InputFileBytes field (we’ll ignore the Input/InputFileUrl parameter in this context).

Since we’re performing a simple GET request, we’ll save our flow now and run it as it is.

We’ll then click on the Get styles action, scroll down to Outputs, and click Show raw outputs to view the entire response.

In our response body, we’ll find a CellStyles array which contains the Path, Name, FormatID, and BuiltInID for each Cell Style used in our document.

Thanks to the structure of this array, it’s easy to take dynamic flow actions based on a document’s Cell Style values. We could, for example, design a flow to flag Excel documents containing the “Bad” Cell Style.

We can also easily use this action in conjunction with the other Cloudmersive Document Conversion connector actions designed to interact with Excel documents.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet