Skip to content

Commit 507577f

Browse files
authored
Refactor: Internationalize comments and test data in write demo package (#753)
1 parent d129b7d commit 507577f

File tree

14 files changed

+386
-322
lines changed

14 files changed

+386
-322
lines changed

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/ColorDemoData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
@NoArgsConstructor
4040
public class ColorDemoData {
4141

42-
@ExcelProperty("姓名")
42+
@ExcelProperty("Name")
4343
private String name;
4444

45-
@ExcelProperty("年龄")
45+
@ExcelProperty("Age")
4646
@HeadFontStyle(color = Font.COLOR_RED)
4747
private Integer age;
4848

49-
@ExcelProperty("性别")
49+
@ExcelProperty("Sex")
5050
private String sex;
5151
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/CommentWriteHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
3131

3232
/**
33-
* 自定义拦截器.新增注释,第一行头加批注
33+
* Custom handler. Add comment to the header of the first row.
3434
*
3535
*
3636
*/
@@ -42,12 +42,12 @@ public void afterRowDispose(RowWriteHandlerContext context) {
4242
if (BooleanUtils.isTrue(context.getHead())) {
4343
Sheet sheet = context.getWriteSheetHolder().getSheet();
4444
Drawing<?> drawingPatriarch = sheet.createDrawingPatriarch();
45-
// 在第一行 第二列创建一个批注
45+
// Create a comment in the first row, second column
4646
Comment comment =
4747
drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 1, 0, (short) 2, 1));
48-
// 输入批注信息
49-
comment.setString(new XSSFRichTextString("创建批注!"));
50-
// 将批注添加到单元格对象中
48+
// Input comment information
49+
comment.setString(new XSSFRichTextString("Create comment!"));
50+
// Add comment to cell object
5151
sheet.getRow(0).getCell(1).setCellComment(comment);
5252
}
5353
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/ComplexHeadData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
import org.apache.fesod.sheet.annotation.ExcelProperty;
2727

2828
/**
29-
* 复杂头数据.这里最终效果是第一行就一个主标题,第二行分类
29+
* Complex header data. The final effect is a main title on the first row, and categories on the second row.
3030
*
3131
*
3232
**/
3333
@Getter
3434
@Setter
3535
@EqualsAndHashCode
3636
public class ComplexHeadData {
37-
@ExcelProperty({"主标题", "字符串标题"})
37+
@ExcelProperty({"Main Title", "String Title"})
3838
private String string;
3939

40-
@ExcelProperty({"主标题", "日期标题"})
40+
@ExcelProperty({"Main Title", "Date Title"})
4141
private Date date;
4242

43-
@ExcelProperty({"主标题", "数字标题"})
43+
@ExcelProperty({"Main Title", "Double Title"})
4444
private Double doubleData;
4545
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/ConverterData.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.fesod.sheet.annotation.format.NumberFormat;
2929

3030
/**
31-
* 基础数据类.这里的排序和excel里面的排序一致
31+
* Basic data class. The sorting here is consistent with the sorting in Excel.
3232
*
3333
*
3434
**/
@@ -37,20 +37,20 @@
3737
@EqualsAndHashCode
3838
public class ConverterData {
3939
/**
40-
* 我想所有的 字符串起前面加上"自定义:"三个字
40+
* I want to add "Custom:" to the beginning of all strings.
4141
*/
42-
@ExcelProperty(value = "字符串标题", converter = CustomStringStringConverter.class)
42+
@ExcelProperty(value = "String Title", converter = CustomStringStringConverter.class)
4343
private String string;
4444
/**
45-
* 我想写到excel 用年月日的格式
45+
* I want to write to Excel using the format "yyyy-MM-dd HH:mm:ss"
4646
*/
47-
@DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒")
48-
@ExcelProperty("日期标题")
47+
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
48+
@ExcelProperty("Date Title")
4949
private Date date;
5050
/**
51-
* 我想写到excel 用百分比表示
51+
* I want to write to Excel using percentage format.
5252
*/
5353
@NumberFormat("#.##%")
54-
@ExcelProperty(value = "数字标题")
54+
@ExcelProperty(value = "Double Title")
5555
private Double doubleData;
5656
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/CustomCellWriteHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.poi.ss.usermodel.Hyperlink;
3030

3131
/**
32-
* 自定义拦截器
32+
* Custom handler
3333
*
3434
*
3535
*/
@@ -39,8 +39,8 @@ public class CustomCellWriteHandler implements CellWriteHandler {
3939
@Override
4040
public void afterCellDispose(CellWriteHandlerContext context) {
4141
Cell cell = context.getCell();
42-
// 这里可以对cell进行任何操作
43-
log.info("第{}行,第{}列写入完成。", cell.getRowIndex(), cell.getColumnIndex());
42+
// Can perform any operation on the cell here
43+
log.info("Finished writing row {}, column {}", cell.getRowIndex(), cell.getColumnIndex());
4444
if (BooleanUtils.isTrue(context.getHead()) && cell.getColumnIndex() == 0) {
4545
CreationHelper createHelper =
4646
context.getWriteSheetHolder().getSheet().getWorkbook().getCreationHelper();

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/CustomSheetWriteHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.poi.ss.util.CellRangeAddressList;
2929

3030
/**
31-
* 自定义拦截器.对第一列第一行和第二行的数据新增下拉框,显示 测试1 测试2
31+
* Custom handler. Add dropdown to first column of first and second data rows, displaying "Test1", "Test2"
3232
*
3333
*
3434
*/
@@ -37,12 +37,13 @@ public class CustomSheetWriteHandler implements SheetWriteHandler {
3737

3838
@Override
3939
public void afterSheetCreate(SheetWriteHandlerContext context) {
40-
log.info("第{}个Sheet写入成功。", context.getWriteSheetHolder().getSheetNo());
40+
log.info("Sheet {} write success.", context.getWriteSheetHolder().getSheetNo());
4141

42-
// 区间设置 第一列第一行和第二行的数据。由于第一行是头,所以第一、二行的数据实际上是第二三行
42+
// Set range for first column, first and second data rows. Since the first row is head, the data is actually in
43+
// the 2nd and 3rd rows.
4344
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(1, 2, 0, 0);
4445
DataValidationHelper helper = context.getWriteSheetHolder().getSheet().getDataValidationHelper();
45-
DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"测试1", "测试2"});
46+
DataValidationConstraint constraint = helper.createExplicitListConstraint(new String[] {"Test1", "Test2"});
4647
DataValidation dataValidation = helper.createValidation(constraint, cellRangeAddressList);
4748
context.getWriteSheetHolder().getSheet().addValidationData(dataValidation);
4849
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/DemoMergeData.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@
2727
import org.apache.fesod.sheet.annotation.write.style.ContentLoopMerge;
2828

2929
/**
30-
* 样式的数据类
30+
* Style data class
3131
*
3232
*
3333
**/
3434
@Getter
3535
@Setter
3636
@EqualsAndHashCode
37-
// 将第6-7行的2-3列合并成一个单元格
37+
// Merge columns 2-3 of rows 6-7 into one cell
3838
// @OnceAbsoluteMerge(firstRowIndex = 5, lastRowIndex = 6, firstColumnIndex = 1, lastColumnIndex = 2)
3939
public class DemoMergeData {
40-
// 这一列 每隔2行 合并单元格
40+
// Merge this column every 2 rows
4141
@ContentLoopMerge(eachRow = 2)
42-
@ExcelProperty("字符串标题")
42+
@ExcelProperty("String Title")
4343
private String string;
4444

45-
@ExcelProperty("日期标题")
45+
@ExcelProperty("Date Title")
4646
private Date date;
4747

48-
@ExcelProperty("数字标题")
48+
@ExcelProperty("Double Title")
4949
private Double doubleData;
5050
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/DemoStyleData.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,36 @@
3131
import org.apache.fesod.sheet.enums.poi.FillPatternTypeEnum;
3232

3333
/**
34-
* 样式的数据类
34+
* Style data class
3535
*
3636
*
3737
**/
3838
@Getter
3939
@Setter
4040
@EqualsAndHashCode
41-
// 头背景设置成红色 IndexedColors.RED.getIndex()
41+
// Head background red
4242
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 10)
43-
// 头字体设置成20
43+
// Head font size 20
4444
@HeadFontStyle(fontHeightInPoints = 20)
45-
// 内容的背景设置成绿色 IndexedColors.GREEN.getIndex()
45+
// Content background green
4646
@ContentStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 17)
47-
// 内容字体设置成20
47+
// Content font size 20
4848
@ContentFontStyle(fontHeightInPoints = 20)
4949
public class DemoStyleData {
50-
// 字符串的头背景设置成粉红 IndexedColors.PINK.getIndex()
50+
// String head background pink
5151
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 14)
52-
// 字符串的头字体设置成20
52+
// String head font size 30
5353
@HeadFontStyle(fontHeightInPoints = 30)
54-
// 字符串的内容的背景设置成天蓝 IndexedColors.SKY_BLUE.getIndex()
54+
// String content background sky blue
5555
@ContentStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 40)
56-
// 字符串的内容字体设置成20
56+
// String content font size 30
5757
@ContentFontStyle(fontHeightInPoints = 30)
58-
@ExcelProperty("字符串标题")
58+
@ExcelProperty("String Title")
5959
private String string;
6060

61-
@ExcelProperty("日期标题")
61+
@ExcelProperty("Date Title")
6262
private Date date;
6363

64-
@ExcelProperty("数字标题")
64+
@ExcelProperty("Double Title")
6565
private Double doubleData;
6666
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/ImageDemoData.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.apache.fesod.sheet.metadata.data.WriteCellData;
3333

3434
/**
35-
* 图片导出类
35+
* Image export class
3636
*/
3737
@Getter
3838
@Setter
@@ -43,19 +43,23 @@ public class ImageDemoData {
4343
private File file;
4444
private InputStream inputStream;
4545
/**
46-
* 如果string类型 必须指定转换器,string默认转换成string
46+
* If it is a String type, a converter must be specified; String is converted to String by default.
4747
*/
4848
@ExcelProperty(converter = StringImageConverter.class)
4949
private String string;
5050

5151
private byte[] byteArray;
5252
/**
53-
* 根据url导出
53+
* Export by URL
54+
*
55+
* @since 2.1.1
5456
*/
5557
private URL url;
5658

5759
/**
58-
* 根据文件导出 并设置导出的位置。
60+
* Export by file and set the export location.
61+
*
62+
* @since 3.0.0-beta1
5963
*/
6064
private WriteCellData<Void> writeCellDataFile;
6165
}

fesod-examples/fesod-sheet-examples/src/test/java/org/apache/fesod/sheet/demo/write/IndexData.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@
2626
import org.apache.fesod.sheet.annotation.ExcelProperty;
2727

2828
/**
29-
* 基础数据类
29+
* Basic data class
3030
*
3131
*
3232
**/
3333
@Getter
3434
@Setter
3535
@EqualsAndHashCode
3636
public class IndexData {
37-
@ExcelProperty(value = "字符串标题", index = 0)
37+
@ExcelProperty(value = "String Title", index = 0)
3838
private String string;
3939

40-
@ExcelProperty(value = "日期标题", index = 1)
40+
@ExcelProperty(value = "Date Title", index = 1)
4141
private Date date;
4242
/**
43-
* 这里设置3 会导致第二列空的
43+
* Setting index to 3 will result in the second column being empty.
4444
*/
45-
@ExcelProperty(value = "数字标题", index = 3)
45+
@ExcelProperty(value = "Double Title", index = 3)
4646
private Double doubleData;
4747
}

0 commit comments

Comments
 (0)