How to Create Formatted Text Lines from Excel or Word Tables
Question details
The user needs to transform rows of table data (such as device names and IP addresses) into specific, formatted text sentences without manually copying and pasting values.

- Product
- Word, Excel
- Device & OS
- not provided
- Scenario
- Generating command lines or structured sentences dynamically from tabular data.
- Observed behavior
- Instead of raw table cells, the desired output is a continuous list of strings where static text surrounds dynamic cell values from each row.
Ensure your table has clear column headers (e.g., 'Name', 'IP Address', 'Network') and contains no merged cells, as this will prevent errors during the automated text conversion process.
Use Directory Mail Merge in Word
The most efficient way to generate customized sentences from a table is by using Word's Mail Merge feature set to the Directory document type.
A Directory Mail Merge allows you to create a continuous list of items on a single page, rather than generating a new page or document for every row in your table. This is perfect for compiling command lines or structured logs.
Create a blank Word document. Go to the 'Mailings' tab, click 'Start Mail Merge', and select 'Directory' from the dropdown menu.
Click 'Select Recipients' and choose 'Use an Existing List'. Browse your computer to locate and open the Excel or Word file containing your table.
Type your static text into the document (e.g., 'allow ' and ' address '). Use the 'Insert Merge Field' button on the ribbon to place the corresponding variables between your text, resulting in a format like: allow {MERGEFIELD name} address {MERGEFIELD ip} register {MERGEFIELD network}.
Click 'Finish & Merge' and select 'Edit Individual Documents'. Choose 'All' and click 'OK' to generate your continuous list of formatted text lines.

Use Excel Formulas for Concatenation
If your data is already housed in an Excel spreadsheet, you can use formulas to stitch static text strings and cell references together instantly.
Convert Table to Text in Word
Use Word's built-in table conversion tool if you simply need to separate column values with a specific text string or character.
Easily Transform Table Data into Text with WPS Office
WPS Office provides robust Mail Merge tools and advanced spreadsheet functions to seamlessly turn your tabular data into structured text lines. Highly compatible with Microsoft formats, it makes bulk data transformation effortless.
- 1. Prepare Data in WPS Spreadsheet: Open your data file in WPS Spreadsheet to ensure your columns are organized and headers are clearly labeled.
- 2. Start Mail Merge in WPS Writer: Create a new document in WPS Writer, navigate to the 'References' or 'Mailings' tab, and select 'Mail Merge'.
- 3. Connect and Insert Fields: Click 'Open Data Source' to connect your spreadsheet. Type your static text and use 'Insert Merge Field' to insert your table columns.
- 4. Generate Final Text: Click 'Merge to New Document' to output all your data rows as a continuous list of formatted text.

Frequently Asked Questions
Can I format table data into text without using Mail Merge?
Yes. If your data is in an Excel or WPS Spreadsheet, you can use the CONCATENATE function or the '&' symbol to stitch together static text strings and dynamic cell values into a single line.
Why is my Mail Merge outputting on separate pages instead of a single list?
This happens if you use the standard 'Letters' merge type instead of 'Directory'. Selecting 'Directory' (or 'Catalog' in older versions) ensures that each row's data is placed consecutively on the same page.
How do I deal with very complex text transformations?
For highly complex transformations, conditional logic, or massive data sets, writing a short script using Python (with libraries like pandas) or utilizing advanced Excel VBA macros might be more efficient than basic Mail Merge.




