Skip to content

Export "Tender Price Comparison and Award Record" to Excel with Java (Formula & Calculated Reports)

JQuick-ExcelFormula & Calculated Reports

Formula & Calculated ReportsScene 0053

Compares bids from multiple tenderers, computing the composite score as Technical Score × 70% + Performance Score × 30%, with the last row giving the average quote and average composite score and the highest-quoting tenderer marked in red. Implemented declaratively in pure XML — no Java business code required.

Download the Excel fileView raw XML configBack to all demos

Tender Price Comparison and Award Record — Formula & Calculated Reports
Full screenshot of the exported xlsx

About this demo

This demo exports the "Tender Price Comparison and Award Record" workbook: 1 data sheet(s); MAPPING over 6 columns (投标单位, 商务报价, 技术得分, 业绩得分, 综合评分, 定标结果), 8 formula(s), 1 style rule(s). On the Java side it builds 6 data rows and calls exportBidComparisonRecord() 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 (61 lines, runnable as-is)
  • The complete XML config (33 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 Tender Price Comparison and Award Record to Excel with Java

Output specs

Scene no.
0053
Group
Formula & Calculated Reports
Config lines
33
Source lines
61

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

    private static final String XML = "jquick/biz/formulas/0053_formulas_bid-comparison-record.xml";

    /** 导出:纯 XML 完成加权综合评分、均值汇总与最高报价标红。 */
    @Test
    public void exportBidComparisonRecord() throws Exception {
        List<JQuickRow> rows = new ArrayList<>();
        rows.add(bidder("甲建工", 1180000.00, 88.0, 90.0, "中标候选"));
        rows.add(bidder("乙工程", 1250000.00, 85.0, 82.0, "未入选"));
        rows.add(bidder("丙建设", 1320000.00, 80.0, 78.0, "未入选"));
        rows.add(bidder("丁安装", 1100000.00, 82.0, 85.0, "备选"));
        rows.add(bidder("戊建筑", 1210000.00, 86.0, 88.0, "中标候选"));
        // 均值占位行:平均报价与平均综合评分留给 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);
        rows.add(avg);

        File out = new File("D:/test/excel/biz/formulas/0053_formulas_bid-comparison-record.xlsx");
        try (OutputStream os = new FileOutputStream(out)) {
            JQuickParseHandler parser = new JQuickExcelExportXmlParseFactory("oliveGreen", rows, os);
            JQuickFactory factory = new JQuickXmlFactory(parser, XML);
            Formulas0053BidComparisonRecordService service = factory.createApi(Formulas0053BidComparisonRecordService.class);
            service.exportBidComparisonRecord("field", "value");
        }

    }

    /** 构造一家投标单位(a=单位,b=报价,c=技术分,d=业绩分,f=结果,e 留空由 FORMULAS 计算)。 */
    private static JQuickRow bidder(String bidder, double quote, double techScore, double perfScore, String result) {
        JQuickRow row = new JQuickRow();
        row.put("a", bidder);
        row.put("b", quote);
        row.put("c", techScore);
        row.put("d", perfScore);
        row.put("e", null);
        row.put("f", result);
        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);
Formulas0053BidComparisonRecordService service = factory.createApi(Formulas0053BidComparisonRecordService.class);

XML config · 0053_formulas_bid-comparison-record.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.Formulas0053BidComparisonRecordService">

    <!-- 导出:招标比价定标记录 -->
    <excel name="exportBidComparisonRecord" returnClass="void">
        <![CDATA[
            EXPORT WITH SHEET="招标比价定标记录", HEADER=true,
                MAPPING={"a":"投标单位","b":"商务报价","c":"技术得分","d":"业绩得分","e":"综合评分","f":"定标结果"},
                FORMAT={"b":"#,##0.00","c":"#,##0.0","d":"#,##0.0","e":"#,##0.00"},
                FORMULAS={
                    E2:'C2*0.7+D2*0.3',E3:'C3*0.7+D3*0.3',E4:'C4*0.7+D4*0.3',
                    E5:'C5*0.7+D5*0.3',E6:'C6*0.7+D6*0.3',
                    B7:'AVERAGE(B2:B6)',E7:'AVERAGE(E2:E6)'
                },
                STYLE={
                    ROW 7:{bold:true,fillPattern:solid_foreground,fillForegroundColor:lightYellow,alignment:right,verticalAlignment:center},
                    B4:{color:red,bold:true}
                }
        ]]>
    </excel>

    <!-- 导入解析:读取导出的招标比价定标记录 -->
    <excel name="importBidComparisonRecord" returnClass="java.util.List">
        <![CDATA[
            IMPORT WITH SHEET="招标比价定标记录", HEADER=true,
                MAPPING={"投标单位":"bidder","商务报价":"quote","技术得分":"techScore","业绩得分":"perfScore","综合评分":"totalScore","定标结果":"result"}
        ]]>
    </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.