Export "VAT Burden Analysis" to Excel with Java (Styled & Formatted Reports)
Styled & Formatted ReportsScene 0024
Analyzes VAT burden by quarter, computing VAT Payable = Output Tax - Input Tax and Tax Burden Rate = VAT Payable / Sales Revenue per row, with a summary in the last row; the tax-burden-rate cell of the quarter with the highest burden is marked in red to flag close attention. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "VAT Burden Analysis" workbook: 1 data sheet(s); MAPPING over 6 columns (期间, 销售收入, 销项税额, 进项税额, 应纳增值税, 税负率), 16 formula(s), 1 style rule(s). On the Java side it builds 5 data rows and calls exportVatBurden() 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 (61 lines, runnable as-is)
- The complete XML config (35 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 VAT Burden Analysis to Excel with Java
Output specs
- Scene no.
- 0024
- Group
- Styled & Formatted Reports
- Config lines
- 35
- Source lines
- 61
Java source · Style0024VatBurdenAnalysisDemo.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.List;
public class Style0024VatBurdenAnalysisDemo {
private static final String XML = "jquick/biz/style/0024_style_vat-burden-analysis.xml";
/** 导出:纯 XML 完成应纳增值税、税负率、合计行汇总与高税负标红。 */
@Test
public void exportVatBurden() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
rows.add(quarter("2026Q1", 2000000, 260000, 180000));
rows.add(quarter("2026Q2", 2000000, 260000, 200000));
// 第 4 行:2026Q3 税负最高(4.25%),模板中 F4 标红
rows.add(quarter("2026Q3", 2400000, 312000, 210000));
rows.add(quarter("2026Q4", 2600000, 338000, 240000));
// 合计占位行:应纳增值税、税负率留给 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);
rows.add(total);
File out = new File("D:/test/excel/biz/style/0024_style_vat-burden-analysis.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("oliveGreen", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0024VatBurdenAnalysisService service = factory.createApi(Style0024VatBurdenAnalysisService.class);
service.exportVatBurden("field", "value");
}
}
/** 构造一条季度税负明细(a=期间,b=销售收入,c=销项税额,d=进项税额)。 */
private static JQuickRow quarter(String period, double revenue, double outputTax, double inputTax) {
JQuickRow row = new JQuickRow();
row.put("a", period);
row.put("b", revenue);
row.put("c", outputTax);
row.put("d", inputTax);
row.put("e", null);
row.put("f", 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("oliveGreen", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0024VatBurdenAnalysisService service = factory.createApi(Style0024VatBurdenAnalysisService.class);XML config · 0024_style_vat-burden-analysis.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.Style0024VatBurdenAnalysisService">
<!-- 导出:增值税税负分析表 -->
<excel name="exportVatBurden" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="增值税税负分析表", HEADER=true,
MAPPING={"a":"期间","b":"销售收入","c":"销项税额","d":"进项税额","e":"应纳增值税","f":"税负率"},
FORMAT={"b":"#,##0.00","c":"#,##0.00","d":"#,##0.00","e":"#,##0.00","f":"0.00%"},
FORMULAS={
E2:'C2-D2',F2:'E2/B2',
E3:'C3-D3',F3:'E3/B3',
E4:'C4-D4',F4:'E4/B4',
E5:'C5-D5',F5:'E5/B5',
B6:'SUM(B2:B5)',C6:'SUM(C2:C5)',D6:'SUM(D2:D5)',E6:'C6-D6',F6:'E6/B6'
},
STYLE={
ROW 6:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
F4:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的增值税税负分析表 -->
<excel name="importVatBurden" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="增值税税负分析表", HEADER=true,
MAPPING={"期间":"period","销售收入":"salesRevenue","销项税额":"outputTax","进项税额":"inputTax","应纳增值税":"payableTax","税负率":"taxBurdenRate"}
]]>
</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.