Refactor report merging logic in ReportService for improved clarity and consistency
- Replaced the existing mergeIfNeeded method with a more descriptive mergeTitleRegion method to enhance readability. - Updated report generation logic to use the new merging method for both title and subtitle rows in Excel reports. - Ensured consistent merging behavior across different report sections by standardizing the merging approach.
This commit is contained in:
parent
8224cd02f5
commit
b5e88d562e
|
|
@ -169,11 +169,11 @@ public class ReportService {
|
|||
Row titleRow = sheet.createRow(0);
|
||||
titleRow.setHeightInPoints(28);
|
||||
createCell(titleRow, 0, "한화 연결 집계 요약", styles.get("title"));
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
|
||||
mergeTitleRegion(sheet, 0, 4);
|
||||
|
||||
Row subtitleRow = sheet.createRow(1);
|
||||
createCell(subtitleRow, 0, "회계기간 " + fiscalPeriod + " | 생성시각 " + generatedAt(), styles.get("subtitle"));
|
||||
sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 3));
|
||||
mergeTitleRegion(sheet, 1, 4);
|
||||
|
||||
Row sectionRow = sheet.createRow(3);
|
||||
createCell(sectionRow, 0, "주요 지표", styles.get("section"));
|
||||
|
|
@ -210,11 +210,11 @@ public class ReportService {
|
|||
Row titleRow = sheet.createRow(0);
|
||||
titleRow.setHeightInPoints(24);
|
||||
createCell(titleRow, 0, sheetName, styles.get("title"));
|
||||
mergeIfNeeded(sheet, 0, columnCount);
|
||||
mergeTitleRegion(sheet, 0, columnCount);
|
||||
|
||||
Row subtitleRow = sheet.createRow(1);
|
||||
createCell(subtitleRow, 0, "회계기간 " + fiscalPeriod + " | 건수 " + rows.size(), styles.get("subtitle"));
|
||||
mergeIfNeeded(sheet, 1, columnCount);
|
||||
mergeTitleRegion(sheet, 1, columnCount);
|
||||
|
||||
if (rows.isEmpty()) {
|
||||
Row emptyRow = sheet.createRow(3);
|
||||
|
|
@ -356,10 +356,9 @@ public class ReportService {
|
|||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
private void mergeIfNeeded(Sheet sheet, int rowIndex, int columnCount) {
|
||||
if (columnCount > 1) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, columnCount - 1));
|
||||
}
|
||||
private void mergeTitleRegion(Sheet sheet, int rowIndex, int columnCount) {
|
||||
int lastColumn = Math.max(1, columnCount - 1);
|
||||
sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, lastColumn));
|
||||
}
|
||||
|
||||
private CellStyle styleForKey(Map<String, CellStyle> styles, String key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue