close
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ permissions:
pull-requests: write

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Local Maven Repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'adopt'
- name: Check code style
run: ./mvnw spotless:check

test:
runs-on: ubuntu-24.04
strategy:
Expand Down
30 changes: 20 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ FastExcel 欢迎社区的每一位用户和开发者成为贡献者。无论是
### 高质量问题报告

为了提高沟通效率,请在提交问题前:

1. **搜索现有问题**:检查您的问题是否已被报告。如果存在,请直接在现有问题下评论补充详细信息,而不是创建新问题。
2. **使用问题模板**:问题模板位于 [ISSUE TEMPLATE](./.github/ISSUE_TEMPLATE),请按照模板要求填写,以确保问题描述准确且完整。

以下情况适合提交新问题:

- Bug 报告
- 新功能需求
- 性能问题
Expand All @@ -33,6 +35,7 @@ FastExcel 欢迎社区的每一位用户和开发者成为贡献者。无论是
所有对 FastExcel 的改进均可通过 Pull Request (PR) 实现。无论是修复 Bug、优化代码、增强功能,还是改进文档,都非常欢迎!

### 您可以贡献的方向

- 修复错别字
- 修复 Bug
- 删除冗余代码
Expand All @@ -45,16 +48,18 @@ FastExcel 欢迎社区的每一位用户和开发者成为贡献者。无论是
**原则**:**任何有助于项目改进的 PR 都值得鼓励!**

在提交 PR 前,请熟悉以下指南:

1. [工作区准备](#工作区准备)
2. [分支定义](#分支定义)
3. [提交规则](#提交规则)
4. [PR 说明](#pr说明)
4. [PR 说明](#PR-说明)

---

### 工作区准备

确保您已注册 GitHub 账号,并按照以下步骤完成本地开发环境配置:

1. **Fork 仓库**:在 FastExcel 的 [GitHub 页面](https://github.com/fast-excel/fastexcel) 点击 `Fork` 按钮,将项目复制到您的 GitHub 账户下,例如:`https://github.com/<your-username>/fastexcel`。
2. **克隆代码库**:运行以下命令将 Fork 的项目克隆到本地:
```bash
Expand All @@ -72,6 +77,7 @@ FastExcel 欢迎社区的每一位用户和开发者成为贡献者。无论是
### 分支定义

在 FastExcel 中,所有贡献应基于 `main` 开发分支。此外,还有以下分支类型:

- **release 分支**:用于版本发布(如 `0.6.0`, `0.6.1`)。
- **feature 分支**:用于开发较大的功能。
- **hotfix 分支**:用于修复重要 Bug。
Expand All @@ -83,25 +89,31 @@ FastExcel 欢迎社区的每一位用户和开发者成为贡献者。无论是
### 提交规则

#### 提交信息

请确保提交消息清晰且具有描述性,遵循以下格式:

- **docs**: 更新文档,例如 `docs: 更新 PR 提交指南`。
- **feature**: 新功能,例如 `feature: 支持 并发写入`。
- **bugfix**: 修复 Bug,例如 `bugfix: 修复空指针异常`。
- **refactor**: 重构代码,例如 `refactor: 优化数据处理逻辑`。
- **test**: 增加或改进测试,例如 `test: 添加单元测试`。

不建议使用模糊的提交信息,如:

- ~~修复问题~~
- ~~更新代码~~

如果需要帮助,请参考 [如何编写 Git 提交消息](http://chris.beams.io/posts/git-commit/)。

#### 提交内容

一次提交应包含完整且可审查的更改,确保:

- 避免提交过于庞大的改动。
- 每次提交内容独立且可通过 CI 测试。

另外,请确保提交时配置正确的 Git 用户信息:

```bash
git config --get user.name
git config --get user.email
Expand All @@ -111,7 +123,7 @@ git config --get user.email

### PR 说明

为了帮助审阅者快速了解 PR 的内容和目的,请使用 [PR 模板](.github/PULL_REQUEST_TEMPLATE/pull_request_template.md)。详细的描述将极大提高代码审阅效率。
为了帮助审阅者快速了解 PR 的内容和目的,请使用 [PR 模板](.github/pull_request_template.md)。详细的描述将极大提高代码审阅效率。

---

Expand All @@ -124,6 +136,7 @@ git config --get user.email
## 其他参与方式

除了直接贡献代码,以下方式同样是对 FastExcel 的宝贵支持:

- 回答其他用户的问题。
- 帮助审阅他人的 PR。
- 提出改进建议。
Expand All @@ -134,15 +147,12 @@ git config --get user.email

## 代码风格

请遵循 [阿里巴巴 Java 编码规范](https://alibaba.github.io/Alibaba-Java-Coding-Guidelines/) 进行代码编写。
您可以选择安装以下插件(非必需)以帮助检查代码风格:
- **IntelliJ IDEA 插件**:[安装指南](https://github.com/alibaba/p3c/blob/master/idea-plugin/README.md)
- **Eclipse 插件**:[安装指南](https://github.com/alibaba/p3c/blob/master/eclipse-plugin/README.md)
FastExcel 使用 [Spotless](https://github.com/diffplug/spotless) 作为代码格式化工具。请确保在提交前运行以下命令以自动格式化代码:

```shell
./mvnw spotless:apply
```

贡献者也可以在IDE中导入代码规范配置,以确保符合项目的代码规范:
- **IntelliJ IDEA 配置**:[配置文件下载](https://github.com/fast-excel/fastexcel/blob/main/style/codestyle/idea/fastexcel_codestyle.xml)
- **Eclipse 配置**:[配置文件下载](https://github.com/fast-excel/fastexcel/blob/main/style/codestyle/eclipse/fastexcel_codestyle.xml)

---

**最后,感谢您对 FastExcel 的支持!每一份帮助,都是我们前进的动力。**
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,5 @@ Thank you to all the people who already contributed to FastExcel!

## License

The project is licensed under the [Apache License 2.0](https://github.com/fast-excel/fastexcel/blob/main/LICENSE).
The project is licensed under the [Apache License 2.0](LICENSE).

Binary file removed doc/font/SimHei.ttf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/**
* empty
*
* @author Jiaju Zhuang
*
*/
public class Empty {
}
public class Empty {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,42 @@ public class StyleTestUtils {

public static byte[] getFillForegroundColor(Cell cell) {
if (cell instanceof XSSFCell) {
return ((XSSFCell)cell).getCellStyle().getFillForegroundColorColor().getRGB();
return ((XSSFCell) cell)
.getCellStyle()
.getFillForegroundColorColor()
.getRGB();
} else {
return short2byte(((HSSFCell)cell).getCellStyle().getFillForegroundColorColor().getTriplet());
return short2byte(((HSSFCell) cell)
.getCellStyle()
.getFillForegroundColorColor()
.getTriplet());
}
}

public static byte[] getFontColor(Cell cell, Workbook workbook) {
if (cell instanceof XSSFCell) {
return ((XSSFCell)cell).getCellStyle().getFont().getXSSFColor().getRGB();
return ((XSSFCell) cell).getCellStyle().getFont().getXSSFColor().getRGB();
} else {
return short2byte(((HSSFCell)cell).getCellStyle().getFont(workbook).getHSSFColor((HSSFWorkbook)workbook)
.getTriplet());
return short2byte(((HSSFCell) cell)
.getCellStyle()
.getFont(workbook)
.getHSSFColor((HSSFWorkbook) workbook)
.getTriplet());
}
}

public static short getFontHeightInPoints(Cell cell, Workbook workbook) {
if (cell instanceof XSSFCell) {
return ((XSSFCell)cell).getCellStyle().getFont().getFontHeightInPoints();
return ((XSSFCell) cell).getCellStyle().getFont().getFontHeightInPoints();
} else {
return ((HSSFCell)cell).getCellStyle().getFont(workbook).getFontHeightInPoints();
return ((HSSFCell) cell).getCellStyle().getFont(workbook).getFontHeightInPoints();
}
}

private static byte[] short2byte(short[] shorts) {
byte[] bytes = new byte[shorts.length];
for (int i = 0; i < shorts.length; i++) {
bytes[i] = (byte)shorts[i];
bytes[i] = (byte) shorts[i];
}
return bytes;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package cn.idev.excel.test.core.annotation;

import java.util.Date;

import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.format.DateTimeFormat;
import cn.idev.excel.annotation.format.NumberFormat;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;

import java.util.Date;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

/**
* @author Jiaju Zhuang
*
*/
@Getter
@Setter
Expand All @@ -34,6 +32,7 @@ public class AnnotationData {

@ExcelIgnore
private String ignore;

private static final String staticFinal = "test";
private transient String transientString;
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package cn.idev.excel.test.core.annotation;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import cn.idev.excel.event.AnalysisEventListener;
import cn.idev.excel.util.DateUtils;
import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.event.AnalysisEventListener;
import cn.idev.excel.exception.ExcelCommonException;
import cn.idev.excel.util.DateUtils;
import com.alibaba.fastjson2.JSON;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Jiaju Zhuang
*
*/
public class AnnotationDataListener extends AnalysisEventListener<AnnotationData> {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationDataListener.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package cn.idev.excel.test.core.annotation;

import cn.idev.excel.EasyExcel;
import cn.idev.excel.test.core.StyleTestUtils;
import cn.idev.excel.test.util.TestFileUtil;
import cn.idev.excel.util.DateUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import cn.idev.excel.util.DateUtils;
import cn.idev.excel.test.core.StyleTestUtils;
import cn.idev.excel.test.util.TestFileUtil;
import cn.idev.excel.EasyExcel;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
Expand All @@ -21,7 +19,7 @@
import org.junit.jupiter.api.TestMethodOrder;

/**
* @author Jiaju Zhuang
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
public class AnnotationDataTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package cn.idev.excel.test.core.annotation;

import cn.idev.excel.annotation.ExcelProperty;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

/**
* @author Jiaju Zhuang
*
*/
@Getter
@Setter
@EqualsAndHashCode
public class AnnotationIndexAndNameData {
@ExcelProperty(value = "第四个", index = 4)
private String index4;

@ExcelProperty(value = "第二个")
private String index2;

@ExcelProperty(index = 0)
private String index0;

@ExcelProperty(value = "第一个", index = 1)
private String index1;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package cn.idev.excel.test.core.annotation;

import java.util.ArrayList;
import java.util.List;

import cn.idev.excel.event.AnalysisEventListener;
import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.event.AnalysisEventListener;
import com.alibaba.fastjson2.JSON;

import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Jiaju Zhuang
*
*/
public class AnnotationIndexAndNameDataListener extends AnalysisEventListener<AnnotationIndexAndNameData> {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotationIndexAndNameDataListener.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package cn.idev.excel.test.core.annotation;

import cn.idev.excel.EasyExcel;
import cn.idev.excel.test.util.TestFileUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import cn.idev.excel.test.util.TestFileUtil;
import cn.idev.excel.EasyExcel;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
Expand All @@ -15,7 +13,7 @@
/**
* Annotation data test
*
* @author Jiaju Zhuang
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
public class AnnotationIndexAndNameDataTest {
Expand Down Expand Up @@ -48,8 +46,9 @@ public void t03ReadAndWriteCsv() {

private void readAndWrite(File file) {
EasyExcel.write(file, AnnotationIndexAndNameData.class).sheet().doWrite(data());
EasyExcel.read(file, AnnotationIndexAndNameData.class, new AnnotationIndexAndNameDataListener()).sheet()
.doRead();
EasyExcel.read(file, AnnotationIndexAndNameData.class, new AnnotationIndexAndNameDataListener())
.sheet()
.doRead();
}

private List<AnnotationIndexAndNameData> data() {
Expand Down
Loading