Convert CSV Files to Excel (xlsx format) in Power Automate

Published: 30 November 2021
on channel: Power GI
64,621
367

Learn how to leverage Power Automate's out of the box actions & Office Scripts to convert CSV documents into Excel (xlsx).

Check out this video (   • Read Raw Excel Data (unformatted xlsx...  ) if your source file is in XLSX format instead of CSV.

Code for the Office Script:
[starts]----------------------------------------------
function main(workbook: ExcelScript.Workbook, lineCSV: string[]) {
let selectedSheet = workbook.getActiveWorksheet();
const alllines = lineCSV;
let counter = 1;
for (let line of alllines) {
if (line.includes(",")) {
let items = line.split(",");
selectedSheet.getRange("A" + counter+":G"+counter).setValues([[items[0], items[1], items[2], items[3], items[4], items[5], items[6]]]);
counter++;
}
}
workbook.addTable(selectedSheet.getRange("A1:G" + counter), true).setName("ContactInfo");
}
[ends]----------------------------------------------

Follow the steps in this link if you don't see the "Automate" tab:
https://docs.microsoft.com/en-us/micr....

Please note that Office scripts will time out if you have more than 1000 rows to insert.

Questions? We can help! Contact us a [email protected]


Watch video Convert CSV Files to Excel (xlsx format) in Power Automate online without registration, duration hours minute second in high quality. This video was added by user Power GI 30 November 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 64,621 once and liked it 367 people.