From 84f7b98599d7669c31395081f73a85dde5e7e911 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Thu, 16 May 2024 20:39:56 +0800 Subject: [PATCH] update work report --- .../modules/report/service/ReportService.kt | 63 ++++++++++++------ ...08_Monthly Work Hours Analysis Report.xlsx | Bin 15817 -> 15819 bytes 2 files changed, 41 insertions(+), 22 deletions(-) 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 72c6c38..2fe91c3 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 @@ -381,6 +381,10 @@ open class ReportService( val monthStyle = workbook.createDataFormat().getFormat("mmm, yyyy") val dateStyle = workbook.createDataFormat().getFormat("dd/mm/yyyy") + val boldStyle = workbook.createCellStyle() + val boldFont = workbook.createFont() + boldFont.bold = true + boldStyle.setFont(boldFont) val daysOfMonth = (1..month.lengthOfMonth()).map { day -> val date = month.withDayOfMonth(day) val formattedDate = date.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) @@ -390,8 +394,6 @@ open class ReportService( val sheet: Sheet = workbook.getSheetAt(0) - val boldFont = sheet.workbook.createFont() - boldFont.bold = true // sheet.forceFormulaRecalculation = true; //Calculate formulas var rowIndex = 1 // Assuming the location is in (1,2), which is the report date field @@ -403,22 +405,27 @@ open class ReportService( var dayInt = 0 var tempCell: Cell - tempCell = sheet.getRow(rowIndex).createCell(columnIndex) - tempCell.setCellValue(FORMATTED_TODAY) + sheet.getRow(rowIndex).createCell(columnIndex).apply { + setCellValue(FORMATTED_TODAY) + } rowIndex = 2 - tempCell = sheet.getRow(rowIndex).createCell(columnIndex) - tempCell.setCellValue(month) - tempCell.cellStyle.dataFormat = monthStyle + sheet.getRow(rowIndex).getCell(columnIndex).apply { + setCellValue(month) +// cellStyle.setFont(boldStyle) + + cellStyle.dataFormat = monthStyle + } rowIndex = 3 - tempCell. sheet.getRow(rowIndex).createCell(columnIndex) - tempCell.setCellValue(staff.name) + sheet.getRow(rowIndex).createCell(columnIndex).apply { + setCellValue(staff.name) + } rowIndex = 4 - tempCell.sheet.getRow(rowIndex).createCell(columnIndex) - tempCell.setCellValue(staff.team.name) - + sheet.getRow(rowIndex).createCell(columnIndex).apply { + setCellValue(staff.team.name) + } rowIndex = 5 tempCell = sheet.getRow(rowIndex).createCell(columnIndex) @@ -430,6 +437,7 @@ open class ReportService( val ThinBorderBottom: MutableMap = mutableMapOf() ThinBorderBottom["borderBottom"] = BorderStyle.THIN + ThinBorderBottom["wrapText"] = true ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// rowIndex = 7 daysOfMonth.forEach { dayInfo -> @@ -437,12 +445,12 @@ open class ReportService( rowSize++ tempCell = sheet.getRow(rowIndex).createCell(0) tempCell.setCellValue(dayInfo.date) + tempCell.cellStyle = boldStyle tempCell.cellStyle.dataFormat = dateStyle - tempCell.cellStyle.setFont(boldFont) // cellStyle.alignment = HorizontalAlignment.LEFT tempCell = sheet.getRow(rowIndex).createCell(1) tempCell.setCellValue(dayInfo.weekday) - tempCell.cellStyle.setFont(boldFont) + tempCell.cellStyle = boldStyle // cellStyle.alignment = HorizontalAlignment.LEFT } @@ -450,7 +458,7 @@ open class ReportService( tempCell = sheet.getRow(rowIndex).createCell(0) sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) tempCell.setCellValue("Sub-total") - tempCell.cellStyle.setFont(boldFont) + tempCell.cellStyle = boldStyle CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) tempCell = sheet.getRow(rowIndex).createCell(1) @@ -459,6 +467,7 @@ open class ReportService( rowIndex += 1 tempCell = sheet.getRow(rowIndex).createCell(0) tempCell.setCellValue("Total Normal Hours [A]") + tempCell.cellStyle = boldStyle CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) var normalConsumed = 0.0 @@ -479,8 +488,8 @@ open class ReportService( rowIndex += 1 tempCell = sheet.getRow(rowIndex).createCell(0) tempCell.setCellValue("Total Other Hours [B]") + tempCell.cellStyle = boldStyle CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) - tempCell.cellStyle.setFont(boldFont) tempCell = sheet.getRow(rowIndex).createCell(2) tempCell.setCellValue(otConsumed) tempCell.cellStyle.dataFormat = accountingStyle @@ -492,6 +501,7 @@ open class ReportService( rowIndex += 1 tempCell = sheet.getRow(rowIndex).createCell(0) tempCell.setCellValue("Total Leave Hours") + tempCell.cellStyle = boldStyle CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) if (leaves.isNotEmpty()) { @@ -507,7 +517,7 @@ open class ReportService( rowIndex += 1 tempCell = sheet.getRow(rowIndex).createCell(0) tempCell.setCellValue("Total Spent Manhours [A+B]") - tempCell.cellStyle.setFont(boldFont) + tempCell.cellStyle = boldStyle CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) tempCell = sheet.getRow(rowIndex).createCell(1) @@ -526,9 +536,13 @@ open class ReportService( projectList.forEachIndexed { index, title -> tempCell = sheet.getRow(7).createCell(columnIndex + index) tempCell.setCellValue(title) - CellUtil.setAlignment(tempCell, HorizontalAlignment.RIGHT) + tempCell.cellStyle = boldStyle + CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) + CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) + columnSize++ } + println(columnSize) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (timesheets.isNotEmpty()) { projectList.forEach { _ -> @@ -564,11 +578,16 @@ open class ReportService( ///////////////////////////////////////////////////////// Leave Hours //////////////////////////////////////////////////////////////////// tempCell = sheet.getRow(rowIndex).createCell(columnIndex) tempCell.setCellValue("Leave Hours") + tempCell.cellStyle = boldStyle + CellUtil.setVerticalAlignment(tempCell, VerticalAlignment.CENTER) + CellUtil.setAlignment(tempCell, HorizontalAlignment.CENTER) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) columnIndex += 1 tempCell = sheet.getRow(rowIndex).createCell(columnIndex) tempCell.setCellValue("Daily Manhour Spent\n(Excluding Leave Hours)") + tempCell.cellStyle = boldStyle + CellUtil.setAlignment(tempCell, HorizontalAlignment.LEFT) CellUtil.setCellStyleProperties(tempCell, ThinBorderBottom) sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex)) @@ -583,18 +602,18 @@ open class ReportService( } // cal subtotal println(rowIndex) - for (i in 0 until columnSize - 2) { // minus last col - tempCell = sheet.getRow(rowIndex).createCell(2 + i) + for (i in 0 ..columnSize ) { // minus last col + println(sheet.getRow(rowIndex).getCell(2 + i)) + tempCell = sheet.getRow(rowIndex).getCell(2 + i) ?: sheet.getRow(rowIndex).createCell(2 + i) tempCell.cellFormula = "SUM(${getColumnAlphabet(2 + i)}9:${getColumnAlphabet(2 + i)}${rowIndex})" + tempCell.cellStyle = boldStyle tempCell.cellStyle.dataFormat = accountingStyle - tempCell.cellStyle.setFont(boldFont) CellUtil.setCellStyleProperties(tempCell, DoubleBorderBottom) } } return workbook } - @Throws(IOException::class) private fun createSalaryList( salarys: List, diff --git a/src/main/resources/templates/report/AR08_Monthly Work Hours Analysis Report.xlsx b/src/main/resources/templates/report/AR08_Monthly Work Hours Analysis Report.xlsx index 4922b4afe3b535bc8358b130064fc6778118843c..001d546e5e0f9d273b547ba826e4dc62193d522f 100644 GIT binary patch delta 2061 zcmV+o2=e#Id&_&U<^}}>IVY`(lj{Z^f1@}M{(jQ^2gG*@CXfVFx*`Fzm6}zRX4^Xn zsdB(6RsnOiX;Q8Bzuy=_+H6*fpJJqRZymOx(=v=IYZ zm7N1uVgB4UM#icJAl9^`^0foiwJP(kpK8YOx&*g($klcneq;C}3mSVk3ARp-s%XZU zU>kV>&}L8i#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