Data Import & Export

WPS Spreadsheet: Convert an Excel Range to SQL INSERT Values

Muhammad TalhaMuhammad Talha Nov 12, 2026 869 views

Question details

The user needs to convert values from an Excel range into comma-separated row groups that can be used in an SQL INSERT statement.

Product
WPS Spreadsheet
Device & OS
not provided
Scenario
An Excel range contains multiple rows and columns that must be formatted as SQL value tuples.
Observed behavior
The range values are still displayed as spreadsheet cells instead of SQL-ready groups such as ("v11","v12","v13"),("v21","v22","v23").
Before you start

Confirm the exact data range and whether the first row contains headers. Decide whether your database expects double-quoted or single-quoted text values before building the formula.

Solution 1Recommended

Use helper formulas in WPS Spreadsheet to build SQL value groups

Use this method when you want a clear, editable conversion for a three-column range and need to review each generated row before combining the results.

This example assumes the source data is in columns A:C, with records in rows 2:4. The first formula creates one SQL value group per row, and the second formula joins those groups with commas.

1
Create a row value formula

Select cell D2, enter ="("&CHAR(34)&A2&CHAR(34)&","&CHAR(34)&B2&CHAR(34)&","&CHAR(34)&C2&CHAR(34)&")", and press Enter.

2
Fill the formula down

Select D2 and drag the fill handle down through D4, or use Home > Fill > Down, to create one SQL tuple for each source row.

3
Join the row groups

Select an empty cell such as D5 and enter =TEXTJOIN(",",TRUE,D2:D4). Press Enter to produce comma-separated SQL value groups.

4
Review the generated text

Check the result for missing values, quotation marks, commas, and characters that need escaping before copying it into an SQL INSERT statement.

Adjust the quotation marks when needed: The example produces double-quoted values such as ("v11","v12","v13"). If your database requires single-quoted SQL string literals, replace CHAR(34) with CHAR(39), then escape any embedded quote characters in the source data.

Create SQL INSERT value text directly in WPS Spreadsheet

WPS Spreadsheet can format each Excel row as a SQL value tuple with a formula, fill the formula through the range, and combine the results with TEXTJOIN. This keeps the generated text easy to inspect and edit before it is used in a database query.

  1. 1. Open the workbook: Launch WPS Office, choose Spreadsheet, and open the workbook containing the Excel range.
  2. 2. Build each SQL row: In an empty helper column, enter the row formula using references to the source columns, then fill it down for all records.
  3. 3. Combine the generated rows: Use the TEXTJOIN function in an empty cell to join the helper-column results with commas.
  4. 4. Copy the SQL text: Review the generated value groups, select the output cell, and copy the text into the VALUES section of your SQL INSERT statement.
Convert multi-column spreadsheet rows into comma-separated SQL value groupsReview and correct each generated row before copying it to SQLUse familiar WPS Spreadsheet formulas without manual retypingOpen and edit Microsoft Excel XLS and XLSX files with strong format compatibility
microsoft office alternative - wps office

Frequently Asked Questions

Can I convert more than three Excel columns into SQL values?

Yes. Extend the row formula by adding another comma, CHAR(34), and the next cell reference, such as D2, for each additional column. Fill the revised formula down the full data set.

How do I combine all generated SQL rows into one string?

Place each row tuple in a helper column, then select an empty cell and use =TEXTJOIN(",",TRUE,D2:D4). Replace D2:D4 with the actual helper-column range.

What should I do if a cell contains a quotation mark?

Review and escape embedded quotation marks before using the output in SQL. You can use SUBSTITUTE in the row formula to replace an internal quote with the escaped form required by your database.

Can the formula include the SQL INSERT command automatically?

Yes. Put the generated values after a statement such as INSERT INTO table_name (column1,column2,column3) VALUES, and check the table name, column names, data types, and quoting rules before execution.