|
@@ -16,6 +16,7 @@ import com.sundata.product.rwa.util.DataUtil;
|
|
|
import org.apache.commons.text.StringSubstitutor;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.ss.util.CellUtil;
|
|
|
+import org.apache.poi.ss.util.SheetUtil;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jxls.builder.JxlsOutputFile;
|
|
|
import org.jxls.transform.poi.JxlsPoiTemplateFillerBuilder;
|
|
@@ -110,6 +111,7 @@ public class ReportCalcService {
|
|
|
Map<String, List<ReportCalculationModel>> selectCalcReportDatas = service.selectCalcReportData(reportDefinitionModel.getReportNo());
|
|
|
// 这张报表需要公式计算的 计算单元,配置中,需要明确,一旦公式类型,必须配置Excel来源公式 字典:UNIT_STYLE_TYPE
|
|
|
List<ReportCalculationModel> fillInCalcs = selectCalcReportDatas.get("FillIn").stream().filter(e -> "1".equals(e.getUnitStyleType())).toList();
|
|
|
+ fillInCalcs.addAll(selectCalcReportDatas.get("Calc"));
|
|
|
File tempTmpFile = createTempReport(reportDefinitionModel, calcIndex, dataDate, context);
|
|
|
tempTmpFiles.add(tempTmpFile);
|
|
|
log.debug("复制临时模板文件内容到 mainTmpWorkbook 文件中,并将配置的Excel公式,其他报表来源公式均配置到 mainTmpWorkbook 中");
|
|
@@ -124,32 +126,21 @@ public class ReportCalcService {
|
|
|
for (int j = tempSheet.getFirstRowNum(); j < tempSheet.getLastRowNum(); j++) {
|
|
|
int finalJ = j;
|
|
|
List<ReportCalculationModel> thisRowNumModel = thisSheetNumModel.stream().filter(e -> finalJ == (e.getReportUnitRow())).toList();
|
|
|
- Row tempRow = tempSheet.getRow(j);
|
|
|
+ Row tempRow = CellUtil.getRow(j,tempSheet);
|
|
|
if (tempRow != null) {
|
|
|
Row mainTmpRow = mainTmpSheet.createRow(j);
|
|
|
for (int k = tempRow.getFirstCellNum(); k < tempRow.getLastCellNum(); k++) {
|
|
|
int finalK = k;
|
|
|
List<ReportCalculationModel> thisCellNumModel = thisRowNumModel.stream().filter(e -> finalK == (e.getReportUnitCell())).toList();
|
|
|
- Cell tempCell = tempRow.getCell(k);
|
|
|
+ Cell tempCell = CellUtil.getCell(tempRow,k);
|
|
|
Cell mainTmpCell = null;
|
|
|
if (tempCell != null) {
|
|
|
+ mainTmpCell = CellUtil.getCell(mainTmpRow,k);
|
|
|
switch (tempCell.getCellType()) {
|
|
|
- case STRING -> {
|
|
|
- mainTmpCell = mainTmpRow.createCell(k,CellType.STRING);
|
|
|
- mainTmpCell.setCellValue(tempCell.getStringCellValue());
|
|
|
- }
|
|
|
- case NUMERIC -> {
|
|
|
- mainTmpCell = mainTmpRow.createCell(k,CellType.NUMERIC);
|
|
|
- mainTmpCell.setCellValue(tempCell.getNumericCellValue());
|
|
|
- }
|
|
|
- case FORMULA -> {
|
|
|
- mainTmpCell = mainTmpRow.createCell(k,CellType.FORMULA);
|
|
|
- mainTmpCell.setCellFormula(tempCell.getCellFormula());
|
|
|
- }
|
|
|
- default -> {
|
|
|
- mainTmpCell = mainTmpRow.createCell(k,CellType.STRING);
|
|
|
- mainTmpCell.setCellValue("");
|
|
|
- }
|
|
|
+ case STRING -> mainTmpCell.setCellValue(tempCell.getStringCellValue());
|
|
|
+ case NUMERIC -> mainTmpCell.setCellValue(tempCell.getNumericCellValue());
|
|
|
+ case FORMULA -> mainTmpCell.setCellFormula(tempCell.getCellFormula());
|
|
|
+ default -> mainTmpCell.setCellValue("");
|
|
|
}
|
|
|
}
|
|
|
if (thisCellNumModel.size() == 1) {
|