导出文件居中
This commit is contained in:
parent
abd6259f98
commit
ff395e93f2
@ -10,6 +10,7 @@ import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -75,11 +76,14 @@ public class DatasetQuestionController {
|
||||
// 创建样式并设置垂直居中
|
||||
HSSFCellStyle cellStyle = template.createCellStyle();
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
int count = 0;
|
||||
List<Integer> id = new ArrayList<>();
|
||||
HSSFRow row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue("问题内容");
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue("标注内容");
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
id.add(count);
|
||||
count++;
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
@ -91,14 +95,18 @@ public class DatasetQuestionController {
|
||||
if (collect.size() == 0){
|
||||
row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue(question);
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue("");
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
id.add(count);
|
||||
count++;
|
||||
}else {
|
||||
for (String s : collect) {
|
||||
row = sheet.createRow(count);
|
||||
row.createCell(0).setCellValue(question);
|
||||
row.getCell(0).setCellStyle(cellStyle);
|
||||
row.createCell(1).setCellValue(s);
|
||||
row.getCell(1).setCellStyle(cellStyle);
|
||||
count++;
|
||||
}
|
||||
id.add(count-1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user