|
@@ -60,11 +60,14 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
|
|
|
XSSFCellStyle cellStyle = Utility.getTitleCellStyle(wb, (short) 10, HorizontalAlignment.CENTER);
|
|
|
XSSFCellStyle cellStyleLeft = Utility.getTitleCellStyle(wb, (short) 10, HorizontalAlignment.LEFT);
|
|
|
FileEntry file = this.getById(Long.parseLong(imgId));
|
|
|
- ByteArrayInputStream inb = new ByteArrayInputStream(file.getFile());
|
|
|
- BufferedImage bufferImg = ImageIO.read(inb);
|
|
|
+ BufferedImage bufferImg = null;
|
|
|
+ if(file!=null) {
|
|
|
+ ByteArrayInputStream inb = new ByteArrayInputStream(file.getFile());
|
|
|
+ bufferImg = ImageIO.read(inb);
|
|
|
+ inb.close();
|
|
|
+ }
|
|
|
String[] data = getOnsiteTitle1Data();
|
|
|
createOnsiteTitle1(wb, sheet, cellStyle, 0, data, bufferImg);
|
|
|
- inb.close();
|
|
|
data = getOnsiteTitle2Data(plan);
|
|
|
createOnsiteTitle2(sheet, cellStyle, 1, data);
|
|
|
data = getOnsiteTitle3Data(plan, param, iscontroll);
|
|
@@ -370,15 +373,16 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
|
|
|
Utility.addCellValForStr(row.getCell(0), data[0], cellStyle);
|
|
|
Utility.addCellValForStr(row.getCell(3), data[1], Utility.getTitleCellStyle(wb, (short) 15, HorizontalAlignment.CENTER));
|
|
|
Utility.addCellValForStr(row.getCell(21), data[2], Utility.getTitleCellStyle(wb, (short) 10, HorizontalAlignment.LEFT));
|
|
|
- ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
|
|
- ImageIO.write(bufferImg, "png", byteArrayOut);
|
|
|
- Drawing patriarch = sheet.createDrawingPatriarch();
|
|
|
- XSSFClientAnchor anchor = new XSSFClientAnchor(10, 10, 255, 255,
|
|
|
- (short) 28, 0, (short) 36, 2);
|
|
|
- patriarch.createPicture(anchor, wb.addPicture(byteArrayOut
|
|
|
- .toByteArray(), HSSFWorkbook.PICTURE_TYPE_PNG)); // 插入图片
|
|
|
- byteArrayOut.close();
|
|
|
-
|
|
|
+ if(bufferImg!=null) {
|
|
|
+ ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
|
|
|
+ ImageIO.write(bufferImg, "png", byteArrayOut);
|
|
|
+ Drawing patriarch = sheet.createDrawingPatriarch();
|
|
|
+ XSSFClientAnchor anchor = new XSSFClientAnchor(10, 10, 255, 255,
|
|
|
+ (short) 28, 0, (short) 36, 2);
|
|
|
+ patriarch.createPicture(anchor, wb.addPicture(byteArrayOut
|
|
|
+ .toByteArray(), HSSFWorkbook.PICTURE_TYPE_PNG)); // 插入图片
|
|
|
+ byteArrayOut.close();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|