|
|
@ -120,34 +120,46 @@ public class ExpenseWorkbookWriter { |
|
|
// 原模板合并表头内部有残留出租车文字及 SUM(E4:F4),应清空隐藏子单元格 - rqrq。 |
|
|
// 原模板合并表头内部有残留出租车文字及 SUM(E4:F4),应清空隐藏子单元格 - rqrq。 |
|
|
cell(routes, 3, 4).setBlank(); |
|
|
cell(routes, 3, 4).setBlank(); |
|
|
cell(routes, 3, 7).setBlank(); |
|
|
cell(routes, 3, 7).setBlank(); |
|
|
|
|
|
// 第二页列布局调整:费用类型移到 B 列,出发地/到达地顺次后移,里程列删除(金额列左移到 G) - rqrq。表头在 row 2。 |
|
|
|
|
|
text(routes, 2, 1, "Expense Type\n费用类型"); |
|
|
|
|
|
text(routes, 2, 2, "From\n出发地"); |
|
|
|
|
|
text(routes, 2, 3, "To\n到达地"); |
|
|
|
|
|
text(routes, 2, 6, "Sub-total\n小计"); |
|
|
|
|
|
routes.setColumnWidth(1, 5600); |
|
|
|
|
|
cell(routes, 3, 6).setBlank(); |
|
|
|
|
|
cell(routes, 2, 7).setBlank(); |
|
|
CellStyle date = style(workbook, cell(routes, 4, 0).getCellStyle(), "yyyy-mm-dd"); |
|
|
CellStyle date = style(workbook, cell(routes, 4, 0).getCellStyle(), "yyyy-mm-dd"); |
|
|
CellStyle tripMoney = style(workbook, cell(routes, 4, 7).getCellStyle(), "#,##0.00"); |
|
|
CellStyle tripMoney = style(workbook, cell(routes, 4, 7).getCellStyle(), "#,##0.00"); |
|
|
CellStyle mileage = style(workbook, cell(routes, 4, 6).getCellStyle(), "0.##"); |
|
|
|
|
|
for (int i = 0; i < tripRows; i++) { |
|
|
for (int i = 0; i < tripRows; i++) { |
|
|
int row = 4 + i; |
|
|
int row = 4 + i; |
|
|
cell(routes, row, 0).setCellStyle(date); |
|
|
cell(routes, row, 0).setCellStyle(date); |
|
|
cell(routes, row, 7).setCellStyle(tripMoney); |
|
|
|
|
|
cell(routes, row, 6).setCellStyle(mileage); |
|
|
|
|
|
|
|
|
cell(routes, row, 6).setCellStyle(tripMoney); |
|
|
|
|
|
cell(routes, row, 7).setBlank(); |
|
|
if (i >= trips.size()) { |
|
|
if (i >= trips.size()) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
ExpenseTrip t = trips.get(i); |
|
|
ExpenseTrip t = trips.get(i); |
|
|
cell(routes, row, 0).setCellValue(t.getTripDate()); |
|
|
cell(routes, row, 0).setCellValue(t.getTripDate()); |
|
|
text(routes, row, 1, t.getStartPlace()); |
|
|
|
|
|
text(routes, row, 2, t.getEndPlace()); |
|
|
|
|
|
text(routes, row, 3, t.getExpenseDesc()); |
|
|
|
|
|
|
|
|
text(routes, row, 1, t.getExpenseDesc()); |
|
|
|
|
|
text(routes, row, 2, t.getStartPlace()); |
|
|
|
|
|
text(routes, row, 3, t.getEndPlace()); |
|
|
text(routes, row, 4, t.getVehicle()); |
|
|
text(routes, row, 4, t.getVehicle()); |
|
|
number(routes, row, 5, t.getBillCount()); |
|
|
number(routes, row, 5, t.getBillCount()); |
|
|
decimal(routes, row, 6, t.getMileage()); |
|
|
|
|
|
decimal(routes, row, 7, ExpenseReportServiceImpl.amount(t.getAmount(), "行程金额")); |
|
|
|
|
|
|
|
|
decimal(routes, row, 6, ExpenseReportServiceImpl.amount(t.getAmount(), "行程金额")); |
|
|
routes.getRow(row).setHeightInPoints(Math.max(30, |
|
|
routes.getRow(row).setHeightInPoints(Math.max(30, |
|
|
14 * Math.max((t.getExpenseDesc().length() + 19) / 20, |
|
|
14 * Math.max((t.getExpenseDesc().length() + 19) / 20, |
|
|
(Math.max(t.getStartPlace().length(), t.getEndPlace().length()) + 9) / 10))); |
|
|
(Math.max(t.getStartPlace().length(), t.getEndPlace().length()) + 9) / 10))); |
|
|
} |
|
|
} |
|
|
cell(routes, tripTotal, 7).setCellFormula(dynamicSum("H", 5)); |
|
|
|
|
|
cell(routes, tripTotal, 7).setCellStyle(tripMoney); |
|
|
|
|
|
|
|
|
cell(routes, tripTotal, 6).setCellFormula(dynamicSum("G", 5)); |
|
|
|
|
|
cell(routes, tripTotal, 6).setCellStyle(tripMoney); |
|
|
|
|
|
cell(routes, tripTotal, 7).setBlank(); |
|
|
text(routes, tripTotal + 3, 6, headers.get(0).getApplyUserName()); |
|
|
text(routes, tripTotal + 3, 6, headers.get(0).getApplyUserName()); |
|
|
print(workbook, routes, 1, 7, tripTotal + 3, 2, 3); |
|
|
|
|
|
|
|
|
print(workbook, routes, 1, 6, tripTotal + 3, 2, 3); |
|
|
|
|
|
// 清除 H 列残留边框(模板原金额列样式带有边框) - rqrq。 |
|
|
|
|
|
CellStyle noBorder = workbook.createCellStyle(); |
|
|
|
|
|
for (int row = 0; row <= tripTotal + 3; row++) { |
|
|
|
|
|
cell(routes, row, 7).setCellStyle(noBorder); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 4) 常规公式后端算缓存,并保留公式供 Excel/WPS 打开及手工改动后重算 - rqrq。 |
|
|
// 4) 常规公式后端算缓存,并保留公式供 Excel/WPS 打开及手工改动后重算 - rqrq。 |
|
|
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll(); |
|
|
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll(); |
|
|
|