|
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -82,10 +83,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
HSSFRow headRow = sheet.createRow(0);
|
|
|
//设置列宽 setColumnWidth的第二个参数要乘以256,这个参数的单位是1/256个字符宽度
|
|
|
sheet.setColumnWidth(0, 5 * 256);
|
|
|
- sheet.setColumnWidth(1, 18 * 256);
|
|
|
- sheet.setColumnWidth(2, 18 * 256);
|
|
|
- sheet.setColumnWidth(3, 18 * 256);
|
|
|
- sheet.setColumnWidth(4, 30 * 256);
|
|
|
+ sheet.setColumnWidth(1, 10 * 256);
|
|
|
+ sheet.setColumnWidth(2, 20 * 256);
|
|
|
+ sheet.setColumnWidth(3, 10 * 256);
|
|
|
+ sheet.setColumnWidth(4, 50 * 256);
|
|
|
sheet.setColumnWidth(5, 18 * 256);
|
|
|
//设置为居中加粗
|
|
|
HSSFCellStyle headStyle = workbook.createCellStyle();
|
|
@@ -123,10 +124,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
row.createCell(0).setCellValue(rowNum);
|
|
|
row.createCell(1).setCellValue((String) map.get("name"));
|
|
|
row.createCell(2).setCellValue((String) map.get("project"));
|
|
|
- row.createCell(3).setCellValue((String) map.get("duration"));
|
|
|
+ row.createCell(3).setCellValue(map.get("duration").toString());
|
|
|
row.createCell(4).setCellValue((String) map.get("content"));
|
|
|
HSSFCell cell = row.createCell(5);
|
|
|
- cell.setCellValue((String) map.get("time"));
|
|
|
+ cell.setCellValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
|
+ .format((Timestamp) map.get("time")));
|
|
|
cell.setCellStyle(style);
|
|
|
rowNum++;
|
|
|
}
|
|
@@ -139,7 +141,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
fos.close();
|
|
|
httpRespMsg.data = "/upload/" + fileUrlSuffix;
|
|
|
} catch (NullPointerException e) {
|
|
|
- httpRespMsg.setError("验证失败");
|
|
|
+ httpRespMsg.setError("验证失败或缺少数据");
|
|
|
return httpRespMsg;
|
|
|
} catch (IOException e) {
|
|
|
httpRespMsg.setError("文件生成错误");
|