From 4f8b669cb6d506670cfb714576fb415d16fd7de1 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Fri, 24 May 2024 17:30:51 +0800 Subject: [PATCH] update cost and expense report dataformat --- .../ffii/tsms/modules/report/service/ReportService.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt index 81fc06a..126f1fe 100644 --- a/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt +++ b/src/main/java/com/ffii/tsms/modules/report/service/ReportService.kt @@ -2207,6 +2207,9 @@ open class ReportService( val templateInputStream = resource.inputStream val workbook: Workbook = XSSFWorkbook(templateInputStream) + val accountingStyle = workbook.createDataFormat().getFormat("_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)") + val percentStyle = workbook.createDataFormat().getFormat("0.00%") + val sheet = workbook.getSheetAt(0) var rowNum = 0 rowNum = 1 @@ -2282,23 +2285,29 @@ open class ReportService( val budget = item["budget"] as Double * 0.8 cell5.apply { setCellValue(budget) +// cellStyle.dataFormat = accountingStyle } + CellUtil.setCellStyleProperty(cell5, "dataFormat", accountingStyle) val cell6 = row.getCell(6) ?: row.createCell(6) val manHoutsSpentCost = item["manhourExpenditure"] as Double cell6.apply { setCellValue(manHoutsSpentCost) } + CellUtil.setCellStyleProperty(cell6, "dataFormat", accountingStyle) val cell7 = row.getCell(7) ?: row.createCell(7) cell7.apply { cellFormula = "F${rowNum+1}-G${rowNum+1}" } + CellUtil.setCellStyleProperty(cell7, "dataFormat", accountingStyle) val cell8 = row.getCell(8) ?: row.createCell(8) cell8.apply { cellFormula = "H${rowNum+1}/F${rowNum+1}" } + CellUtil.setCellStyleProperty(cell8, "dataFormat", percentStyle) + sheet.setRowBreak(rowNum++); }