main
黄海 7 months ago
parent 94faee41a7
commit 22f682b13b

@ -9,7 +9,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
public class GenerateQA { public class GenerateQA_1 {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
//数据源 //数据源
@ -20,10 +20,10 @@ public class GenerateQA {
String target = source.replace(".xlsx", "【结果】.xlsx"); String target = source.replace(".xlsx", "【结果】.xlsx");
//模板读取 //模板读取
FileInputStream finTemplate = new FileInputStream(template); FileInputStream fTemplate = new FileInputStream(template);
Workbook wbTemplate = new XSSFWorkbook(finTemplate); Workbook wbTemplate = new XSSFWorkbook(fTemplate);
Sheet sheetTemplate = wbTemplate.getSheetAt(0);// 获取第一个工作表 Sheet sheetTemplate = wbTemplate.getSheetAt(0);// 获取第一个工作表
CellStyle cellStyle = ExcelCommonUtil.getCellStyle(wbTemplate);//单元格样式 CellStyle style = ExcelCommonUtil.getCellStyle(wbTemplate);//单元格样式
//源文件 //源文件
FileInputStream fSource = new FileInputStream(source); FileInputStream fSource = new FileInputStream(source);
@ -69,7 +69,7 @@ public class GenerateQA {
cell = row.createCell(0); cell = row.createCell(0);
} }
cell.setCellValue(area + "下的学校列表"); cell.setCellValue(area + "下的学校列表");
cell.setCellStyle(cellStyle); cell.setCellStyle(style);
//(2)回答 //(2)回答
cell = row.getCell(1); cell = row.getCell(1);
@ -85,7 +85,7 @@ public class GenerateQA {
content = content + ",学校总数:" + areaMap.get(area).size() + "个。" + "\n"; content = content + ",学校总数:" + areaMap.get(area).size() + "个。" + "\n";
cell.setCellValue(content); cell.setCellValue(content);
cell.setCellStyle(cellStyle); cell.setCellStyle(style);
//(3)可选问题名称 //(3)可选问题名称
cell = row.getCell(2); cell = row.getCell(2);
@ -93,7 +93,7 @@ public class GenerateQA {
cell = row.createCell(2); cell = row.createCell(2);
} }
cell.setCellValue(area + "下的学校列表"); cell.setCellValue(area + "下的学校列表");
cell.setCellStyle(cellStyle); cell.setCellStyle(style);
} }
// 保存文件 // 保存文件
FileOutputStream fileOut = new FileOutputStream(target); FileOutputStream fileOut = new FileOutputStream(target);
Loading…
Cancel
Save