FastExcel Replaces EasyExcel: Now an Apache Project with Enhanced Performance

FastExcel, the successor to EasyExcel, is now an Apache project offering high‑performance, low‑memory Excel read/write, streaming support, full API compatibility, PDF conversion, and detailed usage examples, making it a compelling choice for Java developers handling large Excel datasets.

Java Architect Handbook
Java Architect Handbook
Java Architect Handbook
FastExcel Replaces EasyExcel: Now an Apache Project with Enhanced Performance

FastExcel is an upgraded Java Excel processing framework released by the original EasyExcel author after Alibaba stopped maintaining EasyExcel. It inherits all EasyExcel advantages while delivering significant performance and feature improvements.

Features

High‑performance read/write with low memory consumption.

Simple, intuitive API for quick integration.

Streaming support that minimizes memory usage for tens of thousands to millions of rows.

Full compatibility with EasyExcel APIs, enabling seamless migration.

Ongoing updates for bug fixes, performance tuning, and new capabilities.

Usage

Define Entity Class

Each field maps to an Excel column using @ExcelProperty:

import cn.idev.excel.annotation.ExcelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class User {
    @ExcelProperty("编号")
    private Integer id;
    @ExcelProperty("名字")
    private String name;
    @ExcelProperty("年龄")
    private Integer age;
}

Create Event Listener

The listener processes rows one by one, preventing OOM for large files.

import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.event.AnalysisEventListener;
import java.util.ArrayList;
import java.util.List;

public class BaseExcelListener<T> extends AnalysisEventListener<T> {
    private List<T> dataList = new ArrayList<>();

    @Override
    public void invoke(T t, AnalysisContext analysisContext) {
        dataList.add(t);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("读取完成,共读取了 " + dataList.size() + " 条数据");
    }

    public List<T> getDataList() {
        return dataList;
    }
}

Write Excel

@GetMapping("/download")
public void download(HttpServletResponse response) throws IOException {
    response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    response.setCharacterEncoding("utf-8");
    String fileName = URLEncoder.encode("test", "UTF-8");
    response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
    FastExcel.write(response.getOutputStream(), User.class)
             .sheet("模板")
             .doWrite(buildData());
}

private List<User> buildData() {
    User user1 = new User();
    user1.setId(1);
    user1.setName("张三");
    user1.setAge(18);
    User user2 = new User();
    user2.setId(2);
    user2.setName("李四");
    user2.setAge(19);
    return List.of(user1, user2);
}

Read Excel

@PostMapping("/upload")
public ResponseEntity<String> upload(@RequestParam("file") MultipartFile file) {
    if (file.isEmpty()) {
        return ResponseEntity.badRequest().body("请选择一个文件上传!");
    }
    try {
        BaseExcelListener<User> listener = new BaseExcelListener<>();
        FastExcel.read(file.getInputStream(), User.class, listener)
                 .sheet()
                 .doRead();
        List<User> dataList = listener.getDataList();
        System.out.println(dataList);
        return ResponseEntity.ok("文件上传并处理成功!");
    } catch (IOException e) {
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                             .body("文件处理失败!");
    }
}

Convert to PDF

FastExcel can convert an Excel file to PDF using Apache POI and itext‑pdf (license compliance required).

FastExcel.convertToPdf(new File("excelFile"), new File("pdfFile"), null, null);

Comparison with EasyExcel

Performance: FastExcel offers better and more stable performance.

API compatibility: Identical APIs allow seamless switching.

New features in version 1.0.0: ability to read a specific number of rows and PDF conversion.

Conclusion

FastExcel is a lightweight yet powerful Java library designed for high‑performance, low‑memory Excel processing. Its streaming architecture and flexible API make it suitable for handling large‑scale Excel data in enterprise or personal projects.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaPerformanceStreamingPDFEasyExcelApacheExcelFastExcel
Java Architect Handbook
Written by

Java Architect Handbook

Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.