Convert CSV Files and CSV Data to a Microsoft Excel (XLSX) File

November 9th 2023
Back to all blogs

Back in early 2020 we released the ‘Convert Excel‘ action for Power Automate, which provides the capability to convert spreadsheet file formats to another format. For example, XLS to XLSX, CSV to PDF, CSV to XLSX, etc. The following post provides some basic examples: Convert Excel and CSV Files in Power Automate. Over the past few months, we’ve received several support tickets and multiple queries on the Power Automate forums asking how CSV files and CSV data can be converted into a Microsoft Excel (XLSX) file, and in this post, we’re going to cover both scenarios.

Video Guide: Convert CSV Files and CSV Data to a Microsoft Excel (XLSX) File

What’s the difference between CSV data and a CSV file?

It is very important to distinguish whether you are working with a file or just data, as Power Automate handles these differently. Power Automate exchanges files as ‘File Content’ properties which contain a binary file encoded in base64 format, thus sending a CSV file would look similar to Flow Configuration:

The Input data sent to the Encodian action:

Compare this with CSV Data:

The Input data sent to the Encodian action:

Now, typically, you do not need to worry about whether you’re passing plain text data or a base64 encoded file, as Power Automate contains automated data formatting capabilities which dynamically send/receive data in the correct format pertaining to the data type of the sending / receiving properties, however upon occasion it may be beneficial to forcefully apply the data type by converting plain text data to a base64 encoded file to avoid data processing issues.

Tutorial: Convert CSV Data to a Microsoft Excel (XLSX) File

Building upon the previous example, I’ll update the flow so that the ‘CSV Data‘ string variable is forcefully converted to a base64 encoded file and add Microsoft Excel (XLSX file) created by the ‘Convert Excel‘ action to OneDrive. 1. Update the ‘Convert Excel‘ action 1.a. File Content: Remove the existing ‘CSV Data‘ string variable before re-adding wrapped within the base64() expression

2. Add the OneDrive ‘Create File‘ action

2.a. Folder Path: Select the location to store the file

2.b. File Name: Select the ‘Filename‘ property provided by the Encodian ‘Convert Excel‘ action

2.c. File Content: Select the ‘File Content‘ property provided by the Encodian ‘Convert Excel‘ action

The Microsoft XLSX file created from the CSV Data provided:

Tutorial: Convert a CSV File to a Microsoft Excel (XLSX) File

Building upon the previous example, I’ll update the flow so that the Microsoft Excel (XLSX file) created by the ‘Convert Excel‘ action is added to OneDrive. The initial flow is configured as follows: a ‘File Content‘ property representing the CSV file is selected when the flow is triggered. Noting the file could come from any source (OneDrive, HTTP, SharePoint, Teams, Box, Azure Storage, etc), you just need to pass the ‘File Content’ property to the Encodian ‘Convert Excel‘ action.

2. Add the OneDrive ‘Create File‘ action

2.a. Folder Path: Select the location to store the file

2.b. File Name: Select the ‘Filename‘ property provided by the Encodian ‘Convert Excel‘ action

2.c. File Content: Select the ‘File Content‘ property provided by the Encodian ‘Convert Excel‘ action

The Microsoft XLSX file was created from the CSV file provided:

Final thoughts…

Hopefully, this post will help you to build solutions converting CSV files and data using our ‘Convert Excel‘ action. If you have any technical queries, please visit our customer support portal.

We hope you’ve found this helpful guide. As ever, please share any feedback or comments. All are welcome!

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...