Skip to content

Commit c18adcd

Browse files
authored
docs: update Chapter 4 and 6 in English Version (#498)
* docs: update Chapter 4 and 6 in English Version * docs: improve formatting and consistency of documentation pages
1 parent fdd9d4a commit c18adcd

File tree

6 files changed

+640
-524
lines changed

6 files changed

+640
-524
lines changed

website/docs/fill/fill.md

Lines changed: 76 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ id: 'fill'
33
title: 'Fill'
44
---
55

6-
# 填充
7-
本章节介绍如何使用 FastExcel 来填充数据到文件中。
6+
# Fill
87

9-
## 简单填充
8+
This section explains how to use FastExcel to fill data into files.
109

11-
### 概述
12-
基于模板文件,通过对象或 Map 填充数据到 Excel 中。
10+
## Simple Fill
11+
12+
### Overview
13+
14+
Fill data into Excel based on a template file using objects or Map.
15+
16+
### POJO Class
1317

14-
### POJO 类
1518
```java
1619
@Getter
1720
@Setter
@@ -23,13 +26,14 @@ public class FillData {
2326
}
2427
```
2528

26-
### 代码示例
29+
### Code Example
30+
2731
```java
2832
@Test
2933
public void simpleFill() {
3034
String templateFileName = "path/to/simple.xlsx";
3135

32-
// 方案1:基于对象填充
36+
// Approach 1: Fill based on object
3337
FillData fillData = new FillData();
3438
fillData.setName("张三");
3539
fillData.setNumber(5.2);
@@ -38,7 +42,7 @@ public void simpleFill() {
3842
.sheet()
3943
.doFill(fillData);
4044

41-
// 方案2:基于 Map 填充
45+
// Approach 2: Fill based on Map
4246
Map<String, Object> map = new HashMap<>();
4347
map.put("name", "张三");
4448
map.put("number", 5.2);
@@ -48,32 +52,37 @@ public void simpleFill() {
4852
.doFill(map);
4953
}
5054
```
51-
### 模板
55+
56+
### Template
57+
5258
![img](/img/docs/fill/simpleFill_file.png)
5359

54-
### 结果
60+
### Result
61+
5562
![img](/img/docs/fill/simpleFill_result.png)
5663

5764
---
5865

59-
## 填充列表
66+
## Fill List
6067

61-
### 概述
62-
填充多个数据项到模板列表中,支持内存批量操作和文件缓存分批填充。
68+
### Overview
69+
70+
Fill multiple data items into a template list, supporting in-memory batch operations and file cache batch filling.
71+
72+
### Code Example
6373

64-
### 代码示例
6574
```java
6675
@Test
6776
public void listFill() {
6877
String templateFileName = "path/to/list.xlsx";
6978

70-
// 方案1:一次性填充所有数据
79+
// Approach 1: Fill all data at once
7180
FastExcel.write("listFill.xlsx")
7281
.withTemplate(templateFileName)
7382
.sheet()
7483
.doFill(data());
7584

76-
// 方案2:分批填充
85+
// Approach 2: Batch filling
7786
try (ExcelWriter writer = FastExcel.write("listFillBatch.xlsx").withTemplate(templateFileName).build()) {
7887
WriteSheet writeSheet = FastExcel.writerSheet().build();
7988
writer.fill(data(), writeSheet);
@@ -82,20 +91,24 @@ public void listFill() {
8291
}
8392
```
8493

85-
### 模板
94+
### Template
95+
8696
![img](/img/docs/fill/listFill_file.png)
8797

88-
### 结果
98+
### Result
99+
89100
![img](/img/docs/fill/listFill_result.png)
90101

91102
---
92103

93-
## 复杂填充
104+
## Complex Fill
94105

95-
### 概述
96-
在模板中填充多种数据类型,包括列表和普通变量。
106+
### Overview
107+
108+
Fill various data types in a template, including lists and regular variables.
109+
110+
### Code Example
97111

98-
### 代码示例
99112
```java
100113
@Test
101114
public void complexFill() {
@@ -104,11 +117,11 @@ public void complexFill() {
104117
try (ExcelWriter writer = FastExcel.write("complexFill.xlsx").withTemplate(templateFileName).build()) {
105118
WriteSheet writeSheet = FastExcel.writerSheet().build();
106119

107-
// 填充列表数据,开启 forceNewRow
120+
// Fill list data, with forceNewRow enabled
108121
FillConfig config = FillConfig.builder().forceNewRow(true).build();
109122
writer.fill(data(), config, writeSheet);
110123

111-
// 填充普通变量
124+
// Fill regular variables
112125
Map<String, Object> map = new HashMap<>();
113126
map.put("date", "2024年11月20日");
114127
map.put("total", 1000);
@@ -117,20 +130,24 @@ public void complexFill() {
117130
}
118131
```
119132

120-
### 模板
133+
### Template
134+
121135
![img](/img/docs/fill/complexFill_file.png)
122136

123-
### 结果
137+
### Result
138+
124139
![img](/img/docs/fill/complexFill_result.png)
125140

126141
---
127142

128-
## 大数据量填充
143+
## Complex Fill with Large Data
144+
145+
### Overview
129146

130-
### 概述
131-
优化大数据量填充性能,确保模板列表在最后一行,后续数据通过 `WriteTable` 填充。
147+
Optimize performance for filling large data, ensuring the template list is at the last row, and subsequent data is filled using `WriteTable`.
148+
149+
### Code Example
132150

133-
### 代码示例
134151
```java
135152
@Test
136153
public void complexFillWithTable() {
@@ -139,36 +156,40 @@ public void complexFillWithTable() {
139156
try (ExcelWriter writer = FastExcel.write("complexFillWithTable.xlsx").withTemplate(templateFileName).build()) {
140157
WriteSheet writeSheet = FastExcel.writerSheet().build();
141158

142-
// 填充列表数据
159+
// Fill list data
143160
writer.fill(data(), writeSheet);
144161

145-
// 填充其他变量
162+
// Fill list data
146163
Map<String, Object> map = new HashMap<>();
147164
map.put("date", "2024年11月20日");
148165
writer.fill(map, writeSheet);
149166

150-
// 填充统计信息
167+
// Fill statistical information
151168
List<List<String>> totalList = new ArrayList<>();
152169
totalList.add(Arrays.asList(null, null, null, "统计: 1000"));
153170
writer.write(totalList, writeSheet);
154171
}
155172
}
156173
```
157174

158-
### 模板
175+
### Template
176+
159177
![img](/img/docs/fill/complexFillWithTable_file.png)
160178

161-
### 结果
179+
### Result
180+
162181
![img](/img/docs/fill/complexFillWithTable_result.png)
163182

164183
---
165184

166-
## 横向填充
185+
## Horizontal Fill
186+
187+
### Overview
188+
189+
Fill list data horizontally, suitable for scenarios with dynamic column numbers.
167190

168-
### 概述
169-
将列表数据横向填充,适用于动态列数场景。
191+
### Code Example
170192

171-
### 代码示例
172193
```java
173194
@Test
174195
public void horizontalFill() {
@@ -187,20 +208,24 @@ public void horizontalFill() {
187208
}
188209
```
189210

190-
### 模板
211+
### Template
212+
191213
![img](/img/docs/fill/horizontalFill_file.png)
192214

193-
### 结果
215+
### Result
216+
194217
![img](/img/docs/fill/horizontalFill_result.png)
195218

196219
---
197220

198-
## 多列表组合填充
221+
## Fill Multiple Lists Together
222+
223+
### Overview
199224

200-
### 概述
201-
支持多个列表同时填充,列表之间通过前缀区分。
225+
Support filling multiple lists simultaneously, with prefixes to differentiate between lists.
226+
227+
### Code Example
202228

203-
### 代码示例
204229
```java
205230
@Test
206231
public void compositeFill() {
@@ -209,7 +234,7 @@ public void compositeFill() {
209234
try (ExcelWriter writer = FastExcel.write("compositeFill.xlsx").withTemplate(templateFileName).build()) {
210235
WriteSheet writeSheet = FastExcel.writerSheet().build();
211236

212-
// 使用 FillWrapper 进行多列表填充
237+
// Use FillWrapper for filling multiple lists
213238
writer.fill(new FillWrapper("data1", data()), writeSheet);
214239
writer.fill(new FillWrapper("data2", data()), writeSheet);
215240
writer.fill(new FillWrapper("data3", data()), writeSheet);
@@ -221,8 +246,10 @@ public void compositeFill() {
221246
}
222247
```
223248

224-
### 模板
249+
### Template
250+
225251
![img](/img/docs/fill/compositeFill_file.png)
226252

227-
### 结果
253+
### Result
254+
228255
![img](/img/docs/fill/compositeFill_result.png)

website/docs/help/annotation.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,51 @@ id: 'annotation'
33
title: 'Annotation'
44
---
55

6-
# 注解
7-
本章节介绍读取 FastExcel 中提供的注解。
6+
# Annotation
87

9-
## 实体类注解
8+
This section describes how to read annotations provided in FastExcel.
109

11-
实体类是读写操作的基础。FastExcel 提供了多种注解,帮助开发者轻松定义字段和格式。
10+
## Entity Class Annotations
1211

13-
### **`@ExcelProperty`**
14-
定义 Excel 列名和映射的字段名。 具体参数如下:
12+
Entity classes are the foundation of read and write operations. FastExcel provides various annotations to help developers easily define fields and formats.
1513

16-
| 名称 | 默认值 | 描述 |
17-
|---------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
18-
| value || 用于匹配excel中的头,必须全匹配,如果有多行头,会匹配最后一行头 |
19-
| order | Integer.MAX_VALUE | 优先级高于`value`,会根据`order`的顺序来匹配实体和excel中数据的顺序 |
20-
| index | &#45;1 | 优先级高于`value``order`,会根据`index`直接指定到excel中具体的哪一列 |
21-
| converter | 自动选择 | 指定当前字段用什么转换器,默认会自动选择。读的情况下只要实现`cn.idev.excel.converters.Converter#convertToJavaData(com.idev.excel.converters.ReadConverterContext<?>)` 方法即可 |
14+
### `@ExcelProperty`
15+
16+
Defines the column name in Excel and the field name to map. Specific parameters are as follows:
17+
18+
| Name | Default Value | Description |
19+
|-----------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
20+
| value | Empty | Used to match the header in Excel, must be fully matched. If there are multiple header rows, it will match the last row header. |
21+
| order | Integer.MAX_VALUE | Higher priority than `value`, will match the order of entities and data in Excel according to the order of `order`. |
22+
| index | -1 | Higher priority than `value` and `order`, will directly specify which column in Excel to match based on `index`. |
23+
| converter | Automatically selected | Specifies which converter the current field uses. By default, it will be automatically selected. <br> For reading, as long as the `cn.idev.excel.converters.Converter#convertToJavaData(com.idev.excel.converters.ReadConverterContext<?>)` method is implemented, it is sufficient. |
2224

2325
### `@ExcelIgnore`
2426

25-
默认所有字段都会和 Excel 去匹配,加了这个注解会忽略该字段。
27+
By default, all fields will match Excel. Adding this annotation will ignore the field.
2628

2729
### `@ExcelIgnoreUnannotated`
2830

29-
默认不加 `@ExcelProperty` 的注解的都会参与读写,加了不会参与读写。
31+
By default, all properties without the `@ExcelProperty` annotation are involved in read/write operations. Properties with this annotation are not involved in read/write operations.
32+
33+
### `@DateTimeFormat`
34+
35+
Date conversion: When using `String` to receive data in Excel date format, this annotation will be called. The parameters are as follows:
3036

31-
### **`@DateTimeFormat`**
32-
日期转换,用`String`去接收excel日期格式的数据会调用这个注解,参数如下:
37+
| Name | Default Value | Description |
38+
|------------------|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39+
| value | Empty | Refer to `java.text.SimpleDateFormat` . |
40+
| use1904windowing | Automatically selected | In Excel, time is stored as a double-precision floating-point number starting from 1900, but sometimes the default start date is 1904, so set this value to change the default start date to 1904. |
3341

34-
| 名称 | 默认值 | 描述 |
35-
|---------------------|------|----------------------------------------------------------------|
36-
| value || 参照`java.text.SimpleDateFormat`书写即可 |
37-
| use1904windowing | 自动选择 | excel中时间是存储1900年起的一个双精度浮点数,但是有时候默认开始日期是1904,所以设置这个值改成默认1904年开始 |
42+
### `@NumberFormat`
3843

39-
### **`@NumberFormat`**
44+
Number conversion, using `String` to receive data in Excel number format will trigger this annotation.
4045

41-
数字转换,用`String`去接收excel数字格式的数据会调用这个注解。
46+
| Name | Default Value | Description |
47+
|--------------|----------------------|---------------------------------------|
48+
| value | Empty | Refer to `java.text.DecimalFormat`. |
49+
| roundingMode | RoundingMode.HALF_UP | Set the rounding mode when formatting |
4250

43-
| 名称 | 默认值 | 描述 |
44-
|---------------------|------|-----------------------------|
45-
| value || 参照`java.text.DecimalFormat`书写即可 |
46-
| roundingMode | RoundingMode.HALF_UP | 格式化的时候设置舍入模式 |
51+
### `@ColumnWidth`
4752

48-
### **`@ColumnWidth`**
49-
指定列宽。
53+
Specifies the column width.

0 commit comments

Comments
 (0)