Export "Sales Team Performance Leaderboard" to Excel with Java (Styled & Formatted Reports)
Styled & Formatted ReportsScene 0099
Registers the sales target and actual performance per salesperson, computing Completion Rate = Actual Performance / Sales Target, with the last row summarizing target and performance and giving the overall completion rate; the salesperson with the lowest completion rate is marked in red. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Sales Team Performance Leaderboard" workbook: 1 data sheet(s); MAPPING over 7 columns (排名, 销售员, 所属区域, 销售目标, 实际业绩, 完成率, 业绩等级), 10 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportSalesTeamRanking() 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 (65 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 Sales Team Performance Leaderboard to Excel with Java
Output specs
- Scene no.
- 0099
- Group
- Styled & Formatted Reports
- Config lines
- 32
- Source lines
- 65
Java source · Style0099SalesTeamRankingDemo.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 Style0099SalesTeamRankingDemo {
private static final String XML = "jquick/biz/style/0099_style_sales-team-ranking.xml";
/** 导出:纯 XML 完成逐行完成率、目标 / 业绩合计与整体完成率。 */
@Test
public void exportSalesTeamRanking() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
// f 留空,由 FORMULAS 计算
rows.add(salesperson(1, "张明", "华东", 500000.00, 620000.00, "优秀"));
rows.add(salesperson(2, "李强", "华南", 400000.00, 460000.00, "优秀"));
rows.add(salesperson(3, "王芳", "华北", 350000.00, 330000.00, "达标"));
rows.add(salesperson(4, "赵磊", "西南", 300000.00, 360000.00, "优秀"));
rows.add(salesperson(5, "陈静", "华中", 250000.00, 200000.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/0099_style_sales-team-ranking.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("periwinkle", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0099SalesTeamRankingService service = factory.createApi(Style0099SalesTeamRankingService.class);
service.exportSalesTeamRanking("field", "value");
}
}
/** 构造一名销售员(a=排名,b=销售员,c=区域,d=目标,e=业绩,f 留空,g=等级)。 */
private static JQuickRow salesperson(int ranking, String salesperson, String region,
double salesTarget, double actualPerformance, String performanceGrade) {
JQuickRow row = new JQuickRow();
row.put("a", ranking);
row.put("b", salesperson);
row.put("c", region);
row.put("d", salesTarget);
row.put("e", actualPerformance);
row.put("f", null);
row.put("g", performanceGrade);
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("periwinkle", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Style0099SalesTeamRankingService service = factory.createApi(Style0099SalesTeamRankingService.class);XML config · 0099_style_sales-team-ranking.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.Style0099SalesTeamRankingService">
<!-- 导出:销售团队业绩排行榜 -->
<excel name="exportSalesTeamRanking" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="销售团队业绩排行榜", HEADER=true,
MAPPING={"a":"排名","b":"销售员","c":"所属区域","d":"销售目标","e":"实际业绩","f":"完成率","g":"业绩等级"},
FORMAT={"d":"#,##0.00","e":"#,##0.00","f":"0.00%"},
FORMULAS={
F2:'E2/D2',F3:'E3/D3',F4:'E4/D4',F5:'E5/D5',F6:'E6/D6',
D7:'SUM(D2:D6)',E7:'SUM(E2:E6)',F7:'E7/D7'
},
STYLE={
ROW 7:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
F6:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的销售团队业绩排行榜 -->
<excel name="importSalesTeamRanking" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="销售团队业绩排行榜", HEADER=true,
MAPPING={"排名":"ranking","销售员":"salesperson","所属区域":"region","销售目标":"salesTarget","实际业绩":"actualPerformance","完成率":"completionRate","业绩等级":"performanceGrade"}
]]>
</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.