|
@@ -24,6 +24,7 @@ import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
|
+import org.apache.poi.xssf.usermodel.*;
|
|
import org.apache.velocity.runtime.directive.contrib.For;
|
|
import org.apache.velocity.runtime.directive.contrib.For;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -6280,24 +6281,24 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
// response.setHeader("Cache-Control","no-cache");//设置头
|
|
// response.setHeader("Cache-Control","no-cache");//设置头
|
|
// response.setDateHeader("Expires", 0);//设置日期头
|
|
// response.setDateHeader("Expires", 0);//设置日期头
|
|
// 创建工作簿
|
|
// 创建工作簿
|
|
- HSSFWorkbook workBook = new HSSFWorkbook();
|
|
|
|
|
|
+ XSSFWorkbook workBook = new XSSFWorkbook();
|
|
// 创建工作类
|
|
// 创建工作类
|
|
- HSSFSheet sheet = workBook.createSheet();
|
|
|
|
|
|
+ XSSFSheet sheet = workBook.createSheet();
|
|
//设置首行冻结
|
|
//设置首行冻结
|
|
sheet.createFreezePane(0, 1);
|
|
sheet.createFreezePane(0, 1);
|
|
sheet.setDefaultColumnWidth(16);
|
|
sheet.setDefaultColumnWidth(16);
|
|
//设置字体样式
|
|
//设置字体样式
|
|
- HSSFFont headFont = workBook.createFont();
|
|
|
|
|
|
+ XSSFFont headFont = workBook.createFont();
|
|
headFont.setBold(true);
|
|
headFont.setBold(true);
|
|
headFont.setFontHeightInPoints((short) 10);
|
|
headFont.setFontHeightInPoints((short) 10);
|
|
headFont.setFontName("黑体");
|
|
headFont.setFontName("黑体");
|
|
|
|
|
|
- HSSFFont titleFont = workBook.createFont();
|
|
|
|
|
|
+ XSSFFont titleFont = workBook.createFont();
|
|
titleFont.setBold(true);
|
|
titleFont.setBold(true);
|
|
titleFont.setFontHeightInPoints((short) 10);
|
|
titleFont.setFontHeightInPoints((short) 10);
|
|
titleFont.setFontName("黑体");
|
|
titleFont.setFontName("黑体");
|
|
|
|
|
|
- HSSFFont font = workBook.createFont();
|
|
|
|
|
|
+ XSSFFont font = workBook.createFont();
|
|
font.setFontHeightInPoints((short) 10);
|
|
font.setFontHeightInPoints((short) 10);
|
|
font.setFontName("宋体");
|
|
font.setFontName("宋体");
|
|
|
|
|
|
@@ -6318,10 +6319,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
int g = Integer.parseInt((color.substring(2,4)),16);
|
|
int g = Integer.parseInt((color.substring(2,4)),16);
|
|
int b = Integer.parseInt((color.substring(4,6)),16);
|
|
int b = Integer.parseInt((color.substring(4,6)),16);
|
|
|
|
|
|
- //自定义cell颜色
|
|
|
|
- HSSFPalette palette = workBook.getCustomPalette();
|
|
|
|
- //这里的9是索引
|
|
|
|
- palette.setColorAtIndex((short)9, (byte) r, (byte) g, (byte) b);
|
|
|
|
|
|
|
|
CellStyle titleStyle = workBook.createCellStyle();
|
|
CellStyle titleStyle = workBook.createCellStyle();
|
|
titleStyle.setFont(titleFont);
|
|
titleStyle.setFont(titleFont);
|
|
@@ -6365,11 +6362,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
*/
|
|
*/
|
|
int start = 0;
|
|
int start = 0;
|
|
for(List<String> rowList : allList) {
|
|
for(List<String> rowList : allList) {
|
|
- HSSFRow row = sheet.createRow(start);
|
|
|
|
|
|
+ XSSFRow row = sheet.createRow(start);
|
|
row.setHeightInPoints(24);
|
|
row.setHeightInPoints(24);
|
|
for(int i = 0; i < rowList.size(); i++) {
|
|
for(int i = 0; i < rowList.size(); i++) {
|
|
- HSSFCell cell = row.createCell(i);
|
|
|
|
- ClientAnchor anchor = new HSSFClientAnchor();
|
|
|
|
|
|
+ XSSFCell cell = row.createCell(i);
|
|
|
|
+ ClientAnchor anchor = new XSSFClientAnchor();
|
|
if(start == 0) {
|
|
if(start == 0) {
|
|
cell.setCellStyle(titleStyle);
|
|
cell.setCellStyle(titleStyle);
|
|
// 关键修改
|
|
// 关键修改
|
|
@@ -6395,7 +6392,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
// 输入批注信息
|
|
// 输入批注信息
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
// "例如: 2021-01-01"));
|
|
// "例如: 2021-01-01"));
|
|
- comment.setString(new HSSFRichTextString(MessageUtils.message("excel.dateFormat")+"\n" +
|
|
|
|
|
|
+ comment.setString(new XSSFRichTextString(MessageUtils.message("excel.dateFormat")+"\n" +
|
|
MessageUtils.message("excel.forExample")));
|
|
MessageUtils.message("excel.forExample")));
|
|
cell.setCellComment(comment);
|
|
cell.setCellComment(comment);
|
|
break;
|
|
break;
|
|
@@ -6405,7 +6402,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
// 输入批注信息
|
|
// 输入批注信息
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
// "例如: 2021-01-01"));
|
|
// "例如: 2021-01-01"));
|
|
- comment.setString(new HSSFRichTextString("员工存在重名情况下,必填"));
|
|
|
|
|
|
+ comment.setString(new XSSFRichTextString("员工存在重名情况下,必填"));
|
|
cell.setCellComment(comment);
|
|
cell.setCellComment(comment);
|
|
break;
|
|
break;
|
|
case "子项目名称":
|
|
case "子项目名称":
|
|
@@ -6414,7 +6411,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
// 输入批注信息
|
|
// 输入批注信息
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
// "例如: 2021-01-01"));
|
|
// "例如: 2021-01-01"));
|
|
- comment.setString(new HSSFRichTextString("项目下的子项目,没有可以不填"));
|
|
|
|
|
|
+ comment.setString(new XSSFRichTextString("项目下的子项目,没有可以不填"));
|
|
cell.setCellComment(comment);
|
|
cell.setCellComment(comment);
|
|
break;
|
|
break;
|
|
case "投入时长":
|
|
case "投入时长":
|
|
@@ -6423,7 +6420,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
// 输入批注信息
|
|
// 输入批注信息
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
//comment.setString(new HSSFRichTextString("日期格式:yyyy-MM-dd\n" +
|
|
// "例如: 2021-01-01"));
|
|
// "例如: 2021-01-01"));
|
|
- comment.setString(new HSSFRichTextString("填写当天在该项目上投入的工作时长,填写数字;单位为小时"));
|
|
|
|
|
|
+ comment.setString(new XSSFRichTextString("填写当天在该项目上投入的工作时长,填写数字;单位为小时"));
|
|
cell.setCellComment(comment);
|
|
cell.setCellComment(comment);
|
|
break;
|
|
break;
|
|
}
|
|
}
|