|
|
@@ -79,6 +79,8 @@ public class YakOutboundReportExcelExporter
|
|
79
|
79
|
updateTitleYearMonth(sheet, statYear, statMonth);
|
|
80
|
80
|
updateFiller(sheet, fillerName);
|
|
81
|
81
|
int dataStartRow = headerRowIndex + 1;
|
|
|
82
|
+ CellStyle[] dataRowStyles = captureDataRowStyles(sheet, dataStartRow);
|
|
|
83
|
+ Float dataRowHeight = captureRowHeight(sheet, dataStartRow);
|
|
82
|
84
|
clearTemplateDataRegion(sheet, dataStartRow);
|
|
83
|
85
|
Totals totals = new Totals();
|
|
84
|
86
|
int rowIndex = dataStartRow;
|
|
|
@@ -96,6 +98,7 @@ public class YakOutboundReportExcelExporter
|
|
96
|
98
|
setIntegerCell(row, COL_SEQ, seq++);
|
|
97
|
99
|
setStringCell(row, YakOutboundReportExcelParser.COL_TOWN, report.getTownName());
|
|
98
|
100
|
fillDataRow(row, report);
|
|
|
101
|
+ applyDataRowStyles(row, dataRowStyles, dataRowHeight);
|
|
99
|
102
|
if (report.getVillageDeptId() != null || report.getYakOutboundCount() != null
|
|
100
|
103
|
|| report.getFarmerHouseholdCount() != null)
|
|
101
|
104
|
{
|
|
|
@@ -107,8 +110,9 @@ public class YakOutboundReportExcelExporter
|
|
107
|
110
|
Row totalRow = getOrCreateRow(sheet, rowIndex);
|
|
108
|
111
|
clearDataCells(totalRow);
|
|
109
|
112
|
setStringCell(totalRow, COL_SEQ, "合计");
|
|
110
|
|
- mergeTotalLabelCells(sheet, rowIndex);
|
|
111
|
113
|
totals.writeToRow(totalRow);
|
|
|
114
|
+ applyDataRowStyles(totalRow, dataRowStyles, dataRowHeight);
|
|
|
115
|
+ mergeTotalLabelCells(sheet, rowIndex);
|
|
112
|
116
|
removeRowsAfter(sheet, rowIndex);
|
|
113
|
117
|
workbook.write(out);
|
|
114
|
118
|
return out.toByteArray();
|
|
|
@@ -346,6 +350,62 @@ public class YakOutboundReportExcelExporter
|
|
346
|
350
|
return row;
|
|
347
|
351
|
}
|
|
348
|
352
|
|
|
|
353
|
+ /** 从模板样例数据行捕获各列样式,供数据行与合计行复用(避免第 3 行起/合计行丢边框) */
|
|
|
354
|
+ private static CellStyle[] captureDataRowStyles(Sheet sheet, int styleSourceRow)
|
|
|
355
|
+ {
|
|
|
356
|
+ CellStyle[] styles = new CellStyle[YakOutboundReportExcelParser.COL_LAST + 1];
|
|
|
357
|
+ Row src = sheet.getRow(styleSourceRow);
|
|
|
358
|
+ if (src == null)
|
|
|
359
|
+ {
|
|
|
360
|
+ return styles;
|
|
|
361
|
+ }
|
|
|
362
|
+ for (int col = 0; col < styles.length; col++)
|
|
|
363
|
+ {
|
|
|
364
|
+ Cell cell = src.getCell(col);
|
|
|
365
|
+ if (cell != null)
|
|
|
366
|
+ {
|
|
|
367
|
+ styles[col] = cell.getCellStyle();
|
|
|
368
|
+ }
|
|
|
369
|
+ }
|
|
|
370
|
+ return styles;
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+ private static Float captureRowHeight(Sheet sheet, int styleSourceRow)
|
|
|
374
|
+ {
|
|
|
375
|
+ Row src = sheet.getRow(styleSourceRow);
|
|
|
376
|
+ if (src == null)
|
|
|
377
|
+ {
|
|
|
378
|
+ return null;
|
|
|
379
|
+ }
|
|
|
380
|
+ return src.getHeightInPoints();
|
|
|
381
|
+ }
|
|
|
382
|
+
|
|
|
383
|
+ private static void applyDataRowStyles(Row row, CellStyle[] styles, Float rowHeight)
|
|
|
384
|
+ {
|
|
|
385
|
+ if (row == null || styles == null)
|
|
|
386
|
+ {
|
|
|
387
|
+ return;
|
|
|
388
|
+ }
|
|
|
389
|
+ if (rowHeight != null && rowHeight > 0)
|
|
|
390
|
+ {
|
|
|
391
|
+ row.setHeightInPoints(rowHeight);
|
|
|
392
|
+ }
|
|
|
393
|
+ for (int col = 0; col < styles.length; col++)
|
|
|
394
|
+ {
|
|
|
395
|
+ CellStyle style = styles[col];
|
|
|
396
|
+ if (style == null)
|
|
|
397
|
+ {
|
|
|
398
|
+ continue;
|
|
|
399
|
+ }
|
|
|
400
|
+ Cell cell = row.getCell(col);
|
|
|
401
|
+ if (cell == null)
|
|
|
402
|
+ {
|
|
|
403
|
+ cell = row.createCell(col);
|
|
|
404
|
+ }
|
|
|
405
|
+ cell.setCellStyle(style);
|
|
|
406
|
+ }
|
|
|
407
|
+ }
|
|
|
408
|
+
|
|
349
|
409
|
private static void fillDataRow(Row row, BizYakOutboundReport report)
|
|
350
|
410
|
{
|
|
351
|
411
|
setStringCell(row, YakOutboundReportExcelParser.COL_VILLAGE_NAME, report.getVillageName());
|