|
@@ -1505,27 +1505,31 @@ open class ReportService( |
|
|
lateStartData: List<Map<String, Any>>, |
|
|
lateStartData: List<Map<String, Any>>, |
|
|
evaluator: FormulaEvaluator |
|
|
evaluator: FormulaEvaluator |
|
|
) { |
|
|
) { |
|
|
var dataRowIndex = 6 // Start populating data from row index 7 |
|
|
|
|
|
|
|
|
var dataRowIndex = 6 |
|
|
|
|
|
|
|
|
|
|
|
// Populate the rows with data from the database |
|
|
lateStartData.forEachIndexed { index, data -> |
|
|
lateStartData.forEachIndexed { index, data -> |
|
|
val row = sheet.getRow(dataRowIndex) ?: sheet.createRow(dataRowIndex) |
|
|
val row = sheet.getRow(dataRowIndex) ?: sheet.createRow(dataRowIndex) |
|
|
populateDataRow(workbook, sheet, row, data, index) |
|
|
populateDataRow(workbook, sheet, row, data, index) |
|
|
dataRowIndex++ |
|
|
dataRowIndex++ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Update and apply conditional formatting to highlight specific values in column J |
|
|
|
|
|
val sheetCF = sheet.sheetConditionalFormatting |
|
|
|
|
|
val rule1 = sheetCF.createConditionalFormattingRule("J7 < 60") |
|
|
|
|
|
val pattern1 = rule1.createPatternFormatting().apply { |
|
|
|
|
|
fillBackgroundColor = IndexedColors.RED.index |
|
|
|
|
|
fillPattern = PatternFormatting.SOLID_FOREGROUND |
|
|
|
|
|
} |
|
|
|
|
|
val rule2 = sheetCF.createConditionalFormattingRule("J7 >= 60") |
|
|
|
|
|
val pattern2 = rule2.createPatternFormatting().apply { |
|
|
|
|
|
fillBackgroundColor = IndexedColors.YELLOW.index |
|
|
|
|
|
fillPattern = PatternFormatting.SOLID_FOREGROUND |
|
|
|
|
|
} |
|
|
|
|
|
val region = CellRangeAddress(dataRowIndex - lateStartData.size, dataRowIndex - 1, 9, 9) // Column J |
|
|
|
|
|
sheetCF.addConditionalFormatting(arrayOf(region), arrayOf(rule1, rule2)) |
|
|
|
|
|
|
|
|
// Only apply conditional formatting if there is data |
|
|
|
|
|
if (lateStartData.isNotEmpty()) { |
|
|
|
|
|
val sheetCF = sheet.sheetConditionalFormatting |
|
|
|
|
|
val rule1 = sheetCF.createConditionalFormattingRule("J7 < 60") |
|
|
|
|
|
val pattern1 = rule1.createPatternFormatting().apply { |
|
|
|
|
|
fillBackgroundColor = IndexedColors.RED.index |
|
|
|
|
|
fillPattern = PatternFormatting.SOLID_FOREGROUND |
|
|
|
|
|
} |
|
|
|
|
|
val rule2 = sheetCF.createConditionalFormattingRule("J7 >= 60") |
|
|
|
|
|
val pattern2 = rule2.createPatternFormatting().apply { |
|
|
|
|
|
fillBackgroundColor = IndexedColors.YELLOW.index |
|
|
|
|
|
fillPattern = PatternFormatting.SOLID_FOREGROUND |
|
|
|
|
|
} |
|
|
|
|
|
val region = CellRangeAddress(6, dataRowIndex - 1, 9, 9) // Column J |
|
|
|
|
|
sheetCF.addConditionalFormatting(arrayOf(region), arrayOf(rule1, rule2)) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Sets team and client IDs in the sheet to manage data visibility based on the selected team and client |
|
|
// Sets team and client IDs in the sheet to manage data visibility based on the selected team and client |
|
|