Export "Bank Statement Reconciliation" to Excel with Java (Chart & Visualization)
Chart & VisualizationScene 0014
Account transactions record debits and credits line by line and roll the balance forward (Balance = Previous Row Balance + Credit - Debit), with a total row at the end; includes a balance-trend line chart. Exported as a multi-sheet workbook (Bank Statement Reconciliation / Balance Trend). Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Bank Statement Reconciliation" workbook: 1 data sheet(s); MAPPING over 5 columns (交易日期, 摘要, 借方, 贷方, 余额), 9 formula(s), 1 style rule(s), LINE chart on its own sheet. On the Java side it builds 5 data rows and calls exportBankStatement() once — everything else is driven by the config.
It belongs to the "Chart & Visualization" group: GRAPH charts — column, line, scatter and radar charts written into a separate sheet, making the workbook multi-sheet.
What you can copy from this page
- The complete Java test class (63 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 chart, Java generate Excel line chart, Apache POI chart export example, Java multi-sheet workbook export, export Bank Statement Reconciliation to Excel with Java
Output specs
- Scene no.
- 0014
- Group
- Chart & Visualization
- Config lines
- 32
- Source lines
- 63
Java source · Graph0014BankStatementDemo.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.graph;
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.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class Graph0014BankStatementDemo {
private static final String XML = "jquick/biz/graph/0014_graph_bank-statement.xml";
/** 导出:4 笔流水 + 1 行合计 + 折线图,回读校验滚动余额、合计与图表 sheet。 */
@Test
public void exportBankStatement() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
rows.add(detail("2026-09-01", "销售收入", 0.00, 50000.00));
rows.add(detail("2026-09-05", "采购支出", 20000.00, 0.00));
rows.add(detail("2026-09-12", "销售收入", 0.00, 35000.00));
rows.add(detail("2026-09-20", "支付工资", 45000.00, 0.00));
rows.add(totalRow());
File out = new File("D:/test/excel/biz/graph/0014_graph_bank-statement.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("midnightDark", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Graph0014BankStatementService service = factory.createApi(Graph0014BankStatementService.class);
service.exportBankStatement("field", "value");
}
}
/** 构造一条流水(e=余额由 FORMULAS 滚动计算,占位保列)。 */
private static JQuickRow detail(String date, String summary, double debit, double credit) throws Exception {
JQuickRow row = new JQuickRow();
row.put("a", new SimpleDateFormat("yyyy-MM-dd").parse(date));
row.put("b", summary);
row.put("c", debit);
row.put("d", credit);
row.put("e", null);
return row;
}
/** 合计行:只写「合计」文字,其余列以空值占位(必须补齐全部映射列)。 */
private static JQuickRow totalRow() {
JQuickRow row = new JQuickRow();
row.put("a", "合计");
row.put("b", null);
row.put("c", null);
row.put("d", null);
row.put("e", null);
return row;
}
}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("midnightDark", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Graph0014BankStatementService service = factory.createApi(Graph0014BankStatementService.class);XML config · 0014_graph_bank-statement.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.graph.Graph0014BankStatementService">
<!-- 导出:银行流水对账单 -->
<excel name="exportBankStatement" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="银行流水对账单", HEADER=true,
MAPPING={"a":"交易日期","b":"摘要","c":"借方","d":"贷方","e":"余额"},
FORMAT={"a":"yyyy-MM-dd","c":"#,##0.00","d":"#,##0.00","e":"#,##0.00"},
FORMULAS={
E2:'D2-C2',E3:'E2+D3-C3',E4:'E3+D4-C4',E5:'E4+D5-C5',
C6:'SUM(C2:C5)',D6:'SUM(D2:D5)',E6:'D6-C6'
},
STYLE={ROW 6:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center}},
GRAPH={TYPE=LINE, TITLE="余额趋势", CATEGORY_AXIS=笔次, VALUE_AXIS=余额,
CATEGORIES=["第1笔","第2笔","第3笔","第4笔"],
SERIES=[{NAME=余额, DATA=[50000,30000,65000,20000]}]}
]]>
</excel>
<!-- 导入解析:读取导出的银行流水对账单 -->
<excel name="importBankStatement" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="银行流水对账单", HEADER=true,
MAPPING={"交易日期":"tradeDate","摘要":"summary","借方":"debit","贷方":"credit","余额":"balance"}
]]>
</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.