Export "Employee Performance Appraisal Score Sheet" to Excel with Java (Formula & Calculated Reports)
Formula & Calculated ReportsScene 0017
Records performance, ability and attitude scores per employee, computes a weighted overall score and gives the average of each dimension at the end; for employees with a low overall score and a rating of "Needs Improvement", the rating cell is marked in red font. Implemented declaratively in pure XML — no Java business code required.

About this demo
This demo exports the "Employee Performance Appraisal Score Sheet" workbook: 1 data sheet(s); MAPPING over 8 columns (工号, 姓名, 部门, 业绩分, 能力分, 态度分, 综合得分, 绩效等级), 12 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportPerformanceAppraisal() 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 (67 lines, runnable as-is)
- The complete XML config (36 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 Employee Performance Appraisal Score Sheet to Excel with Java
Output specs
- Scene no.
- 0017
- Group
- Formula & Calculated Reports
- Config lines
- 36
- Source lines
- 67
Java source · Formulas0017PerformanceAppraisalDemo.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 Formulas0017PerformanceAppraisalDemo {
private static final String XML = "jquick/biz/formulas/0017_formulas_performance-appraisal.xml";
/** 导出:纯 XML 完成加权得分、平均分与待改进标红。 */
@Test
public void exportPerformanceAppraisal() throws Exception {
List<JQuickRow> rows = new ArrayList<>();
rows.add(employee("E1001", "张伟", "研发部", 92, 88, 90, "优秀"));
rows.add(employee("E1002", "李娜", "市场部", 85, 90, 88, "良好"));
rows.add(employee("E1003", "王强", "财务部", 78, 82, 85, "良好"));
rows.add(employee("E1004", "赵敏", "研发部", 95, 93, 92, "优秀"));
// 第 6 行:综合得分 65.6,等级「待改进」,模板中 H6 标红
rows.add(employee("E1005", "陈刚", "生产部", 62, 70, 68, "待改进"));
// 平均行占位:得分留给 FORMULAS
JQuickRow avg = new JQuickRow();
avg.put("a", "平均");
avg.put("b", null);
avg.put("c", null);
avg.put("d", null);
avg.put("e", null);
avg.put("f", null);
avg.put("g", null);
avg.put("h", null);
rows.add(avg);
File out = new File("D:/test/excel/biz/formulas/0017_formulas_performance-appraisal.xlsx");
try (OutputStream os = new FileOutputStream(out)) {
JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("periwinkle", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Formulas0017PerformanceAppraisalService service = factory.createApi(Formulas0017PerformanceAppraisalService.class);
service.exportPerformanceAppraisal("field", "value");
}
}
/** 构造一条员工考核明细(a=工号,b=姓名,c=部门,d/e/f=三项得分,h=等级)。 */
private static JQuickRow employee(String code, String name, String dept,
double performance, double ability, double attitude, String grade) {
JQuickRow row = new JQuickRow();
row.put("a", code);
row.put("b", name);
row.put("c", dept);
row.put("d", performance);
row.put("e", ability);
row.put("f", attitude);
row.put("g", null);
row.put("h", 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("periwinkle", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Formulas0017PerformanceAppraisalService service = factory.createApi(Formulas0017PerformanceAppraisalService.class);XML config · 0017_formulas_performance-appraisal.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.Formulas0017PerformanceAppraisalService">
<!-- 导出:员工绩效考核评分表 -->
<excel name="exportPerformanceAppraisal" returnClass="void">
<![CDATA[
EXPORT WITH SHEET="员工绩效考核评分表", HEADER=true,
MAPPING={"a":"工号","b":"姓名","c":"部门","d":"业绩分","e":"能力分","f":"态度分","g":"综合得分","h":"绩效等级"},
FORMAT={"d":"0.0","e":"0.0","f":"0.0","g":"#,##0.00"},
FORMULAS={
G2:'D2*0.5+E2*0.3+F2*0.2',
G3:'D3*0.5+E3*0.3+F3*0.2',
G4:'D4*0.5+E4*0.3+F4*0.2',
G5:'D5*0.5+E5*0.3+F5*0.2',
G6:'D6*0.5+E6*0.3+F6*0.2',
D7:'AVERAGE(D2:D6)',E7:'AVERAGE(E2:E6)',F7:'AVERAGE(F2:F6)',G7:'AVERAGE(G2:G6)'
},
STYLE={
ROW 7:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
H6:{color:red,bold:true}
}
]]>
</excel>
<!-- 导入解析:读取导出的员工绩效考核评分表 -->
<excel name="importPerformanceAppraisal" returnClass="java.util.List">
<![CDATA[
IMPORT WITH SHEET="员工绩效考核评分表", HEADER=true,
MAPPING={"工号":"code","姓名":"name","部门":"dept","业绩分":"performance","能力分":"ability","态度分":"attitude","综合得分":"total","绩效等级":"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.