main
黄海 2 years ago
parent 15d22af30f
commit 467589c2f0

@ -48,8 +48,6 @@ public class TestRegex {
public static void ExportExcel(List<Record> list, List<Record> errlist) throws IOException { public static void ExportExcel(List<Record> list, List<Record> errlist) throws IOException {
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream(path)); XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new FileInputStream(path));
XSSFSheet sheet1 = xssfWorkbook.getSheetAt(0); XSSFSheet sheet1 = xssfWorkbook.getSheetAt(0);
//正文与表头不是一个颜色
XSSFFont txtFont = xssfWorkbook.createFont(); XSSFFont txtFont = xssfWorkbook.createFont();
txtFont.setFontHeightInPoints((short) 11); //字体大小 txtFont.setFontHeightInPoints((short) 11); //字体大小
txtFont.setFontName("等线"); //字体 txtFont.setFontName("等线"); //字体
@ -86,31 +84,31 @@ public class TestRegex {
//调整宽度 //调整宽度
sheet1.setColumnWidth(14, 512 * 50 + 184); sheet1.setColumnWidth(14, 512 * 50 + 184);
//填充 // //填充
for (int i = 0; i < list.size(); i++) { // for (int i = 0; i < list.size(); i++) {
Record record = list.get(i); // Record record = list.get(i);
int id = record.getInt("id"); // int id = record.getInt("id");
String zhuanye = record.getStr("zhuanye"); // String zhuanye = record.getStr("zhuanye");
String xf = record.getStr("xf"); // String xf = record.getStr("xf");
String memo = record.getStr("memo"); // String memo = record.getStr("memo");
try { // try {
row = sheet1.getRow(id + 1); // row = sheet1.getRow(id + 1);
cell = row.createCell(12); // cell = row.createCell(12);
cell.setCellValue(zhuanye); // cell.setCellValue(zhuanye);
cell.setCellStyle(cellStyleTxt); // cell.setCellStyle(cellStyleTxt);
//
cell = row.createCell(13); // cell = row.createCell(13);
cell.setCellValue(xf); // cell.setCellValue(xf);
cell.setCellStyle(cellStyleTxt); // cell.setCellStyle(cellStyleTxt);
//
cell = row.createCell(14); // cell = row.createCell(14);
cell.setCellValue(memo); // cell.setCellValue(memo);
cell.setCellStyle(cellStyleTxt); // cell.setCellStyle(cellStyleTxt);
} catch (Exception err) { // } catch (Exception err) {
System.out.println(err.toString()); // System.out.println(err.toString());
} // }
} // }
// //写入异常数据 // //写入异常数据
// XSSFSheet sheet2 = xssfWorkbook.getSheetAt(1); // XSSFSheet sheet2 = xssfWorkbook.getSheetAt(1);
// for (int i = 0; i < errlist.size(); i++) { // for (int i = 0; i < errlist.size(); i++) {

Loading…
Cancel
Save