代码拉取完成,页面将自动刷新
依赖 | 版本 | 备注 |
---|---|---|
lombok | 1.18.10 | |
poi | 5.1.0 | |
poi-ooxml | 5.1.0 | |
poi-scratchpad | 5.1.0 |
<dependency>
<groupId>com.sushengren</groupId>
<artifactId>easyword</artifactId>
<version>1.1.3</version>
</dependency>
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DemoData {
@WordProperty("标题")
private String title;
@WordProperty("生成时间")
private String generationTime;
@WordProperty("学生数")
private Integer numberOfStudents;
@WordProperty("监考老师数")
private Integer numberOfInvigilators;
@WordProperty("评卷老师数")
private Integer numberOfTeachers;
@WordProperty("年度")
private String year;
@WordProperty("学期")
private String semester;
@WordProperty("考试时间")
private String examinationTime;
@WordProperty("科目")
private String subject;
@WordProperty(value = "Logo", converter = PictureConverter.class)
private InputStream logo;
@WordProperty("班级列表")
private List<ClassInfo> classList;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ClassInfo {
@WordProperty("班级")
private String className;
@WordProperty("人数")
private Integer numberOfPeople;
@WordProperty("平均分")
private Double theAverageScore;
@WordProperty("年级")
private String grade;
@WordProperty("排名")
private Integer ranking;
@WordProperty("班主任")
private String classTeacher;
@WordProperty("学生列表")
private List<StudentInfo> studentList;
}
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class StudentInfo {
@WordProperty("姓名")
private String name;
@WordProperty("学号")
private String studentID;
@WordProperty("总分")
private Double totalScore;
@WordProperty("平均分")
private Double theAverageScore;
@WordProperty("排名")
private Integer ranking;
@WordProperty("年级排名")
private Integer gradeRanking;
@WordProperty("备注")
private String remark;
}
}
public static void main(String[] args) throws IOException {
List<StudentInfo> studentList = new ArrayList<>();
studentList.add(new StudentInfo("小明", "No00001", 280.0, 93.3, 1, 1, ""));
studentList.add(new StudentInfo("小红", "No00002", 260.0, 86.6, 2, 2, ""));
studentList.add(new StudentInfo("小花", "No00003", 270.0, 90.0, 3, 120, ""));
studentList.add(new StudentInfo("小莉", "No00004", 250.0, 83.3, 4, 210, ""));
studentList.add(new StudentInfo("托尼", "No00005", 241.0, 80.3, 5, 600, ""));
List<ClassInfo> classList = new ArrayList<>();
classList.add(new ClassInfo("一年级一班", 50, 270.5, "一年级", 1, "温娟", studentList));
classList.add(new ClassInfo("一年级二班", 60, 260.5, "一年级", 2, "张三", studentList));
classList.add(new ClassInfo("一年级三班", 35, 280.5, "一年级", 3, "李四", studentList));
classList.add(new ClassInfo("一年级四班", 56, 290.5, "一年级", 4, "王五", studentList));
DemoData data = DemoData.builder()
.title("2022年度期末考试成绩报告")
.generationTime("2022-01-01")
.numberOfStudents(1510)
.numberOfInvigilators(157)
.numberOfTeachers(157)
.year("二零二二")
.semester("第二学期")
.examinationTime("2022-10-01 至 2022-10-02")
.subject("语文、数学、英语")
.classList(classList)
.logo(new FileInputStream("C:\\Users\\mangfu\\Pictures\\logo.png"))
.build();
File file = new File("C:\\Users\\mangfu\\Desktop\\期末成绩报告模板.docx");
FileOutputStream out = new FileOutputStream("C:\\Users\\mangfu\\Desktop\\期末成绩报告模板-1.docx");
EasyWord.of(file).doWrite(data).toOutputStream(out);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。