How to Convert CSV Data to an Excel Table with Office Scripts
Question details
The user needs an Office Script that reads CSV text, writes it to an Excel worksheet, converts the data into an Excel table, and prepares the table for a Power Automate email workflow.

- Product
- Microsoft Excel with Office Scripts and Power Automate
- Device & OS
- not provided
- Scenario
- Automating CSV-to-Excel table conversion and preparing the table for email workflows.
- Observed behavior
- A script is required to parse CSV rows and columns, write them to the active worksheet, and create a table from the used range.
Confirm that your CSV data uses a consistent delimiter and that the workbook is saved in a location where Office Scripts and Power Automate can access it.
Write and Run an Office Script to Convert CSV Text into an Excel Table
Use this method when you need a repeatable, scripted CSV-to-table conversion that can be called from Power Automate.
Office Scripts run in Excel on the web and can expose the resulting table to Power Automate. The script splits CSV text into rows and columns, writes values starting at A1, and creates a table from the used range.
In Excel on the web, open the workbook, select the Automate tab, and click New Script.
Replace the default code with an Office Script that splits csvData into rows and columns, writes each value with sheet.getCell(i, j).setValue(), and creates a table with sheet.addTable(sheet.getUsedRange().getAddress(), true).
Click Run to create the table on the active worksheet, then save the script with a recognizable name so Power Automate can call it.

Make Email Addresses Clickable After the Table Is Created
Use this follow-up if your email workflow requires live mailto hyperlinks instead of plain-text addresses.
Convert CSV Data to Excel Tables in WPS Office Without Office Scripts
WPS Office is a free, lightweight Microsoft Office alternative that opens, edits, and saves .xlsx files, imports CSV data directly into WPS Spreadsheets, and formats it as a table with a familiar ribbon interface—no Office Scripts or Power Automate required.
- 1. Open WPS Spreadsheets: Launch WPS Office, open WPS Spreadsheets, and create a new blank workbook.
- 2. Import the CSV file: Select Data > From Text/CSV, choose your CSV file, and complete the import with the delimiter that matches your data.
- 3. Format as a table and save: Select the imported range, click Insert > Table or use the Format as Table command, then save the file as .xlsx for Microsoft Excel compatibility.

Frequently Asked Questions
Can I run Office Scripts in WPS Office?
WPS Office does not support Microsoft Office Scripts or Power Automate. It supports VBA and JavaScript macros plus direct CSV import and table formatting in WPS Spreadsheets.
How do I convert CSV data to an Excel table without Office Scripts?
In WPS Spreadsheets, use Data > From Text/CSV to import the file, then select the imported range and choose Insert > Table. Save the workbook as .xlsx.
Does the Office Script automatically make email addresses clickable?
No. The script writes plain text values. Use =HYPERLINK("mailto:"&B2,B2) or right-click > Hyperlink to add clickable mailto links.
Can Power Automate run this Office Script and then send email?
Yes. Save the script in Excel on the web, then use the Run script action in Power Automate and continue with the resulting Excel table for your email workflow.
What should I do if my CSV uses semicolons or tabs?
Change the split delimiter in the script from a comma to the actual delimiter, or use WPS Spreadsheets' import dialog to specify semicolon, tab, or custom delimiters.




