WPS Spreadsheet: Convert an Excel Range to SQL INSERT Values
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").
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.
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.
Select cell D2, enter ="("&CHAR(34)&A2&CHAR(34)&","&CHAR(34)&B2&CHAR(34)&","&CHAR(34)&C2&CHAR(34)&")", and press Enter.
Select D2 and drag the fill handle down through D4, or use Home > Fill > Down, to create one SQL tuple for each source row.
Select an empty cell such as D5 and enter =TEXTJOIN(",",TRUE,D2:D4). Press Enter to produce comma-separated SQL value groups.
Check the result for missing values, quotation marks, commas, and characters that need escaping before copying it into an SQL INSERT statement.
Generate SQL values with a single Microsoft 365-style formula
Use this option when your WPS Spreadsheet version supports LET, ARRAYTOTEXT, TEXTBEFORE, and TEXTAFTER and you want one formula for the complete range.
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. Open the workbook: Launch WPS Office, choose Spreadsheet, and open the workbook containing the Excel range.
- 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. Combine the generated rows: Use the TEXTJOIN function in an empty cell to join the helper-column results with commas.
- 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.

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.




