Export "Engineering Project Progress Payment Plan" to Excel with Java (Styled & Formatted Reports)
Styled & Formatted ReportsScene 0094
Registers the contract amount and completion progress per engineering milestone, computing Progress Payment Due = Contract Amount × Completion Progress and Unpaid Amount = Progress Payment Due - Paid Amount, with the last row summarizing contract, due and paid amounts and giving the total unpaid; the milestone with the largest unpaid amount is marked in red. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Engineering Project Progress Payment Plan" workbook: 1 data sheet(s); MAPPING over 7 columns (工程节点, 计划完成日, 合同金额, 完成进度, 应付进度款, 已付金额, 待付金额), 18 formula(s), 1 style rule(s). On the Java side it builds 7 data rows and calls exportProjectPaymentPlan() once — everything else is driven by the config.
It belongs to the "Styled & Formatted Reports" group: STYLE and conditional formatting: themed headers, zebra striping, highlighted total rows and threshold-based colouring of abnormal cells.
What you can copy from this page
- The complete Java test class (76 lines, runnable as-is)
- The complete XML config (33 lines: mapping, formulas, styles, charts and every other rule)
- The exported xlsx file (real output, comparable with the preview above)
Related searches: Java export Excel styles, Java Excel header style zebra rows, Apache POI CellStyle export, Java Excel conditional formatting, export Engineering Project Progress Payment Plan to Excel with Java
Output specs
- Scene no.
- 0094
- Group
- Styled & Formatted Reports
- Config lines
- 33
- Source lines
- 76
Java source · Style0094ProjectPaymentPlanDemo.java
This is the complete test class that produced the Excel file above — copy it and run as-is. Java only builds the data rows; all statistics and styling live in the XML config.
package com.github.paohaijiao.biz.style;
import com.github.paohaijiao.statement.JQuickRow;
import com.github.paohaijiao.xml.ex.JQuickExcelExportXmlParseFactory;
import com.github.paohaijiao.xml.factory.JQuickFactory;
import com.github.paohaijiao.xml.factory.JQuickXmlFactory;
import com.github.paohaijiao.xml.handler.JQuickParseHandler;
import org.junit.Test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class Style0094ProjectPaymentPlanDemo {
private static final String XML = "jquick/biz/style/0094_style_project-payment-plan.xml";
/** 导出:纯 XML 完成逐行应付进度款、待付、合计与待付最大节点标红。 */
@Test
public void exportProjectPaymentPlan() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
// e/g 留空,由 FORMULAS 计算
rows.add(node("开工准备", date(2026, 3, 1), 200000.00, 0.10, 20000.00));
rows.add(node("基础施工", date(2026, 5, 1), 200000.00, 0.30, 55000.00));
rows.add(node("主体结构", date(2026, 8, 1), 200000.00, 0.50, 60000.00));
rows.add(node("装饰装修", date(2026, 10, 1), 200000.00, 0.70, 110000.00));
rows.add(node("设备安装", date(2026, 12, 1), 200000.00, 0.90, 160000.00));
rows.add(node("竣工验收", date(2027, 2, 1), 200000.00, 1.00, 195000.00));
// 合计占位行:合同、应付、已付与待付合计留给 FORMULAS
JQuickRow total = new JQuickRow();
total.put("a", "合计");
total.put("b", null);
total.put("c", null);
total.put("d", null);
total.put("e", null);
total.put("f", null);
total.put("g", null);
rows.add(total);
File out = new File("D:/test/excel/biz/style/0094_style_project-payment-plan.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("charcoal", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0094ProjectPaymentPlanService service = factory.createApi(Style0094ProjectPaymentPlanService.class);
service.exportProjectPaymentPlan("field", "value");
}
}
/** 构造一个工程节点(a=节点,b=计划完成日,c=合同金额,d=完成进度,e/g 留空,f=已付金额)。 */
private static JQuickRow node(String projectNode, Date planDate, double contractAmount,
double progress, double paidAmount) {
JQuickRow row = new JQuickRow();
row.put("a", projectNode);
row.put("b", planDate);
row.put("c", contractAmount);
row.put("d", progress);
row.put("e", null);
row.put("f", paidAmount);
row.put("g", null);
return row;
}
/** 构造日期(月份按自然月 1-12 传入)。 */
private static Date date(int year, int month, int day) {
Calendar c = Calendar.getInstance();
c.clear();
c.set(year, month - 1, day);
return c.getTime();
}
}Minimal invocation (4 lines)
The core is these four lines: hand the rows to the parser, the parser to the factory, get a typed Service and call it. Copy them straight into your project.
// rows 由业务代码构造(List<JQuickRow>),os 为输出流,见下方完整源码
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("charcoal", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0094ProjectPaymentPlanService service = factory.createApi(Style0094ProjectPaymentPlanService.class);XML config · 0094_style_project-payment-plan.xml
Formats (FORMAT), formulas (FORMULAS) and styles (STYLE) are all declared in this XML, fully decoupled from the Java code. The full config is below — copy it as-is.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE excels PUBLIC "-//PAOHAIJIAO//DTD API EXCEL 1.0//EN"
"classpath:paohaijiao/dtd/Jquick-excel.dtd">
<excels namespace="com.github.paohaijiao.biz.style.Style0094ProjectPaymentPlanService">
<!-- 导出:工程项目进度款支付计划表 -->
<excel name="exportProjectPaymentPlan" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="工程项目进度款支付计划表", HEADER=true,
MAPPING={"a":"工程节点","b":"计划完成日","c":"合同金额","d":"完成进度","e":"应付进度款","f":"已付金额","g":"待付金额"},
FORMAT={"b":"yyyy-MM-dd","c":"#,##0.00","d":"0%","e":"#,##0.00","f":"#,##0.00","g":"#,##0.00"},
FORMULAS={
E2:'C2*D2',G2:'E2-F2', E3:'C3*D3',G3:'E3-F3', E4:'C4*D4',G4:'E4-F4',
E5:'C5*D5',G5:'E5-F5', E6:'C6*D6',G6:'E6-F6', E7:'C7*D7',G7:'E7-F7',
C8:'SUM(C2:C7)',E8:'SUM(E2:E7)',F8:'SUM(F2:F7)',G8:'E8-F8'
},
STYLE={
ROW 8:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
G4:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的工程项目进度款支付计划表 -->
<excel name="importProjectPaymentPlan" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="工程项目进度款支付计划表", HEADER=true,
MAPPING={"工程节点":"projectNode","计划完成日":"planDate","合同金额":"contractAmount","完成进度":"progress","应付进度款":"payableAmount","已付金额":"paidAmount","待付金额":"pendingAmount"}
]]>
</excel>
</excels>More demos in this group
The Excel file, preview image, XML config and source code on this page were all produced by a real JQuick-Excel run and are free to copy into your own project.