Boost Java Excel Import/Export Performance with AlanPOI – A Quick Guide
This article introduces the AlanPOI library for Java, detailing its lightweight Maven dependency, core import features, advantages over raw POI, configuration via XML, implementation of the ExcelConsumeInterface, and versatile export capabilities with code examples and advanced usage patterns.
Feature Overview
IMPORT
ExcelHandle core processor
ExcelWorkbookManage for managing all worksheets
ExcelInitConfig for configuration file initialization
AbstractFileParser for file conversion
Why choose AlanPOI import?
No need to manually add POI jars
Millisecond-level parsing of large files, one‑click multi‑sheet import without manual loops
Supports any number of imports and returns accurate objects, reducing developer effort
Provides error feedback per row, writing errors back to Excel
Extensible via ExcelConsumeInterface with valid, error, end callbacks
How to use AlanPOI for import
Create excel-config.xml under resources, define consume class, sheet VO, and column mappings. Example:
<?xml version="1.0" encoding="GB2312"?>
<exg name="excelId" version="1.0" file-type="excel">
<excel id="ACCOUNT" consume="com.xxx.FinAccountImportHandler">
<sheet index="0" row-start="1" column-start="0" vo="com.xxx.vo.FinAccountImportVO">
<column name="公司/供应商编号" offset="1">companyCode</column>
<column name="公司/供应商名称" offset="2">companyName</column>
<column name="银行账号" offset="3">bankAccount</column>
<column name="开户银行" offset="4">bankName</column>
</sheet>
</excel>
</exg>Implementing the consumer
Implement ExcelConsumeInterface with three methods:
void error(ExcelError excelError);
void validData(String workbookId, List<ExcelSheetData> sheetDataList, Map<Serializable, Object> excelParam);
void end(List<ExcelSheetData> sheetDataList, Map<Serializable, Object> excelParam);Export functionality
One‑line export via ExcelExportUtil.export(...) or obtain a Workbook with ExcelExportUtil.getWorkbook(...). Supports annotation‑driven column definitions such as @ExcelSheet, @ExcelColumn, @DateFormat, @NumFormat.
Advanced usage examples
Dynamic column export, multi‑sheet export, and custom workbook handling are demonstrated with sample code snippets.
https://github.com/alan-et/alanpoi/tree/develop/alanpoi-analysis
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
