Holly has attended:
PowerPoint Intermediate Advanced course
Power Automate Introduction course
Power automate convert excel attachment to csv before saving on
Hi I have set up a power automate flow for an email attachment to save to a sharepoint location when it arrives. This is functioning, however I want to put in a step to save the file as xlsx rather than csv. I'm using the step in flow but the file keeps saving as csv.
RE: Power automate convert excel attachment to csv before saving
Hi Holly,
Thank you for the forum question.
It sounds like your Power Automate flow is currently saving the email attachment in its original format (CSV), and you want to convert it to XLSX before saving it to SharePoint.
Here’s how you can achieve that:
Steps to Convert CSV to XLSX in Power Automate
Trigger: When a new email arrives with an attachment.
Condition: Check if the attachment is a .csv file.
Get Attachment Content: Use the "Get Attachment Content" action.
Create File (Temporary): Save the CSV file temporarily in OneDrive or SharePoint.
Convert CSV to Excel:
Use the "Create CSV Table" and "Create Excel File" actions (Premium).
Or use Excel Online (Business) connector:
Create a new Excel file.
Use "Add a row into a table" to populate it with CSV data.
Save as XLSX: Save the new Excel file to your desired SharePoint location.
Delete Temporary Files (optional): Clean up any temporary files created.
Common Pitfall
If you're using "Create file" and just changing the extension to .xlsx, it will still be a CSV file in content. You need to actually convert the content into Excel format.
Alternative: Use Power Automate Desktop
If you have access to Power Automate Desktop, you can:
Download the attachment.
Open it in Excel.
Save it as .xlsx.
Upload it to SharePoint.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Power automate convert excel attachment to csv before saving
is there a way to do this without creating a temp file? I'm struggling a little to follow the instructions
RE: Power automate convert excel attachment to csv before saving
Hi Holly,
Yes, you can convert a CSV email attachment to XLSX in Power Automate without creating a temporary file, but it requires a bit of clever use of built-in actions. Here's a simplified version of how to do it entirely in the cloud, using Excel Online (Business) and Office Scripts (if needed):
Simplified Cloud-Only Flow (No Temp File)
Prerequisites:
The attachment is a CSV file.
You have access to Excel Online (Business).
You have a SharePoint or OneDrive location to store the final XLSX file.
Flow Outline:
Trigger: When a new email arrives (with attachment).
Condition: If attachment name ends with .csv.
Get Attachment Content.
Create a New Excel File (XLSX) in SharePoint or OneDrive.
Use Excel Online (Business):
Create a table in the new Excel file.
Use "Add a row into a table" to populate it with the CSV data.
Done: The file is now a proper .xlsx format.
Challenge:
Power Automate does not natively parse CSV into rows/columns. You’ll need to:
Use "Compose" to split the CSV content by line (split(body, '\n'))
Then split each line by comma to get columns.
Loop through each line and use "Add a row into a table".
Easier Option: Use Office Script (Recommended)
If you're comfortable using Office Scripts, you can:
Upload the CSV content into a new Excel file.
Run a script to parse the CSV and convert it to a table.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector