Skip to content

Commit

Permalink
easyexcel plus init
Browse files Browse the repository at this point in the history
  • Loading branch information
jipengfei-jpf committed Nov 20, 2024
1 parent e7673f3 commit 7062b45
Show file tree
Hide file tree
Showing 35 changed files with 38 additions and 786 deletions.
9 changes: 0 additions & 9 deletions .gitee/ISSUE_TEMPLATE.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
# 建议先去看文档
[快速开始](https://easyexcel.opensource.alibaba.com/docs/current/)[常见问题](https://easyexcel.opensource.alibaba.com/qa/)
# 异常代码
```java
这里写你的代码
```
# 异常提示
大家尽量把问题一次性描述清楚,然后贴上全部异常,这样方便把问题一次性解决掉。
# 其他描述
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
---
name: bug
about: 发现一个新的Bug
title: ''
labels: bug
assignees: zhuangjiaju

---

# 建议先去看文档
[快速开始](https://easyexcel.opensource.alibaba.com/docs/current/)[常见问题](https://easyexcel.opensource.alibaba.com/qa/)
# 触发场景描述

# 触发Bug的代码
```java
这里写代码
```
# 提示的异常或者没有达到的效果
大家尽量把问题一次性描述清楚,然后贴上全部异常,这样方便把问题一次性解决掉。
至少大家要符合一个原则就是,能让其他人复现出这个问题,如果无法复现,肯定无法解决。
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
---
name: question
about: 有使用疑问,请先阅读“快速开始”,上面无法解决再提交问题。处理完请关闭问题。
title: ''
labels: help wanted
assignees: ''

---

# 建议先去看文档
[快速开始](https://easyexcel.opensource.alibaba.com/docs/current/)[常见问题](https://easyexcel.opensource.alibaba.com/qa/)
# 异常代码
```java
这里写你的代码
```
# 异常提示
大家尽量把问题一次性描述清楚,然后贴上全部异常,这样方便把问题一次性解决掉。
至少大家要符合一个原则就是,能让其他人复现出这个问题,如果无法复现,肯定无法解决。
# 问题描述
12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/suggest.md
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
---
name: suggest
about: 给出一些建议的能
title: ''
labels: suggest
assignees: ''

---

# 建议先去看文档
[快速开始](https://easyexcel.opensource.alibaba.com/docs/current/)[常见问题](https://easyexcel.opensource.alibaba.com/qa/)
# 建议描述
10 changes: 0 additions & 10 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
## 关联的ISSUE
TODO 请说明关联的异常
## 问题描述&解决
TODO 描述下出了什么问题,必要的话提供excel。在PR合并前,审核同学一定会复现问题,然后再PR合并的。
## 代码注意点
* 确认已经安装了阿里巴巴代码规约插件:[alibaba-java-coding-guidelines ](https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines)
* src/main 下面不要出现中文注释
* src/test/core && src/test/demo 下面要新增测试案例请严格参照其他的,包括注释等等什么都不要错
* 如果只是自己测试 全部加入到 src/test/temp
* 如果改动量较大(5+文件)尽量先和作者沟通,这个风险很大
9 changes: 0 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
## 前言
非常感谢您愿意协助EasyExcel的开发,EasyExcel成长离不开大家的贡献。但是为了合作的更有效率,希望我们在贡献代码的时候能按照如下约定。
## 提前沟通
尽量把自己的想法和实现思路提前沟通,可以通过issue,钉钉,QQ都可以,可能很多问题我们内部已经讨论过,由于各种原因后续不会支持,但是您这边又开发好了,这样容易浪费您的时间。
## 代码规范
请先安装阿里巴巴代码规约插件!!!https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines
目前代码规范已经集成了自动校验,然后源代码尽量不要有中文注释。在新增功能的时候,尽量注意补充junit。core代表每次travis-ci都会跑的测试案例,然后demo用于对外看到,temp里面随便写。
## 提交分支
建议提交到最新的版本号.x上面,比如 3.x之类的版本,为了方便其他同学阅读源代码,所以目前的思路是master和maven center的最新版本代码保持一致,然后您提交过来的代码我们可能会稍微做一些修改。所以提交到开发分支会比较好。fork也可以直接fork该分支。
157 changes: 0 additions & 157 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,157 +0,0 @@
EasyExcel
======================
[![Build Status](https://github.com/alibaba/easyexcel/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/alibaba/easyexcel/actions/workflows/ci.yml?query=branch%3Amaster)
[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.alibaba/easyexcel/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.alibaba/easyexcel)
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![](https://img.shields.io/badge/EasyExcel-Check%20Your%20Contribution-orange)](https://opensource.alibaba.com/contribution_leaderboard/details?projectValue=easyexcel)

[Communication Group 1 in QQ(Full): 662022184](https://jq.qq.com/?_wv=1027&k=1T21jJxh)
[Communication Group 2 in QQ(Full): 1097936804](https://jq.qq.com/?_wv=1027&k=j5zEy6Xl)
[Communication Group 3 in QQ(Full): 453928496](https://qm.qq.com/cgi-bin/qm/qr?k=e2ULsA5A0GldhV2CXJ8sIbAyu9I6qqs7&jump_from=webapi)
[Communication Group 4 in QQ: 496594404](https://qm.qq.com/cgi-bin/qm/qr?k=e_aVG1Q7gi0PJUBkbrUGAgbeO3kUEInK&jump_from=webapi)
[Communication Group 1 in DingTalk(Full): 21960511](https://qr.dingtalk.com/action/joingroup?code=v1,k1,cchz6k12ci9B08NNqhNRFGXocNVHrZtW0kaOtTKg/Rk=&_dt_no_comment=1&origin=11)
[Communication Group 2 in DingTalk(Full): 32796397](https://qr.dingtalk.com/action/joingroup?code=v1,k1,jyU9GtEuNU5S0QTyklqYcYJ8qDZtUuTPMM7uPZTS8Hs=&_dt_no_comment=1&origin=11)
[Communication Group 3 in DingTalk(Full): 33797247](https://qr.dingtalk.com/action/joingroup?code=v1,k1,3UGlEScTGQaHpW2cIRo+gkxJ9EVZ5fz26M6nW3uFP30=&_dt_no_comment=1&origin=11)
[Communication Group 4 in DingTalk(Full): 33491624](https://qr.dingtalk.com/action/joingroup?code=v1,k1,V14Pb65Too70rQkEaJ9ohb6lZBZbtp6jIL/q9EWh9vA=&_dt_no_comment=1&origin=11)
[Communication Group 5 in DingTalk: 32134498](https://h5.dingtalk.com/circle/healthCheckin.html?dtaction=os&corpId=dingb9fa1325d9dccc3ecac589edd02f1650&5233a=71a83&cbdbhh=qwertyuiop)
[Official Website: https://yuque.com/easyexcel](https://www.yuque.com/easyexcel/doc/easyexcel)

[FAQ](https://www.yuque.com/easyexcel/faq)
#### It is recommended to join a DingTalk group

# EasyExcel, a java toolkit for parsing Excel easily
There are several java frameworks or toolkit which can parse and generate Excel, such as Apache POI or jxl. But they all have some difficulties to handle problems like excessive memory usage. Apache POI framework has a set of SAX mode API can fix some memory overflow problems at some extent, but it still has some flaws. For example, the unzipping and the storage of the unzipping of Excel file in version 07 are done in memory, so the memory consumption is still very high. The EasyExcel toolkit rewrites the logic of POI for parsing Excel version 07. One 3 megabytes Excel file parsed with POI still requires about 100M memory, which can be reduced to a few megabyte by using EasyExcel instead. And yes, there is no memory overflow for even larger excel with EasyExcel. EasyExcel version 03 depends on POI SAX model and does model transformation/encapsulation in the upper layer to make it simpler and more convenient for users.

## Using EasyExcel version 3.0.2+, a machine with 64M RAM can read a 75 megabyte Excel file containing 460,000 rows and 25 columns in 20 seconds
Of course, there is also a very fast mode can be faster, but the memory consumption will be a little more than 100M
![img](img/readme/large.png)

## Version support
* EasyExcel version 2+ works on Java7 or Java6
* EasyExcel version 3+ works on Java8 or java8+
### About version upgrade
* It is not recommended upgrading across major versions, especially across 2 major versions.
* There are some incompatibilities in upgrading from version 2+ to version 3+.
* Using a custom interceptor to modify the style can cause problems, even if it does not compile with errors.
* When reading the Excel file, the `invoke` function will throw an exception, there will not be an additional layer of `ExcelAnalysisException` wrapped here, and it will not compile with errors.
* Style and other annotations involving `boolean` or some enumeration values have been changed, adding the default value. The compiler will report an error, just change the annotation.
* It is recommended to re-test the relevant functions after upgrading across major versions.

### Latest Version
```xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.0.2</version>
</dependency>
```

## Advertising space
### Alibaba New Retail Business Department Recruitment
Alibaba New Retail Business Department sincerely recruit JAVA senior development, technical experts. If you are interested, you can contact us by WeChat, or send your Resume to my email [email protected].
### EasyExcel personnel recruitment
Anyone who wants to participate in this project can apply, mainly responsible for answering questions in the communication group and dealing with the issues. Of course, you can also do some PR.
Since there is no material reward for participating in the open source project, and the current maintainers are also maintaining the project in their spare time. So people who want to join this project need to be persistent, not just on a whim.
The requirements are as follows:
* There are certain java coding skills & good coding habits
* Understand the read&write principles of EasyExcel
* Has passion for open source projects
* Be able to do things consistently for a long time
* Your job is not so busy

## Related Documents
* [Quick Start](https://www.yuque.com/easyexcel/doc/easyexcel)
* [About Us](/abouteasyexcel.md)
* [Update Notes](/update.md)
* [Code Contribution](https://www.yuque.com/easyexcel/doc/contribute)

## Maintainers
姬朋飞(玉霄)、庄家钜、怀宇
## Quick Start
### Read Excel File
DEMO:[https://github.com/alibaba/easyexcel/blob/master/src/test/java/com/alibaba/easyexcel/demo/read/ReadTest.java](/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java)

```java
/**
* The easiest way to read Excel file using EasyExcel toolkit
*
* <p>
* 1. Create an entity object, such as {@link DemoData}, each property of the entity object corresponds to a specific field in any row of Excel.
* 2. When reading each row of an Excel file, create a callback listener for the corresponding row. Refer to{@link DemoDataListener}
* 3. Invoke the read function
* </p>
*/
@Test
public void simpleRead() {
String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
// Specify which entity object class to use to read the Excel content. The file stream will close automatically after reading the first sheet of Excel.
EasyExcel.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead();
}
```

### Write Excel File
DEMO:[https://github.com/alibaba/easyexcel/blob/master/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java](/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java)
```java
/**
* The easiest way to write Excel file using EasyExcel toolkit
*
* <p>
* 1. Create an entity object, refer to{@link write.demo.plus.easyexcel.test.DemoData}.
* Each property of the entity object corresponds to a specific field of Excel
* 2. Invoke write function
* </p>
*/
@Test
public void simpleWrite() {
String fileName = TestFileUtil.getPath() + "write" + System.currentTimeMillis() + ".xlsx";
// Specify which entity object class to use to write Excel, it will write to the first sheet of Excel with the name template. Then the file stream will be closed automatically.
// With version 03, just pass in the excelType parameter
EasyExcel.write(fileName, DemoData.class).sheet("template").doWrite(data());
}
```

### File Uploading&Downloading
DEMO:[https://github.com/alibaba/easyexcel/blob/master/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java](/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java)
```java
/**
* File downloading
*
* Note: returns an Excel with partial data if it fails
*
* <p>
* 1. Create an entity object, refer to{@link DownloadData}.
* Each property of the entity object corresponds to a specific field of Excel
* 2. Specify the returned properties
* 3. Invoke write function, then the OutputStream is automatically closed when it ends.
* </p>
*/
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
// Using swagger may cause some problems, please use your browser directly or use postman to invoke this
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
// URLEncoder.encode function can prevent Chinese garbled code
String fileName = URLEncoder.encode("test", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), DownloadData.class).sheet("template").doWrite(data());
}

/**
* File uploading
*
* <p>
* 1. Create an entity object, refer to{@link UploadData}
* Each property of the entity object corresponds to a specific field of Excel
* 2. When reading each row of an Excel file, create a callback listener for the corresponding row. Refer to{@link UploadDataListener}
* 3. Invoke read function
* </p>
*/
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file) throws IOException {
EasyExcel.read(file.getInputStream(), UploadData.class, new UploadDataListener(uploadDAO)).sheet().doRead();
return "success";
}
```
### Contact Us
If you have any questions, Alibaba colleagues can find me in DingTalk, and others can leave messages here. All related questions are well welcomed.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void finish() {
}

// close csv.
// https://github.com/alibaba/easyexcel/issues/2309
// https://github.com/CodePhiliaX/easyexcel-plus/issues/2309
try {
if ((readWorkbookHolder instanceof CsvReadWorkbookHolder)
&& ((CsvReadWorkbookHolder) readWorkbookHolder).getCsvParser() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void processRecord(XlsReadContext xlsReadContext, Record record) {
xlsReadSheetHolder.setTempRowType(RowTypeEnum.EMPTY);
} else if (record instanceof MissingCellDummyRecord) {
MissingCellDummyRecord mcdr = (MissingCellDummyRecord)record;
// https://github.com/alibaba/easyexcel/issues/2236
// https://github.com/CodePhiliaX/easyexcel-plus/issues/2236
// Some abnormal XLS, in the case of data already exist, or there will be a "MissingCellDummyRecord"
// records, so if the existing data, empty data is ignored
xlsReadSheetHolder.getCellMap().putIfAbsent(mcdr.getColumn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

/**
*
* default @see com.alibaba.excel.util.TypeUtil if default is not meet you can set format
* default @see ai.chat2db.excel.util.TypeUtil if default is not meet you can set format
*
* @return Format string
* @deprecated please use {@link DateTimeFormat}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ai.chat2db.excel.metadata.data.ReadCellData;

/**
* Read not to {@code com.alibaba.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Read not to {@code ai.chat2db.excel.metadata.BasicParameter#clazz} value, the default will return type.
*
* @author Jiaju Zhuang
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This exception will only stop the parsing of the current sheet. If you want to stop the entire excel parsing, please
* use ExcelAnalysisStopException.
*
* The com.alibaba.excel.read.listener.ReadListener#doAfterAllAnalysed(com.alibaba.excel.context.AnalysisContext) method
* The ai.chat2db.excel.read.listener.ReadListener#doAfterAllAnalysed(ai.chat2db.excel.context.AnalysisContext) method
* is called after the call is stopped.
*
* @author Jiaju Zhuang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public ExcelReaderBuilder useDefaultListener(Boolean useDefaultListener) {
}

/**
* Read not to {@code com.alibaba.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Read not to {@code ai.chat2db.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Is only effective when set `useDefaultListener=true` or `useDefaultListener=null`.
*
* @see ReadDefaultReturnEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Object buildNoModel(Map<Integer, ReadCellData<?>> cellDataMap, ReadSheet
}
}
}
// fix https://github.com/alibaba/easyexcel/issues/2014
// fix https://github.com/CodePhiliaX/easyexcel-plus/issues/2014
int headSize = calculateHeadSize(readSheetHolder);
while (index < headSize) {
map.put(index, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class ReadWorkbook extends ReadBasicParameter {
private Boolean useDefaultListener;

/**
* Read not to {@code com.alibaba.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Read not to {@code ai.chat2db.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Is only effective when set `useDefaultListener=true` or `useDefaultListener=null`.
*
* @see ReadDefaultReturnEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ReadSheetHolder extends AbstractReadHolder {
private ReadCellData<?> tempCellData;
/**
* Read the size of the largest head in sheet head data.
* see https://github.com/alibaba/easyexcel/issues/2014
* see https://github.com/CodePhiliaX/easyexcel-plus/issues/2014
*/
private Integer maxNotEmptyDataHeadSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class ReadWorkbookHolder extends AbstractReadHolder {
private Boolean autoCloseStream;

/**
* Read not to {@code com.alibaba.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Read not to {@code ai.chat2db.excel.metadata.BasicParameter#clazz} value, the default will return type.
* Is only effective when set `useDefaultListener=true` or `useDefaultListener=null`.
*
* @see ReadDefaultReturnEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BeanMapUtils {
* <code>BeanMap.Generator</code> instead of this static method.
*
* Custom naming policy to prevent null pointer exceptions.
* see: https://github.com/alibaba/easyexcel/issues/2064
* see: https://github.com/CodePhiliaX/easyexcel-plus/issues/2064
*
* @param bean the JavaBean underlying the map
* @return a new <code>BeanMap</code> instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void addBasicTypeToExcel(RowData oneRowData, Row row, int rowIndex, int
if (dataIndex >= oneRowData.size()) {
return;
}
// fix https://github.com/alibaba/easyexcel/issues/1702
// fix https://github.com/CodePhiliaX/easyexcel-plus/issues/1702
// If there is data, it is written to the next cell
maxCellIndex++;

Expand Down Expand Up @@ -196,7 +196,7 @@ private void addJavaObjectToExcel(Object oneRowData, Row row, int rowIndex, int
writeContext, row, rowIndex, null, maxCellIndex, relativeRowIndex, Boolean.FALSE, excelContentProperty);
WriteHandlerUtils.beforeCellCreate(cellWriteHandlerContext);

// fix https://github.com/alibaba/easyexcel/issues/1870
// fix https://github.com/CodePhiliaX/easyexcel-plus/issues/1870
// If there is data, it is written to the next cell
Cell cell = WorkBookUtil.createCell(row, maxCellIndex);
cellWriteHandlerContext.setCell(cell);
Expand Down
Loading

0 comments on commit 7062b45

Please sign in to comment.