|
|
@@ -16,7 +16,7 @@ import java.time.LocalDate |
|
|
|
import java.time.format.DateTimeFormatter |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
data class DayInfo(val date: String, val weekday: String) |
|
|
|
data class DayInfo(val date: String?, val weekday: String?) |
|
|
|
@Service |
|
|
|
open class ReportService { |
|
|
|
private val DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd") |
|
|
@@ -310,9 +310,11 @@ open class ReportService { |
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
rowIndex = 7 |
|
|
|
println(daysOfMonth) |
|
|
|
daysOfMonth.forEach { dayInfo -> |
|
|
|
rowIndex++ |
|
|
|
rowSize++ |
|
|
|
println(dayInfo) |
|
|
|
sheet.getRow(rowIndex).getCell(0).apply { |
|
|
|
setCellValue(dayInfo.date) |
|
|
|
cellStyle.setFont(boldFont) |
|
|
@@ -326,12 +328,16 @@ open class ReportService { |
|
|
|
rowIndex += 1 |
|
|
|
sheet.getRow(rowIndex).getCell(0).apply { |
|
|
|
setCellValue("Sub-total") |
|
|
|
cellStyle.setFont(boldFont) |
|
|
|
cellStyle.alignment = HorizontalAlignment.CENTER |
|
|
|
} |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
// |
|
|
|
rowIndex += 1 |
|
|
|
sheet.getRow(rowIndex).getCell(0).apply { |
|
|
|
setCellValue("Total Normal Hours [A]") |
|
|
|
// cellStyle.setFont(boldFont) |
|
|
|
cellStyle.alignment = HorizontalAlignment.CENTER |
|
|
|
} |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
// |
|
|
@@ -339,12 +345,16 @@ open class ReportService { |
|
|
|
sheet.getRow(rowIndex).getCell(0).apply { |
|
|
|
setCellValue("Total Other Hours [B]") |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
cellStyle.setFont(boldFont) |
|
|
|
cellStyle.alignment = HorizontalAlignment.CENTER |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex += 1 |
|
|
|
sheet.getRow(rowIndex).getCell(0).apply { |
|
|
|
setCellValue("Total Spent Manhours [A+B]") |
|
|
|
// cellStyle.borderBottom = BorderStyle.DOUBLE |
|
|
|
// cellStyle.setFont(boldFont) |
|
|
|
cellStyle.alignment = HorizontalAlignment.CENTER |
|
|
|
cellStyle.borderBottom = BorderStyle.DOUBLE |
|
|
|
} |
|
|
|
sheet.addMergedRegion(CellRangeAddress(rowIndex,rowIndex , 0, 1)) |
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
@@ -363,7 +373,7 @@ open class ReportService { |
|
|
|
columnIndex += 1 |
|
|
|
getCell(columnIndex).setCellValue("Daily Manhour Spent\n" + "(Excluding Leave Hours)") |
|
|
|
getCell(columnIndex).cellStyle.alignment = HorizontalAlignment.CENTER |
|
|
|
// columnSize = columnIndex |
|
|
|
columnSize = columnIndex |
|
|
|
} |
|
|
|
sheet.addMergedRegion(CellRangeAddress(6,6 , 2, columnIndex)) |
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
@@ -389,17 +399,23 @@ open class ReportService { |
|
|
|
} |
|
|
|
|
|
|
|
rowIndex = 8 |
|
|
|
println("rowSize is: $rowSize") |
|
|
|
// println("rowSize is: $rowSize") |
|
|
|
if (sheet.getRow(rowIndex - 1).getCell(2).stringCellValue == "Leave Hours") { |
|
|
|
for (i in 0 until rowSize) { |
|
|
|
val cell = sheet.getRow(rowIndex + i)?.getCell(columnIndex) ?: sheet.getRow(rowIndex + i)?.createCell(columnIndex) |
|
|
|
cell?.cellFormula = "SUM(${getColumnAlphabet(2)}${rowIndex+1+i}:${getColumnAlphabet(columnIndex)}${rowIndex+1+i})" // should columnIndex - 2 |
|
|
|
val cell = sheet.getRow(rowIndex)?.getCell(columnIndex) ?: sheet.getRow(rowIndex + i)?.createCell(columnIndex) |
|
|
|
cell?.cellFormula = "SUM(${getColumnAlphabet(2)}${rowIndex+1}:${getColumnAlphabet(columnIndex)}${rowIndex+1})" // should columnIndex - 2 |
|
|
|
rowIndex++ |
|
|
|
// cell?.setCellValue("testing") |
|
|
|
// rowIndex++ |
|
|
|
} |
|
|
|
// for (i in 0 until columnSize) { |
|
|
|
// val cell = sheet.getRow(rowIndex) |
|
|
|
// } |
|
|
|
// println(columnSize) |
|
|
|
for (i in 0 until columnSize) { // minus last col |
|
|
|
val cell = sheet.getRow(rowIndex)?.getCell(2) ?: sheet.getRow(rowIndex)?.createCell(2) |
|
|
|
cell?.cellFormula = "SUM(${getColumnAlphabet(2)}${rowIndex}:${getColumnAlphabet(columnIndex + i)}${rowIndex})" |
|
|
|
cell?.cellStyle?.dataFormat = accountingStyle |
|
|
|
cell?.cellStyle?.setFont(boldFont) |
|
|
|
// cell?.cellStyle.borderBottom = border |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return workbook |
|
|
|