# EasyExcel — Fast Memory-Efficient Excel Processing for Java > Alibaba's open-source Java library for reading and writing large Excel files without running out of memory. Handles millions of rows with minimal heap usage through streaming and event-driven parsing. ## Install Save in your project root: # EasyExcel — Fast Memory-Efficient Excel Processing for Java ## Quick Use ```xml com.alibaba easyexcel 4.0.3 ``` ```java // Read an Excel file EasyExcel.read("input.xlsx", DataModel.class, new DataListener()).sheet().doRead(); // Write an Excel file EasyExcel.write("output.xlsx", DataModel.class).sheet("Sheet1").doWrite(dataList); ``` ## Introduction EasyExcel is a Java library by Alibaba designed to solve the memory overflow problems that plague Apache POI when handling large spreadsheets. It uses an event-driven SAX-style parser for reads and a streaming writer for exports, keeping memory usage flat regardless of file size. ## What EasyExcel Does - Reads Excel files (xls and xlsx) with constant memory consumption via streaming - Writes large datasets to Excel with automatic sheet splitting and style support - Maps Excel columns to Java objects through annotations for type-safe parsing - Supports custom converters, validators, and listeners for complex data pipelines - Handles merged cells, formulas, images, and multi-sheet workbooks ## Architecture Overview EasyExcel wraps Apache POI's low-level SAX event reader for xlsx and the legacy HSSFEventFactory for xls, exposing a high-level annotation-based API. During reads, rows stream through a listener callback one at a time so only a small window of data resides in memory. Writes use a streaming workbook that flushes rows to disk in batches. A reflection-based converter layer automatically maps between Excel cells and annotated Java fields. ## Self-Hosting & Configuration - Add the Maven or Gradle dependency to your project — no external services required - Annotate Java model classes with @ExcelProperty to map columns by name or index - Implement a ReadListener to process rows as they stream in from the file - Configure write styles, column widths, and merge strategies via builder methods - Use the fill template feature to populate pre-designed Excel templates with data ## Key Features - Reads a 750,000-row file using roughly 64 MB of heap versus multiple GB with POI - Annotation-driven column mapping eliminates manual cell-index bookkeeping - Built-in support for Excel template filling for report generation - Automatic type conversion between Java types and Excel cell formats - Compatible with both legacy .xls and modern .xlsx file formats ## Comparison with Similar Tools - **Apache POI** — the standard Java Excel library but loads entire workbooks into memory; EasyExcel wraps POI's SAX layer for constant-memory streaming - **JExcelApi** — lightweight xls-only library; lacks xlsx support and is no longer maintained - **Alibaba DataX** — a data synchronization tool, not an Excel library; complementary rather than competing - **OpenCSV** — handles CSV files only; EasyExcel covers the full xlsx/xls format including styles and formulas - **Python openpyxl / pandas** — popular in the Python ecosystem; EasyExcel serves the same role for Java and Spring Boot projects ## FAQ **Q: How much memory does EasyExcel use for large files?** A: EasyExcel processes rows one at a time via streaming, so heap usage stays constant (typically 64-128 MB) regardless of file size. **Q: Can I use EasyExcel with Spring Boot?** A: Yes. It is a plain Java library that works in any Spring Boot project. Many teams use it for REST endpoints that export reports. **Q: Does EasyExcel support writing styled Excel files?** A: Yes. You can apply cell styles, fonts, colors, column widths, and merged regions through the write builder API. **Q: Is EasyExcel actively maintained?** A: Yes. Alibaba continues to release updates and the project has an active community on GitHub. ## Sources - https://github.com/alibaba/easyexcel - https://easyexcel.opensource.alibaba.com/ --- Source: https://tokrepo.com/en/workflows/asset-e42b53dc Author: AI Open Source