VBA & Macro Problems

How to Convert CSV Data to an Excel Table with Office Scripts

Amos GikundaAmos Gikunda Nov 13, 2026 868 views

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.

How to Convert CSV Data to an Excel Table with Office Scripts
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the script editor

In Excel on the web, open the workbook, select the Automate tab, and click New Script.

2
Paste the CSV conversion code

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).

3
Run and save the script

Click Run to create the table on the active worksheet, then save the script with a recognizable name so Power Automate can call it.

Write and Run an Office Script to Convert CSV Text into an Excel Table
CSV data source: Replace the csvData string with the actual CSV content from your file or Power Automate input.
Free Microsoft Office alternative

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. 1. Open WPS Spreadsheets: Launch WPS Office, open WPS Spreadsheets, and create a new blank workbook.
  2. 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. 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.
Directly import CSV files into WPS Spreadsheets and convert them to formatted tablesFull compatibility with Microsoft Excel .xlsx and .xls filesFamiliar ribbon UI makes spreadsheet tasks easy without scriptingFree and lightweight Office suite for Windows, macOS, Linux, Android, and iOS
microsoft office alternative - wps office

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.