Top Related Projects
Mirror of Apache POI
A Python module for creating Excel XLSX files.
A pure PHP library for reading and writing spreadsheet files
📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
Quick Overview
EasyExcel is a Java-based Excel reading and writing framework developed by Alibaba. It aims to provide a simpler and more efficient way to handle Excel files compared to traditional POI, with a focus on memory optimization for large files.
Pros
- High performance and low memory usage, especially for large Excel files
- Easy to use API with fluent interface
- Supports both .xls and .xlsx formats
- Provides annotation-based mapping for easy object-to-Excel conversion
Cons
- Limited support for complex Excel features (e.g., formulas, charts)
- Documentation is primarily in Chinese, which may be challenging for non-Chinese speakers
- Less mature compared to Apache POI, with potentially fewer community resources
Code Examples
- Reading an Excel file:
EasyExcel.read("path/to/file.xlsx", DemoData.class, new ReadListener<DemoData>() {
@Override
public void invoke(DemoData data, AnalysisContext context) {
// Process each row of data
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// Do something after all data is processed
}
}).sheet().doRead();
- Writing data to an Excel file:
List<DemoData> dataList = // ... your data
EasyExcel.write("path/to/output.xlsx", DemoData.class).sheet("Sheet1").doWrite(dataList);
- Using annotations for column mapping:
public class DemoData {
@ExcelProperty("Name")
private String name;
@ExcelProperty("Age")
private Integer age;
// getters and setters
}
Getting Started
- Add EasyExcel dependency to your project:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.2.1</version>
</dependency>
- Create a model class with annotations:
@Data
public class User {
@ExcelProperty("User ID")
private Long id;
@ExcelProperty("Name")
private String name;
@ExcelProperty("Email")
private String email;
}
- Read or write Excel files using EasyExcel methods as shown in the code examples above.
Competitor Comparisons
Mirror of Apache POI
Pros of POI
- More comprehensive support for various Microsoft Office formats (Excel, Word, PowerPoint, etc.)
- Longer history and larger community support
- More feature-rich, offering advanced functionality for complex document manipulation
Cons of POI
- Higher memory consumption, especially for large files
- Steeper learning curve due to its extensive API
- Slower performance compared to EasyExcel for simple Excel operations
Code Comparison
POI:
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("Sheet1");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("Hello, POI!");
EasyExcel:
EasyExcel.write("output.xlsx", ExcelModel.class)
.sheet("Sheet1")
.doWrite(Arrays.asList(new ExcelModel("Hello, EasyExcel!")));
Summary
POI offers a more comprehensive solution for working with various Microsoft Office formats, while EasyExcel focuses specifically on Excel operations with improved performance and ease of use. POI provides more advanced features but comes with higher memory usage and a steeper learning curve. EasyExcel, on the other hand, offers a simpler API and better performance for basic Excel tasks, making it a good choice for projects primarily dealing with Excel files.
A Python module for creating Excel XLSX files.
Pros of XlsxWriter
- Written in Python, offering seamless integration with Python projects
- Supports a wide range of Excel features, including charts, images, and data validation
- Excellent documentation and extensive examples
Cons of XlsxWriter
- Limited to writing Excel files, cannot read or modify existing files
- May have slower performance for very large datasets compared to EasyExcel
Code Comparison
XlsxWriter:
import xlsxwriter
workbook = xlsxwriter.Workbook('example.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello Excel')
workbook.close()
EasyExcel:
EasyExcel.write("example.xlsx", ExampleData.class)
.sheet("Sheet1")
.doWrite(dataList);
Key Differences
- XlsxWriter is Python-based, while EasyExcel is Java-based
- EasyExcel focuses on simplicity and ease of use for reading and writing Excel files
- XlsxWriter offers more advanced Excel features but is limited to writing files
- EasyExcel provides better performance for large datasets and memory optimization
Both libraries are popular choices for working with Excel files, with XlsxWriter being more suitable for Python developers and EasyExcel catering to Java developers. The choice between them depends on the specific project requirements, programming language preference, and desired Excel features.
A pure PHP library for reading and writing spreadsheet files
Pros of PhpSpreadsheet
- More mature and widely adopted in the PHP ecosystem
- Supports a broader range of spreadsheet formats (XLSX, XLS, ODS, CSV, HTML)
- Extensive documentation and community support
Cons of PhpSpreadsheet
- Generally slower performance, especially with large datasets
- Higher memory consumption compared to EasyExcel
- Steeper learning curve for beginners
Code Comparison
PhpSpreadsheet:
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World!');
$writer = new Xlsx($spreadsheet);
$writer->save('hello_world.xlsx');
EasyExcel:
EasyExcel.write("hello_world.xlsx", DemoData.class)
.sheet("Sheet1")
.doWrite(data());
While both libraries aim to simplify spreadsheet manipulation, EasyExcel focuses on performance and ease of use for Java developers, particularly when dealing with large datasets. PhpSpreadsheet offers more comprehensive features and format support for PHP projects but may require more resources. The code comparison highlights the simplicity of EasyExcel's API compared to PhpSpreadsheet's more verbose approach.
📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
Pros of sheetjs
- Broader language support, including JavaScript, TypeScript, and various frameworks
- More comprehensive file format support, including legacy Excel formats
- Larger community and ecosystem, with more resources and third-party integrations
Cons of sheetjs
- Steeper learning curve due to more complex API
- Larger file size, which may impact performance in some applications
- Commercial use requires a paid license
Code Comparison
easyexcel (Java):
EasyExcel.read("demo.xlsx", DemoData.class, new DemoDataListener())
.sheet()
.doRead();
sheetjs (JavaScript):
const workbook = XLSX.readFile('demo.xlsx');
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const data = XLSX.utils.sheet_to_json(worksheet);
Both libraries provide straightforward methods for reading Excel files, but easyexcel's API is more concise and tailored for Java developers. sheetjs offers more flexibility and options, but requires more code to achieve similar results.
easyexcel is specifically designed for Java applications and excels in handling large Excel files with low memory usage. It's particularly well-suited for server-side processing in Java environments.
sheetjs, on the other hand, offers broader language and format support, making it a versatile choice for web applications and cross-platform development. However, its larger file size and more complex API may be considerations for some projects.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
EasyExcel
æ°æå¿ è¯»
- å®æ¹ç½ç«ï¼https://easyexcel.opensource.alibaba.com/
- githubå°åï¼https://github.com/alibaba/easyexcel
- giteeå°åï¼https://gitee.com/easyexcel/easyexcel
JAVA解æExcelå·¥å ·
Java解æãçæExcelæ¯è¾æåçæ¡æ¶æApache poiãjxlãä½ä»ä»¬é½åå¨ä¸ä¸ªä¸¥éçé®é¢å°±æ¯é常çèå
åï¼poiæä¸å¥SAX模å¼çAPIå¯ä»¥ä¸å®ç¨åº¦ç解å³ä¸äºå
å溢åºçé®é¢ï¼ä½POIè¿æ¯æä¸äºç¼ºé·ï¼æ¯å¦07çExcel解å缩以å解åååå¨é½æ¯å¨å
åä¸å®æçï¼å
åæ¶èä¾ç¶å¾å¤§ã
easyexceléåäºpoi对07çExcelç解æï¼ä¸ä¸ª3Mçexcelç¨POI sax解æä¾ç¶éè¦100Må·¦å³å
åï¼æ¹ç¨easyexcelå¯ä»¥éä½å°å Mï¼å¹¶ä¸å大çexcelä¹ä¸ä¼åºç°å
å溢åºï¼03çä¾èµPOIçsax模å¼ï¼å¨ä¸å±åäºæ¨¡å转æ¢çå°è£
ï¼è®©ä½¿ç¨è
æ´å ç®åæ¹ä¾¿
16Må å23ç§è¯»å75M(46Wè¡25å)çExcelï¼3.2.1+çæ¬ï¼
å½ç¶è¿ææéæ¨¡å¼ è½æ´å¿«ï¼ä½æ¯å åå ç¨ä¼å¨100Må¤ä¸ç¹
ææ°çæ¬
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>4.0.2</version>
</dependency>
帮å¿ç¹ä¸ªâStar
å¼æºä¸æï¼å¦æè§å¾EasyExcel对æ¨çå·¥ä½è¿æ¯æ帮å©çè¯ï¼è¯·å¸®å¿å¨ çå³ä¸è§ç¹ä¸ªâStarï¼æ¨çæ¯ææ¯ä½¿EasyExcelåå¾æ´å¥½æ大çå¨åã
å¦ä½è·å帮å©
ä¼å 建议èªå·±éè¿ææ¡£æ¥è§£å³é®é¢
å
¶æ¬¡å»ºè®®éè¿issues
æ¥è§£å³è§£å³é®é¢
å¯ä»¥å°è¯å¨ä»¥ä¸2个é¾æ¥æç´¢é®é¢ï¼å¦æä¸åå¨å¯ä»¥å°è¯å建issue
ã
éè¿ issues
解å³é®é¢ï¼å¯ä»¥ç»åé¢éå°ç¸åé®é¢çåå¦æ¥çï¼æ以æ¯è¾æ¨èè¿ç§æ¹å¼ã
ä¸ç®¡github
ãgitee
é½ä¼å®ææ人åçæ¨çé®é¢ï¼æ¯è¾ç´§æ¥å¯ä»¥å¨æå®issue
以åå¨éé群è¾ç¹ç¾¤ä¸»å¹¶åéissue
å°å帮å¿è§£å³ã
QQ
å
¬å¸ä¸è®©ç¨ï¼ææ¶åä¹ä¼å»çï¼ä½æ¯æ ¸å¿è¯å®è¿æ¯å¨ééã
ä¹å¯ä»¥å å ¥éé&QQ群æ¥è§£å³é®é¢
å å
¥ééæQQ群ï¼çå®å
¬åå¯ä»¥è·å¾å¸®å© ã
æ¯è¾æ¨èéé群ï¼QQ
å
¬å¸ä¸è®©ç¨ï¼å½ç¶QQ群ä¹ä¼æçå¿ç½å帮å¿è§£å³ã
QQ1群(已满): 662022184
QQ2群(已满): 1097936804
QQ3群(已满): 453928496
QQ4群(已满): 496594404
QQ5群(已满): 451925680
QQ6群(已满): 784741035
QQ7群(已满): 667889383
QQ8群: 113968681
éé1群ï¼å·²æ»¡ï¼: 21960511
éé2群ï¼å·²æ»¡ï¼: 32796397
éé3群ï¼å·²æ»¡ï¼: 33797247
éé4群ï¼å·²æ»¡ï¼: 33491624
éé5群ï¼å·²æ»¡ï¼: 32134498
éé6群ï¼å·²æ»¡ï¼: 34707941
éé7群ï¼å·²æ»¡ï¼: 35235427
éé8群ï¼å·²æ»¡ï¼: 44752220
éé9群ï¼å·²æ»¡ï¼: 11045002277
éé10群(已满): 27360019755
éé11群(已满):24330026964
éé12群(已满):27210038956
éé13群:83695000992
ç»´æ¤è
姬æé£ï¼çé)ãåºå®¶é
å¿«éå¼å§
读Excel
demo代ç å°åï¼https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java
详ç»ææ¡£å°åï¼https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read
/**
* æç®åç读
* <p>1. å建excel对åºçå®ä½å¯¹è±¡ åç
§{@link DemoData}
* <p>2. ç±äºé»è®¤ä¸è¡è¡ç读åexcelï¼æ以éè¦å建excelä¸è¡ä¸è¡çåè°çå¬å¨ï¼åç
§{@link DemoDataListener}
* <p>3. ç´æ¥è¯»å³å¯
*/
@Test
public void simpleRead() {
String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
// è¿é éè¦æå®è¯»ç¨åªä¸ªclasså»è¯»ï¼ç¶å读å第ä¸ä¸ªsheet æ件æµä¼èªå¨å
³é
EasyExcel.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead();
}
åExcel
demo代ç å°åï¼https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java
详ç»ææ¡£å°åï¼https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write
/**
* æç®åçå
* <p>1. å建excel对åºçå®ä½å¯¹è±¡ åç
§{@link com.alibaba.easyexcel.test.demo.write.DemoData}
* <p>2. ç´æ¥åå³å¯
*/
@Test
public void simpleWrite() {
String fileName=TestFileUtil.getPath()+"write"+System.currentTimeMillis()+".xlsx";
// è¿é éè¦æå®åç¨åªä¸ªclasså»è¯»ï¼ç¶ååå°ç¬¬ä¸ä¸ªsheetï¼ååä¸ºæ¨¡æ¿ ç¶åæ件æµä¼èªå¨å
³é
// å¦æè¿éæ³ä½¿ç¨03 å ä¼ å
¥excelTypeåæ°å³å¯
EasyExcel.write(fileName,DemoData.class).sheet("模æ¿").doWrite(data());
}
webä¸ä¼ ãä¸è½½
demo代ç å°åï¼https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java
/**
* æ件ä¸è½½ï¼å¤±è´¥äºä¼è¿åä¸ä¸ªæé¨åæ°æ®çExcelï¼
* <p>
* 1. å建excel对åºçå®ä½å¯¹è±¡ åç
§{@link DownloadData}
* <p>
* 2. 设置è¿åç åæ°
* <p>
* 3. ç´æ¥åï¼è¿é注æï¼finishçæ¶åä¼èªå¨å
³éOutputStream,å½ç¶ä½ å¤é¢åå
³éæµé®é¢ä¸å¤§
*/
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
// è¿é注æ æåå¦ååºä½¿ç¨swagger ä¼å¯¼è´åç§é®é¢ï¼è¯·ç´æ¥ç¨æµè§å¨æè
ç¨postman
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
// è¿éURLEncoder.encodeå¯ä»¥é²æ¢ä¸æä¹±ç å½ç¶åeasyexcel没æå
³ç³»
String fileName=URLEncoder.encode("æµè¯","UTF-8").replaceAll("\\+","%20");
response.setHeader("Content-disposition","attachment;filename*=utf-8''"+fileName+".xlsx");
EasyExcel.write(response.getOutputStream(),DownloadData.class).sheet("模æ¿").doWrite(data());
}
/**
* æ件ä¸ä¼
* <p>1. å建excel对åºçå®ä½å¯¹è±¡ åç
§{@link UploadData}
* <p>2. ç±äºé»è®¤ä¸è¡è¡ç读åexcelï¼æ以éè¦å建excelä¸è¡ä¸è¡çåè°çå¬å¨ï¼åç
§{@link UploadDataListener}
* <p>3. ç´æ¥è¯»å³å¯
*/
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file)throws IOException{
EasyExcel.read(file.getInputStream(),UploadData.class,new UploadDataListener(uploadDAO)).sheet().doRead();
return"success";
}
Top Related Projects
Mirror of Apache POI
A Python module for creating Excel XLSX files.
A pure PHP library for reading and writing spreadsheet files
📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot