Export "Property Utility Fee Collection Ledger" to Excel with Java (Styled & Formatted Reports)
Styled & Formatted ReportsScene 0063
Registers receivables and receipts for property fees / water charges / electricity charges by unit number, computing Overdue Amount = Receivable - Received per row, with the last row summarizing receivable, received and overdue amounts; the overdue amount of delinquent households is marked in red. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Property Utility Fee Collection Ledger" workbook: 1 data sheet(s); MAPPING over 8 columns (房号, 户主, 费用类型, 应收金额, 已收金额, 欠缴金额, 缴费状态, 缴费日期), 10 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportUtilityFeeLedger() 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 (77 lines, runnable as-is)
- The complete XML config (32 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 Property Utility Fee Collection Ledger to Excel with Java
Output specs
- Scene no.
- 0063
- Group
- Styled & Formatted Reports
- Config lines
- 32
- Source lines
- 77
Java source · Style0063UtilityFeeLedgerDemo.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 Style0063UtilityFeeLedgerDemo {
private static final String XML = "jquick/biz/style/0063_style_utility-fee-ledger.xml";
/** 导出:纯 XML 完成欠缴金额计算、合计与欠缴户标红。 */
@Test
public void exportUtilityFeeLedger() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
// f=欠缴金额 留空,由 FORMULAS 计算
rows.add(line("A-1801", "张伟", "物业费", 2400.00, 2400.00, "已缴清", date(2026, 3, 5)));
rows.add(line("A-1802", "李娜", "物业费", 2400.00, 1200.00, "部分缴纳", date(2026, 3, 8)));
rows.add(line("B-0903", "王强", "水费", 680.00, 680.00, "已缴清", date(2026, 3, 10)));
rows.add(line("B-0904", "赵敏", "电费", 1560.00, 0.00, "欠缴", null));
rows.add(line("C-0605", "陈杰", "物业费", 3200.00, 3200.00, "已缴清", date(2026, 3, 15)));
// 合计占位行:应收 / 已收 / 欠缴 合计留给 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);
total.put("h", null);
rows.add(total);
File out = new File("D:/test/excel/biz/style/0063_style_utility-fee-ledger.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("emerald", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0063UtilityFeeLedgerService service = factory.createApi(Style0063UtilityFeeLedgerService.class);
service.exportUtilityFeeLedger("field", "value");
}
}
/** 构造一条收缴明细(a=房号,b=户主,c=费用类型,d=应收,e=已收,f=欠缴,g=状态,h=缴费日期)。 */
private static JQuickRow line(String roomNo, String owner, String feeType,
double receivable, double received, String payStatus, Date payDate) {
JQuickRow row = new JQuickRow();
row.put("a", roomNo);
row.put("b", owner);
row.put("c", feeType);
row.put("d", receivable);
row.put("e", received);
row.put("f", null);
row.put("g", payStatus);
row.put("h", payDate);
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("emerald", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0063UtilityFeeLedgerService service = factory.createApi(Style0063UtilityFeeLedgerService.class);XML config · 0063_style_utility-fee-ledger.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.Style0063UtilityFeeLedgerService">
<!-- 导出:物业水电费收缴台账 -->
<excel name="exportUtilityFeeLedger" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="物业水电费收缴台账", HEADER=true,
MAPPING={"a":"房号","b":"户主","c":"费用类型","d":"应收金额","e":"已收金额","f":"欠缴金额","g":"缴费状态","h":"缴费日期"},
FORMAT={"d":"#,##0.00","e":"#,##0.00","f":"#,##0.00","h":"yyyy-MM-dd"},
FORMULAS={
F2:'D2-E2',F3:'D3-E3',F4:'D4-E4',F5:'D5-E5',F6:'D6-E6',
D7:'SUM(D2:D6)',E7:'SUM(E2:E6)',F7:'SUM(F2:F6)'
},
STYLE={
ROW 7:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
F5:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的收缴台账 -->
<excel name="importUtilityFeeLedger" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="物业水电费收缴台账", HEADER=true,
MAPPING={"房号":"roomNo","户主":"owner","费用类型":"feeType","应收金额":"receivable","已收金额":"received","欠缴金额":"unpaid","缴费状态":"payStatus","缴费日期":"payDate"}
]]>
</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.