Export "Department Quarterly Performance Appraisal Summary" to Excel with Java (Formula & Calculated Reports)
Formula & Calculated ReportsScene 0081
Registers goal-completion, work-quality and teamwork scores per department, computing a weighted Composite Score = Completion Score × 0.5 + Quality Score × 0.3 + Teamwork Score × 0.2, with the last row giving the average of each item and the average composite score; the department with the lowest composite score is marked in red. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Department Quarterly Performance Appraisal Summary" workbook: 1 data sheet(s); MAPPING over 7 columns (部门, 考核负责人, 目标完成分, 工作质量分, 团队协作分, 综合得分, 考核等级), 12 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportDepartmentPerformanceReview() once — everything else is driven by the config.
It belongs to the "Formula & Calculated Reports" group: FORMULAS — inline expressions and aggregate functions such as Quantity × Unit Price or Balance = Receivable − Received, with SUM totals on the last row.
What you can copy from this page
- The complete Java test class (65 lines, runnable as-is)
- The complete XML config (34 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 formulas, Java Excel SUM formula export, Apache POI write formula example, Java computed column export, export Department Quarterly Performance Appraisal Summary to Excel with Java
Output specs
- Scene no.
- 0081
- Group
- Formula & Calculated Reports
- Config lines
- 34
- Source lines
- 65
Java source · Formulas0081DepartmentPerformanceReviewDemo.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.formulas;
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 Formulas0081DepartmentPerformanceReviewDemo {
private static final String XML = "jquick/biz/formulas/0081_formulas_department-performance-review.xml";
/** 导出:纯 XML 完成加权综合得分、平均分与最低分标红。 */
@Test
public void exportDepartmentPerformanceReview() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
// f 留空,由 FORMULAS 计算
rows.add(dept("研发部", "张伟", 95.00, 90.00, 88.00, "优秀"));
rows.add(dept("市场部", "李娜", 88.00, 85.00, 92.00, "良好"));
rows.add(dept("生产部", "王强", 82.00, 78.00, 80.00, "合格"));
rows.add(dept("财务部", "赵敏", 90.00, 88.00, 85.00, "良好"));
rows.add(dept("客服部", "陈晨", 85.00, 80.00, 78.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/formulas/0081_formulas_department-performance-review.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("indigo", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Formulas0081DepartmentPerformanceReviewService service = factory.createApi(Formulas0081DepartmentPerformanceReviewService.class);
service.exportDepartmentPerformanceReview("field", "value");
}
}
/** 构造一个部门(a=部门,b=负责人,c/d/e=三项得分,f 留空,g=考核等级)。 */
private static JQuickRow dept(String department, String reviewer, double goalScore,
double qualityScore, double teamScore, String grade) {
JQuickRow row = new JQuickRow();
row.put("a", department);
row.put("b", reviewer);
row.put("c", goalScore);
row.put("d", qualityScore);
row.put("e", teamScore);
row.put("f", null);
row.put("g", grade);
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("indigo", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Formulas0081DepartmentPerformanceReviewService service = factory.createApi(Formulas0081DepartmentPerformanceReviewService.class);XML config · 0081_formulas_department-performance-review.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.formulas.Formulas0081DepartmentPerformanceReviewService">
<!-- 导出:部门季度绩效考核汇总表 -->
<excel name="exportDepartmentPerformanceReview" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="部门季度绩效考核汇总表", HEADER=true,
MAPPING={"a":"部门","b":"考核负责人","c":"目标完成分","d":"工作质量分","e":"团队协作分","f":"综合得分","g":"考核等级"},
FORMAT={"c":"0.00","d":"0.00","e":"0.00","f":"0.00"},
FORMULAS={
F2:'C2*0.5+D2*0.3+E2*0.2',F3:'C3*0.5+D3*0.3+E3*0.2',
F4:'C4*0.5+D4*0.3+E4*0.2',F5:'C5*0.5+D5*0.3+E5*0.2',
F6:'C6*0.5+D6*0.3+E6*0.2',
C7:'AVERAGE(C2:C6)',D7:'AVERAGE(D2:D6)',E7:'AVERAGE(E2:E6)',F7:'AVERAGE(F2:F6)'
},
STYLE={
ROW 7:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
F4:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的部门季度绩效考核汇总表 -->
<excel name="importDepartmentPerformanceReview" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="部门季度绩效考核汇总表", HEADER=true,
MAPPING={"部门":"department","考核负责人":"reviewer","目标完成分":"goalScore","工作质量分":"qualityScore","团队协作分":"teamScore","综合得分":"totalScore","考核等级":"grade"}
]]>
</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.