|
|
@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
package com.gmh;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import com.gmh.utils.POIExcelUtil;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @author ChenDa
|
|
|
|
|
|
|
|
* @ClassName test
|
|
|
|
|
|
|
|
* @description: TODO
|
|
|
|
|
|
|
|
* @datetime 2022/11/06 16:43
|
|
|
|
|
|
|
|
* @version: 1.0
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class test {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
|
|
|
File file = new File("C:\\Users\\xxche\\Desktop\\继续教育证明\\盛华编制聘任制.xlsx");
|
|
|
|
|
|
|
|
Workbook workbook = POIExcelUtil.readExcelFromFile(file);
|
|
|
|
|
|
|
|
// 编制
|
|
|
|
|
|
|
|
Sheet bianzhi = workbook.getSheetAt(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> bianzhiList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0; i <= bianzhi.getLastRowNum(); i++) {
|
|
|
|
|
|
|
|
Row row = bianzhi.getRow(i);
|
|
|
|
|
|
|
|
if (row == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell cell = row.getCell(1);
|
|
|
|
|
|
|
|
String name = cell.getStringCellValue();
|
|
|
|
|
|
|
|
if ("姓名".equals(name)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrUtil.isBlankIfStr(name)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bianzhiList.add(nameFormat(name));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Workbook bianzhiWb = POIExcelUtil.batchCloneSheet(new File("C:\\Users\\xxche\\Desktop\\20221106_test_excel\\附件3.继续教育证明.xls"), 0, bianzhiList.size());
|
|
|
|
|
|
|
|
for (int i = 0; i < bianzhiWb.getNumberOfSheets(); i++) {
|
|
|
|
|
|
|
|
Sheet sheet = bianzhiWb.getSheetAt(i);
|
|
|
|
|
|
|
|
if (sheet == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Row row = sheet.getRow(2);
|
|
|
|
|
|
|
|
Cell cell = row.getCell(0);
|
|
|
|
|
|
|
|
cell.setCellValue(" (2022年度)\n" +
|
|
|
|
|
|
|
|
" ${NAME}同志于2022年 1月4日至2022年11月14日参加${schoolName} 举办的继续教育培训,总计 90 学时,成绩合格,特此证明。"
|
|
|
|
|
|
|
|
.replace("${NAME}", bianzhiList.get(i))
|
|
|
|
|
|
|
|
.replace("${schoolName}", "长春市盛华学校"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream("C:\\Users\\xxche\\Desktop\\20221106_test_excel\\附件3.继续教育证明222.xls");
|
|
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
bianzhiWb.write(out);
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
System.out.println("编制文件输出完成");
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 聘任制
|
|
|
|
|
|
|
|
Sheet pinren = workbook.getSheetAt(1);
|
|
|
|
|
|
|
|
List<String> pinrenList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (int i = 0; i <= pinren.getLastRowNum(); i++) {
|
|
|
|
|
|
|
|
Row row = pinren.getRow(i);
|
|
|
|
|
|
|
|
if (row == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Cell cell = row.getCell(1);
|
|
|
|
|
|
|
|
String name = cell.getStringCellValue();
|
|
|
|
|
|
|
|
if ("姓名".equals(name)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrUtil.isBlankIfStr(name)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pinrenList.add(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Workbook pinrenWb = POIExcelUtil.batchCloneSheet(new File("C:\\Users\\xxche\\Desktop\\20221106_test_excel\\附件3.继续教育证明(聘用制).xls"), 0, pinrenList.size());
|
|
|
|
|
|
|
|
for (int i = 0; i < pinrenWb.getNumberOfSheets(); i++) {
|
|
|
|
|
|
|
|
Sheet sheet = pinrenWb.getSheetAt(i);
|
|
|
|
|
|
|
|
if (sheet == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Row row = sheet.getRow(2);
|
|
|
|
|
|
|
|
Cell cell = row.getCell(0);
|
|
|
|
|
|
|
|
cell.setCellValue(" (2022年度)\n" +
|
|
|
|
|
|
|
|
" ${NAME}同志于2022年 1月4日至2022年11月14日参加${schoolName} 举办的继续教育培训,总计 90 学时,成绩合格,特此证明。"
|
|
|
|
|
|
|
|
.replace("${NAME}", pinrenList.get(i))
|
|
|
|
|
|
|
|
.replace("${schoolName}", "长春市盛华学校"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream("C:\\Users\\xxche\\Desktop\\20221106_test_excel\\附件3.继续教育证明(聘用制)222.xls");
|
|
|
|
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
pinrenWb.write(out);
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
System.out.println("聘任制文件输出完成");
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String nameFormat(String name) {
|
|
|
|
|
|
|
|
StringBuilder newName = new StringBuilder(name.replaceAll("\\s*", ""));
|
|
|
|
|
|
|
|
if (newName.length() == 2) {
|
|
|
|
|
|
|
|
newName.insert(1, " ");
|
|
|
|
|
|
|
|
return newName.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|