Sheet-to-Doc supports multiple data formats, including Excel, CSV, JSON, and JSONL. This extensive format support enables Sheet-to-Doc to adapt to different data sources and usage scenarios, enhancing the tool’s flexibility and applicability. Today, I will detailedly introduce the data formats supported by Sheet-to-Doc, helping you understand how to use different data formats to generate automated documents.
- Official Website: https://s.wtsolutions.cn/sheet-to-doc.html
- Download Page: https://sheet-to-doc.wtsolutions.cn/zh-cn/latest/Download.html
1. Excel Format: The Most Commonly Used Data Format
Excel is one of the most commonly used data formats and is also the default supported format of Sheet-to-Doc. Excel files have an intuitive table structure, are easy to edit and manage, and are suitable for most document generation scenarios.
Usage Method
- Create an Excel table with column names in the first row and data rows in subsequent rows
- Add placeholders in Word template using the format
{column name} - Directly copy Excel data or upload Excel files in the Sheet-to-Doc tool
- Generate documents
Example
| Name | Age | |
|---|---|---|
| Zhang San | 25 | [email protected] |
| Li Si | 30 | [email protected] |
2. CSV Format: Lightweight Data Format
CSV (Comma-Separated Values) is a lightweight data format that uses commas to separate different field values. CSV files have a small file size, are easy to transmit and process, and are suitable for large data volume scenarios.
Usage Method
- Create a CSV file with column names in the first row and data rows in subsequent rows, separated by commas
- Add placeholders in Word template using the format
{column name} - Upload CSV files or directly copy CSV content in the Sheet-to-Doc tool
- Generate documents
Example
1 | Name,Age,Email |
3. JSON Format: Structured Data Format
JSON (JavaScript Object Notation) is a lightweight structured data format that is easy for humans to read and write, and easy for machines to parse and generate. JSON format is suitable for processing complex nested data structures.
Usage Method
- Create a JSON file, store data in array format, with each object representing a row of data
- Add placeholders in Word template using the format
{field name} - Upload JSON files or directly copy JSON content in the Sheet-to-Doc tool
- Generate documents
Example
1 | [ |
Nested JSON Processing
Sheet-to-Doc supports processing nested JSON data, and you can use dots (.) to access nested fields.
Example
1 | [ |
In Word templates, you can use {Contact.Email} and {Contact.Phone} to access nested fields.
4. JSONL Format: Line-Delimited JSON Format
JSONL (JSON Lines) is a line-delimited JSON format, with one JSON object per line. JSONL format is suitable for processing large amounts of data because it can be processed line by line without loading the entire file into memory at once.
Usage Method
- Create a JSONL file with one JSON object per line
- Add placeholders in Word template using the format
{field name} - Upload JSONL files or directly copy JSONL content in the Sheet-to-Doc tool
- Generate documents
Example
1 | {"Name": "Zhang San", "Age": 25, "Email": "[email protected]"} |
Comparison of Different Data Formats
| Format | Advantages | Disadvantages | Suitable Scenarios |
|---|---|---|---|
| Excel | Intuitive and easy to edit, supports formulas and formatting | Large file size, slow processing speed | Small data volume, needs intuitive editing |
| CSV | Small file size, fast processing speed | Does not support formulas and formatting, error-prone | Large data volume, simple data structure |
| JSON | Supports complex nested structures, easy for machine processing | Poor readability, inconvenient to edit | Complex data structure, needs program generation |
| JSONL | Supports large data volume, line-by-line processing | Poor readability, does not support nested structures | Very large data volume, simple data structure |
Data Format Conversion Techniques
1. Excel to CSV
You can use Excel’s “Save As” function to convert Excel files to CSV format:
- Open the Excel file
- Click “File” → “Save As”
- Select “CSV (Comma Separated)” format
- Save the file
2. Excel to JSON
You can use online tools or programming languages to convert Excel files to JSON format:
- Online tools: Such as Convert Excel to JSON, Excel to JSON Converter, etc.
- Programming languages: Using Python’s pandas library, JavaScript’s xlsx library, etc.
3. JSON to CSV
You can use online tools or programming languages to convert JSON files to CSV format:
- Online tools: Such as Convert JSON to CSV, JSON to CSV Converter, etc.
- Programming languages: Using Python’s pandas library, JavaScript’s json2csv library, etc.
Best Practices for Using Data Formats
1. Choose Format Based on Data Volume
- Small data volume (<1000 rows): It is recommended to use Excel format, which is intuitive and easy to edit
- Medium data volume (1000-10000 rows): It is recommended to use CSV format, which has small file size and fast processing speed
- Large data volume (>10000 rows): It is recommended to use JSONL format, which supports line-by-line processing
2. Choose Format Based on Data Complexity
- Simple data structure: It is recommended to use Excel or CSV format
- Complex nested structure: It is recommended to use JSON format
3. Keep Data Structure Clear
No matter which data format is used, the data structure should be kept clear to facilitate Sheet-to-Doc tool processing.
4. Use Clear Field Names
Choose concise and clear field names, avoiding overly complex or confusing names.
5. Test Data Formats
Before generating a large number of documents, test data formats with a small amount of data to ensure that the tool can process them correctly.
6. Backup Original Data
It is recommended to backup original data files to avoid being unable to generate documents due to data file loss.
Common Problems and Solutions for Data Formats
Problem 1: Excel Data Cannot Be Imported Correctly
Reason: Excel file format is not supported, or Excel data structure is incorrect.
Solution:
- Ensure that the Excel file format is .xlsx or .xls
- Ensure that Excel data structure is correct, with column names in the first row and data rows in subsequent rows
- Try converting Excel files to CSV format and then importing
Problem 2: CSV Data Imported with Messy Format
Reason: Incorrect delimiters in CSV files, or contains special characters.
Solution:
- Ensure that CSV files use commas as delimiters
- For field values containing commas, wrap them in double quotes
- Try cleaning CSV files using online tools
Problem 3: JSON Data Cannot Be Parsed Correctly
Reason: JSON format is incorrect, or contains syntax errors.
Solution:
- Use JSON validation tools (such as JSONLint) to check whether JSON format is correct
- Ensure that JSON data uses array format to store multiple rows of data
- Fix syntax errors in JSON
Problem 4: JSONL Data Missing After Import
Reason: There are incorrectly formatted lines in JSONL files, or line separators are incorrect.
Solution:
- Ensure that each line of JSONL files is a complete JSON object
- Ensure that correct line separators (\n) are used
- Check and fix syntax errors in JSONL
Summary
Sheet-to-Doc supports multiple data formats, including Excel, CSV, JSON, and JSONL. This extensive format support enables Sheet-to-Doc to adapt to different data sources and usage scenarios. By understanding the characteristics and usage methods of different data formats, you can choose appropriate data formats according to your own needs, improving the efficiency and flexibility of document generation.
When choosing data formats, it is recommended to consider factors such as data volume size, data complexity, and editing requirements. At the same time, following best practices for using data formats, ensuring clear data structure, concise and clear field names, testing data formats, backing up original data, etc., can all help improve the success rate and quality of document generation.
In the next series of articles, we will delve into Sheet-to-Doc’s template design best practices to help you create professional and efficient Word templates. Stay tuned!