web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert CSV files to E...
Power Automate
Unanswered

Convert CSV files to Excel workbooks - Office Scripts not working?

(0) ShareShare
ReportReport
Posted on by 2

I have been using Convert CSV files to Excel workbooks - Office Scripts | Microsoft Docs  tutorial to convert a csv to excel data in sharepoint. I have also tried in onedrive. My limiter seems to be in Office Scripts since I can't seem to make it beyond csv = csv.replace(/\r/g, "");

 

function main(workbook: ExcelScript.Workbook, csv: string) {
 
 let sheet = workbook.getWorksheet("Sheet1");

 // Remove any Windows \r characters.
 csv = csv.replace(/\r/g, "");

 // Split each line into a row.
 let rows = csv.split("\n");
 /*

 

 

I get the error  

Line 9: Cannot read properties of undefined (reading 'replace')

 

 

Categories:
I have the same question (0)
  • Yutao Huang Profile Picture
    Microsoft Employee on at

    Based on the error message, it feels to me the script input parameter "csv" is probably missing. Can you share a bit more about your flow? Where did you get the source CSV content? Did you pass this CSV content to the "Run script" action as a parameter for "csv"?

  • Bubulover Profile Picture
    32 on at

    Hi,

     

    I previously used the below video and it works for me.

     

    Convert CSV Files to Excel (xslx format) in Power Automate - Bing video

     

    Hoping it helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 308

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 226 Most Valuable Professional

Last 30 days Overall leaderboard