Sheet-to-Doc Placeholder System Detailed Explanation: Automatically Fill Data into Specific Positions in Word

In Sheet-to-Doc, placeholders are the bridge connecting Excel data and Word templates. By using different types of placeholders, we can automatically fill data into specific positions in Word templates and create personalized documents. Today, I will detailedly introduce Sheet-to-Doc’s placeholder system to help you master the skills of using various placeholders.


What are Placeholders?

Placeholders are positions marked with special syntax in Word templates, and the Sheet-to-Doc tool will replace these positions with corresponding values from Excel data. The basic format of placeholders is {placeholder name}, and the tool will process them differently based on the type and name of the placeholders.


1. Data Placeholders: The Most Basic Placeholder Type

Data placeholders are the most commonly used placeholder type, used to fill a single data value from Excel into a Word template.

Syntax

1
{column name}

Usage Method

  1. Define column names in Excel table, such as “Name”, “Age”, “Email”, etc.
  2. Add placeholders in Word template using the format {column name}
  3. The tool will automatically replace the placeholders with corresponding column values from Excel

Example

Excel Data

Name Age Email
Zhang San 25 [email protected]
Li Si 30 [email protected]

Word Template

1
2
3
4
5
Personal Information Form

Name: {Name}
Age: {Age}
Email: {Email}

Generated Document

1
2
3
4
5
Personal Information Form

Name: Zhang San
Age: 25
Email: [email protected]

2. Image Placeholders: Insert Dynamic Images in Word

Image placeholders are used to dynamically insert images into Word documents. Using image placeholders, you can insert different images into generated documents based on image names in Excel data.

Syntax

1
2
{@image column name | _inline_image:width:height}
{@image column name | _block_image:width:height}

Usage Instructions

  • @image column name: Image placeholders must start with @, image column name is the column name in Excel that stores image names
  • _inline_image: Inline image, closely integrated with text
  • _block_image: Block-level image, independent of paragraphs
  • width and height: Optional parameters, specify image width and height (in centimeters)

Usage Method

  1. Add a column in Excel table to store image names
  2. Add image placeholders in Word template using the format {@image column name | _inline_image} or {@image column name | _block_image}
  3. Upload image files to the Sheet-to-Doc tool
  4. The tool will insert the corresponding images into the document based on image names in Excel data

Example

Excel Data

Name Product Product Image
Zhang San Watch watch.png
Li Si Power Bank batterybank.png

Word Template

1
2
3
4
5
6
7
8
9
10
11
Product Recommendation

Dear Mr./Ms. {Name}:

We recommend the following products for you:

Product Name: {Product}
Product Image:
{@Product Image | _inline_image}

Thank you for your attention!

Generated Document

1
2
3
4
5
6
7
8
9
10
11
Product Recommendation

Dear Mr. Zhang San:

We recommend the following products for you:

Product Name: Watch
Product Image:
[watch.png image] (Note: This is an image, not displayed in this blog article)

Thank you for your attention!

3. Loop Placeholders: Handle Repeated Data

Loop placeholders are used to handle multiple rows of data in Excel and realize repeated content generation. Sheet-to-Doc supports two types of loop placeholders.

3.1 Loop Placeholder 1: Fixed Syntax, Only Supports Generation Mode 2

Syntax

1
{#data}...{/data}

3.1.1 Usage Instructions

  • Fixed syntax, cannot customize name
  • Only takes effect in generation mode 2 (single document)
  • Used to generate all data into one document

3.1.2 Example

Excel Data

Name Age Gender
Zhang San 25 Male
Li Si 30 Female

Word Template

1
2
3
{#data}
{Name},{Age},{Gender}.
{/data}

Generated Document

1
2
Zhang San,25,Male.
Li Si,30,Female.

3.2 Loop Placeholder 2: General Version, Supports Generation Modes 1 and 2

Syntax

1
{#loop name}...{/loop name}

3.2.1 Usage Instructions

  • Can customize loop name (cannot be data)
  • Supports generation modes 1 and 2
  • Requires special processing of Excel data (adding prefix)

3.2.2 Example

Excel Data (needs prefix)

info.Name info.Age info.Gender
Zhang San 25 Male
Li Si 30 Female

Word Template (Generation Mode 1)

1
2
3
{#info}
{Name},{Age},{Gender}.
{/info}

Word Template (Generation Mode 2)

1
2
3
4
5
{#data}
{#info}
{Name},{Age},{Gender}.
{/info}
{/data}

5. Conditional Placeholders: Display Content Based on Conditions

Conditional placeholders are used to display different content based on values in Excel data. Sheet-to-Doc supports three types of conditional placeholders.

5.1 Conditional Placeholder 1: True/False Judgment

Syntax

1
{#condition}display content{/condition}

Usage Instructions

  • When the condition column value is true, display content
  • When the condition column value is false, do not display content

Example

Excel Data

Name Age Awarded
Zhang San 25 true
Li Si 30 false

Word Template

1
2
3
4
5
{#data}
{#Awarded}
{Name} has won an award!
{/Awarded}
{/data}

Generated Document

1
Zhang San has won an award!

5.2 Conditional Placeholder 2: Equal/Not Equal Judgment

Syntax

1
2
{#condition == "value"}display content{/}
{#condition != "value"}display content{/}

Usage Instructions

  • Supports string and number comparison
  • Strings need to be wrapped in English double quotes
  • Numbers can be used directly without quotes

Example

Excel Data

Name Prize
Zhang San Watch
Li Si Power Bank

Word Template

1
2
3
4
5
6
7
8
9
{#data}
{Name} has won a {Prize}.
{#Prize == "Watch"}
This is a watch!
{/}
{#Prize == "Power Bank"}
This is a power bank!
{/}
{/data}

5.3 Conditional Placeholder 3: Size Comparison

Syntax

1
2
3
4
{#condition > value}display content{/}
{#condition >= value}display content{/}
{#condition < value}display content{/}
{#condition <= value}display content{/}

Usage Instructions

  • Used for numeric size comparison
  • Values do not need quotes

Example

Excel Data

Name Age
Zhang San 25
Li Si 35

Word Template

1
2
3
4
5
6
{#data}
{Name} is {Age} years old.
{#Age >= 30}
{Name} is 30 years old or above.
{/}
{/data}

Generated Document

1
2
3
Zhang San is 25 years old.
Li Si is 35 years old.
Li Si is 30 years old or above.

Best Practices for Using Placeholders

1. Keep Placeholder Names Consistent with Excel Column Names

Ensure that placeholder names in Word templates are completely consistent with column names in Excel tables, including case and spaces.

2. Use Clear Column Names

Choose concise and clear column names, avoiding overly complex or confusing names.

3. Test Placeholders

Before generating a large number of documents, test with a small amount of data to ensure that placeholders can be correctly replaced with corresponding data.

4. Utilize Data Comparison Function

Sheet-to-Doc provides a data comparison function that can help you find incorrect placeholders in templates. It is recommended to perform data comparison before generating documents each time.

5. Use Placeholders Nested

You can nest different types of placeholders, such as using data placeholders and conditional placeholders within loop placeholders, to create more complex document structures.


Summary

Sheet-to-Doc’s placeholder system is very powerful, supporting multiple types of placeholders, including data placeholders, image placeholders, loop placeholders, and conditional placeholders. By flexibly using these placeholders, you can create various complex document templates and realize automatic conversion from Excel to Word.

In the following series of articles, we will delve into advanced features of Sheet-to-Doc, including usage skills of loop placeholders, image processing, data format support, etc. Stay tuned!

微信二维码
Share