Skip to content

Export "R&D Project Performance Appraisal Score Sheet" to Excel with Java (Formula & Calculated Reports)

JQuick-ExcelFormula & Calculated Reports

Formula & Calculated ReportsScene 0069

Registers three scores (Schedule Achievement / Quality / Cost Control) per R&D project, computing a weighted composite score (Schedule × 0.4 + Quality × 0.35 + Cost × 0.25) per row, with the last row giving the average composite score; the low-scoring project (lowest composite score) is marked in red. Implemented declaratively in pure XML — no Java business code required.

Download the Excel fileView raw XML configBack to all demos

R&D Project Performance Appraisal Score Sheet — Formula & Calculated Reports
Full screenshot of the exported xlsx

About this demo

This demo exports the "R&D Project Performance Appraisal Score Sheet" workbook: 1 data sheet(s); MAPPING over 7 columns (项目名称, 负责人, 进度达成, 质量得分, 成本控制得分, 综合得分, 评级), 6 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportRdProjectPerformance() 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 R&D Project Performance Appraisal Score Sheet to Excel with Java

Output specs

Scene no.
0069
Group
Formula & Calculated Reports
Config lines
34
Source lines
65

Java source · Formulas0069RdProjectPerformanceDemo.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 Formulas0069RdProjectPerformanceDemo {

    private static final String XML = "jquick/biz/formulas/0069_formulas_rd-project-performance.xml";

    /** 导出:纯 XML 完成加权综合得分、平均分与低分标红。 */
    @Test
    public void exportRdProjectPerformance() throws Exception {
        List<JQuickRow> rows = new ArrayList<>();
        // f=综合得分 留空,由 FORMULAS 计算
        rows.add(project("智能仓储系统", "张伟", 95.0, 90.0, 85.0, "优秀"));
        rows.add(project("产线改造项目", "李娜", 88.0, 92.0, 80.0, "良好"));
        rows.add(project("数据中台建设", "王强", 70.0, 75.0, 68.0, "待改进"));
        rows.add(project("移动端重构", "赵敏", 85.0, 88.0, 90.0, "良好"));
        rows.add(project("客户关系系统", "陈杰", 92.0, 85.0, 82.0, "良好"));
        // 均分占位行:平均综合得分留给 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/0069_formulas_rd-project-performance.xlsx");
        try (OutputStream os = new FileOutputStream(out)) {
            JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("espresso", rows, os);
            JQuickFactory factory = new JQuickXmlFactory(parser, XML);
            Formulas0069RdProjectPerformanceService service = factory.createApi(Formulas0069RdProjectPerformanceService.class);
            service.exportRdProjectPerformance("field", "value");
        }

    }

    /** 构造一条项目评分(a=项目名称,b=负责人,c=进度达成,d=质量得分,e=成本控制得分,f=综合得分,g=评级)。 */
    private static JQuickRow project(String projectName, String owner, double scheduleScore,
                                     double qualityScore, double costScore, String rating) {
        JQuickRow row = new JQuickRow();
        row.put("a", projectName);
        row.put("b", owner);
        row.put("c", scheduleScore);
        row.put("d", qualityScore);
        row.put("e", costScore);
        row.put("f", null);
        row.put("g", rating);
        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("espresso", rows, os);
JQuickFactory factory = new JQuickXmlFactory(parser, XML);
Formulas0069RdProjectPerformanceService service = factory.createApi(Formulas0069RdProjectPerformanceService.class);

XML config · 0069_formulas_rd-project-performance.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.Formulas0069RdProjectPerformanceService">

    <!-- 导出:研发项目绩效考核评分表 -->
    <excel name="exportRdProjectPerformance" returnClass="void">
        <![CDATA[
            EXPORT WITH SHEET="研发项目绩效考核评分表", HEADER=true,
                MAPPING={"a":"项目名称","b":"负责人","c":"进度达成","d":"质量得分","e":"成本控制得分","f":"综合得分","g":"评级"},
                FORMAT={"c":"#,##0.0","d":"#,##0.0","e":"#,##0.0","f":"#,##0.00"},
                FORMULAS={
                    F2:'C2*0.4+D2*0.35+E2*0.25',F3:'C3*0.4+D3*0.35+E3*0.25',
                    F4:'C4*0.4+D4*0.35+E4*0.25',F5:'C5*0.4+D5*0.35+E5*0.25',
                    F6:'C6*0.4+D6*0.35+E6*0.25',
                    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="importRdProjectPerformance" returnClass="java.util.List">
        <![CDATA[
            IMPORT WITH SHEET="研发项目绩效考核评分表", HEADER=true,
                MAPPING={"项目名称":"projectName","负责人":"owner","进度达成":"scheduleScore","质量得分":"qualityScore","成本控制得分":"costScore","综合得分":"totalScore","评级":"rating"}
        ]]>
    </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.