|
|
@@ -13,6 +13,7 @@ import cn.start.tz.module.system.api.standard.dto.StandardProductRespDTO;
|
|
|
import cn.start.tz.module.system.api.standard.dto.StandardTemplateRespDTO;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.grapecity.documents.excel.*;
|
|
|
+import com.grapecity.documents.excel.drawing.ImageType;
|
|
|
import com.grapecity.documents.excel.template.DataSource.JsonDataSource;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -102,6 +103,37 @@ public class GrapeCityApiImpl implements GrapeCityApi {
|
|
|
workbook.open(mainInputStream, OpenFileFormat.Sjs);
|
|
|
for (IWorksheet worksheet : workbook.getWorksheets()) {
|
|
|
worksheet.setDataSource(new JsonDataSource(reqDTO.getReportJson()));
|
|
|
+ if (reqDTO.getPreparedByImg() != null
|
|
|
+ || reqDTO.getReportRatifyByImg() != null
|
|
|
+ || reqDTO.getReportApprovalByImg() != null) {
|
|
|
+ IRange usedRange = worksheet.getUsedRange();
|
|
|
+ if (usedRange != null) {
|
|
|
+ for (int row = 0; row < worksheet.getUsedRange().getRowCount(); row++) {
|
|
|
+ for (int col = 0; col < worksheet.getUsedRange().getColumnCount(); col++) {
|
|
|
+ IRange cell = worksheet.getRange(-1, -1, -1, -1).get(row, col);
|
|
|
+ String bindingPath = cell.getBindingPath();
|
|
|
+ if ("preparedByName".equals(bindingPath) && reqDTO.getPreparedByImg() != null) {
|
|
|
+ try (InputStream tempIn0 = new ByteArrayInputStream(reqDTO.getPreparedByImg())) {
|
|
|
+ Rectangle rect = CellInfo.GetRangeBoundary(worksheet.getRange(cell.getAddress()));
|
|
|
+ worksheet.getShapes().addPictureInPixel(tempIn0, ImageType.JPG, rect.getX(), rect.getY(), rect.getWidth() * 8, rect.getHeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("reportApprovalByName".equals(bindingPath) && reqDTO.getReportApprovalByImg() != null) {
|
|
|
+ try (InputStream tempIn1 = new ByteArrayInputStream(reqDTO.getReportApprovalByImg())) {
|
|
|
+ Rectangle rect = CellInfo.GetRangeBoundary(worksheet.getRange(cell.getAddress()));
|
|
|
+ worksheet.getShapes().addPictureInPixel(tempIn1, ImageType.JPG, rect.getX(), rect.getY(), rect.getWidth() * 8, rect.getHeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("reportRatifyByName".equals(bindingPath) && reqDTO.getReportRatifyByImg() != null) {
|
|
|
+ try (InputStream tempIn4 = new ByteArrayInputStream(reqDTO.getReportRatifyByImg())) {
|
|
|
+ Rectangle rect = CellInfo.GetRangeBoundary(worksheet.getRange(cell.getAddress()));
|
|
|
+ worksheet.getShapes().addPictureInPixel(tempIn4, ImageType.JPG, rect.getX(), rect.getY(), rect.getWidth() * 8, rect.getHeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
// 子报告
|
|
|
if (CollUtil.isNotEmpty(reqDTO.getSubReportList())) {
|
|
|
@@ -148,10 +180,6 @@ public class GrapeCityApiImpl implements GrapeCityApi {
|
|
|
|
|
|
}
|
|
|
Workbook.FontsFolderPath = fontsFolderPath;
|
|
|
-// PrintManager printManager = new PrintManager();
|
|
|
-//
|
|
|
-// List<PageInfo> pages = printManager.paginate(reportWorkbook);
|
|
|
-// printManager.savePageInfosToPDF(response.getOutputStream(), pages);
|
|
|
// 设置PdfSaveOptions以将工作簿导出为PDF文件。
|
|
|
PdfSaveOptions pdfOptions = new PdfSaveOptions();
|
|
|
pdfOptions.setIncludeAutoMergedCells(true);
|