diff --git a/.travis.yml b/.travis.yml
index 60343c4e..8191cf3c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,4 +6,5 @@ cache:
before_install:
- chmod +x mvnw
install:
- - ./mvnw install -Dgpg.skip -B -V -Dmaven.test.skip=true
\ No newline at end of file
+ - ./mvnw install -Dgpg.skip -B -V -Dmaven.test.skip=true
+ - ./mvnw javadoc:javadoc
\ No newline at end of file
diff --git a/README.md b/README.md
index 17ce6190..e48cd83b 100644
--- a/README.md
+++ b/README.md
@@ -25,10 +25,10 @@ Java解析、生成Excel比较有名的框架有Apache poi、jxl。但他们都
1. 创建excel对应的实体对象 参照{@link DemoData} + *
2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener} + *
3. 直接读即可 */ @Test public void simpleRead() { @@ -55,8 +55,8 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja ```java /** * 最简单的写 - *
1. 创建excel对应的实体对象 参照{@link com.alibaba.easyexcel.test.demo.write.DemoData} + *
2. 直接写即可 */ @Test public void simpleWrite() { @@ -72,9 +72,9 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja ```java /** * 文件下载 - *
1. 创建excel对应的实体对象 参照{@link DownloadData} + *
2. 设置返回的 参数 + *
3. 直接写,这里注意,finish的时候会自动关闭OutputStream,当然你外面再关闭流问题不大 */ @GetMapping("download") public void download(HttpServletResponse response) throws IOException { @@ -86,9 +86,9 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja /** * 文件上传 - *
1. 创建excel对应的实体对象 参照{@link UploadData} + *
2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link UploadDataListener} + *
3. 直接读即可
*/
@PostMapping("upload")
@ResponseBody
diff --git a/pom.xml b/pom.xml
index 30049644..f85fd407 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ * 3. 直接读即可
*/
@Test
public void simpleRead() {
@@ -127,9 +127,9 @@ public class IndexOrNameData {
/**
* 指定列的下标或者列名
*
- * 1. 创建excel对应的实体对象,并使用{@link ExcelProperty}注解. 参照{@link IndexOrNameData}
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link IndexOrNameDataListener}
+ * 3. 直接读即可
*/
@Test
public void indexOrNameRead() {
@@ -150,9 +150,9 @@ public class IndexOrNameData {
```java
/**
* 读多个sheet,这里注意一个sheet不能读取多次,多次读取需要重新读取文件
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ * 3. 直接读即可
*/
@Test
public void repeatedRead() {
@@ -248,9 +248,9 @@ public class CustomStringStringConverter implements Converter
* 默认读的转换器{@link DefaultConverterLoader#loadDefaultReadConverter()}
- * 1. 创建excel对应的实体对象 参照{@link ConverterData}.里面可以使用注解{@link DateTimeFormat}、{@link NumberFormat}或者自定义注解
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link ConverterDataListener}
+ * 3. 直接读即可
*/
@Test
public void converterRead() {
@@ -277,9 +277,9 @@ public class CustomStringStringConverter implements Converter 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ * 3. 设置headRowNumber参数,然后读。 这里要注意headRowNumber如果不指定, 会根据你传入的class的{@link ExcelProperty#value()}里面的表头的数量来决定行数,
* 如果不传入class则默认为1.当然你指定了headRowNumber不管是否传入class都是以你传入的为准。
*/
@Test
@@ -335,9 +335,9 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja
```java
/**
* 文件上传
- * 1. 创建excel对应的实体对象 参照{@link UploadData}
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link UploadDataListener}
+ * 3. 直接读即可
*/
@PostMapping("upload")
@ResponseBody
@@ -381,8 +381,8 @@ public class DemoData {
```java
/**
* 最简单的写
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 直接写即可
*/
@Test
public void simpleWrite() {
@@ -425,9 +425,9 @@ public class IndexData {
```java
/**
* 指定写入的列
- * 1. 创建excel对应的实体对象 参照{@link IndexData}
+ * 2. 使用{@link ExcelProperty}注解指定写入的列
+ * 3. 直接写即可
*/
@Test
public void indexWrite() {
@@ -456,9 +456,9 @@ public class ComplexHeadData {
```java
/**
* 复杂头写入
- * 1. 创建excel对应的实体对象 参照{@link ComplexHeadData}
+ * 2. 使用{@link ExcelProperty}注解指定复杂的头
+ * 3. 直接写即可
*/
@Test
public void complexHeadWrite() {
@@ -477,9 +477,9 @@ public class ComplexHeadData {
```java
/**
* 重复多次写入
- * 1. 创建excel对应的实体对象 参照{@link ComplexHeadData}
+ * 2. 使用{@link ExcelProperty}注解指定复杂的头
+ * 3. 直接调用二次写入即可
*/
@Test
public void repeatedWrite() {
@@ -526,9 +526,9 @@ public class ConverterData {
```java
/**
* 日期、数字或者自定义格式转换
- * 1. 创建excel对应的实体对象 参照{@link ConverterData}
+ * 2. 使用{@link ExcelProperty}配合使用注解{@link DateTimeFormat}、{@link NumberFormat}或者自定义注解
+ * 3. 直接写即可
*/
@Test
public void converterWrite() {
@@ -561,8 +561,8 @@ public class ImageData {
```java
/**
* 图片导出
- * 1. 创建excel对应的实体对象 参照{@link ImageData}
+ * 2. 直接写即可
*/
@Test
public void imageWrite() throws Exception {
@@ -601,10 +601,10 @@ public class ImageData {
```java
/**
* 根据模板写入
- * 1. 创建excel对应的实体对象 参照{@link IndexData}
+ * 2. 使用{@link ExcelProperty}注解指定写入的列
+ * 3. 使用withTemplate 读取模板
+ * 4. 直接写即可
*/
@Test
public void templateWrite() {
@@ -641,9 +641,9 @@ public class WidthAndHeightData {
```java
/**
* 列宽、行高
- * 1. 创建excel对应的实体对象 参照{@link WidthAndHeightData}
+ * 2. 使用注解{@link ColumnWidth}、{@link HeadRowHeight}、{@link ContentRowHeight}指定宽度或高度
+ * 3. 直接写即可
*/
@Test
public void widthAndHeightWrite() {
@@ -662,9 +662,9 @@ public class WidthAndHeightData {
```java
/**
* 自定义样式
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 创建一个style策略 并注册
+ * 3. 直接写即可
*/
@Test
public void styleWrite() {
@@ -705,9 +705,9 @@ public class WidthAndHeightData {
```java
/**
* 合并单元格
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 创建一个merge策略 并注册
+ * 3. 直接写即可
*/
@Test
public void mergeWrite() {
@@ -729,8 +729,8 @@ public class WidthAndHeightData {
```java
/**
* 使用table去写入
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 然后写入table即可
*/
@Test
public void tableWrite() {
@@ -764,8 +764,8 @@ public class WidthAndHeightData {
*
* 思路是这样子的,先创建List 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 2. 然后写入table即可
*/
@Test
public void dynamicHeadWrite() {
@@ -818,9 +818,9 @@ public class LongestMatchColumnWidthData {
*
* poi 自带{@link SXSSFSheet#autoSizeColumn(int)} 对中文支持也不太好。目前没找到很好的算法。 有的话可以推荐下。
*
- * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ * 3. 注册策略{@link LongestMatchColumnWidthStyleStrategy}
+ * 2. 直接写即可
*/
@Test
public void longestMatchColumnWidthWrite() {
@@ -852,9 +852,9 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/src/test/ja
```java
/**
* 文件下载
- * 1. 创建excel对应的实体对象 参照{@link DownloadData}
+ * 2. 设置返回的 参数
+ * 3. 直接写,这里注意,finish的时候会自动关闭OutputStream,当然你外面再关闭流问题不大
*/
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
diff --git a/src/main/java/com/alibaba/excel/EasyExcelFactory.java b/src/main/java/com/alibaba/excel/EasyExcelFactory.java
index c1789c13..39fe0311 100644
--- a/src/main/java/com/alibaba/excel/EasyExcelFactory.java
+++ b/src/main/java/com/alibaba/excel/EasyExcelFactory.java
@@ -136,6 +136,8 @@ public class EasyExcelFactory {
* the java OutputStream you wish to write the value to
* @param typeEnum
* 03 or 07
+ * @param needHead
+ * Whether a write header is required
* @return new ExcelWriter
* @deprecated please use {@link EasyExcel#write()}
*/
@@ -157,6 +159,7 @@ public class EasyExcelFactory {
* @param typeEnum
* 03 or 07
* @param needHead
+ * Whether a write header is required
* @param handler
* User-defined callback
* @return new ExcelWriter
@@ -182,7 +185,8 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param file
- * @return
+ * File to write
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(File file) {
return write(file, null);
@@ -192,8 +196,10 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param file
+ * File to write
* @param head
- * @return
+ * Annotate the class for configuration information
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(File file, Class head) {
ExcelWriterBuilder excelWriterBuilder = new ExcelWriterBuilder();
@@ -208,7 +214,8 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param pathName
- * @return
+ * File path to write
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(String pathName) {
return write(pathName, null);
@@ -218,8 +225,10 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param pathName
+ * File path to write
* @param head
- * @return
+ * Annotate the class for configuration information
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(String pathName, Class head) {
ExcelWriterBuilder excelWriterBuilder = new ExcelWriterBuilder();
@@ -234,7 +243,8 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param outputStream
- * @return
+ * Output stream to write
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(OutputStream outputStream) {
return write(outputStream, null);
@@ -244,8 +254,10 @@ public class EasyExcelFactory {
* Build excel the write
*
* @param outputStream
+ * Output stream to write
* @param head
- * @return
+ * Annotate the class for configuration information.
+ * @return Excel writer builder
*/
public static ExcelWriterBuilder write(OutputStream outputStream, Class head) {
ExcelWriterBuilder excelWriterBuilder = new ExcelWriterBuilder();
@@ -257,19 +269,20 @@ public class EasyExcelFactory {
}
/**
- * Build excel the 'writerSheet'
+ * Build excel the
+ * write: It automatically merges when you have more than one head
+ *
+ * read: When you have multiple heads, take the first one
*
- * @return
+ * @return The name of the sheet header
*/
String[] value() default {""};
@@ -32,14 +34,14 @@ public @interface ExcelProperty {
*
* Read or write it on the index of column,If it's equal to -1, it's sorted by Java class
*
- * @return
+ * @return Index of column
*/
int index() default -1;
/**
* Force the current field to use this converter.
*
- * @return
+ * @return Converter
*/
Class extends Converter> converter() default AutoConverter.class;
@@ -47,7 +49,7 @@ public @interface ExcelProperty {
*
* default @see com.alibaba.excel.util.TypeUtil if default is not meet you can set format
*
- * @return
+ * @return Format string
* @deprecated please use {@link com.alibaba.excel.annotation.format.DateTimeFormat}
*/
@Deprecated
diff --git a/src/main/java/com/alibaba/excel/annotation/format/DateTimeFormat.java b/src/main/java/com/alibaba/excel/annotation/format/DateTimeFormat.java
index 4d166522..96aff229 100644
--- a/src/main/java/com/alibaba/excel/annotation/format/DateTimeFormat.java
+++ b/src/main/java/com/alibaba/excel/annotation/format/DateTimeFormat.java
@@ -9,8 +9,10 @@ import java.lang.annotation.Target;
/**
* Convert date format.
*
- *
+ * write: It can be used on classes {@link java.util.Date}
+ *
+ * read: It can be used on classes {@link String}
*
* @author Jiaju Zhuang
*/
@@ -23,14 +25,14 @@ public @interface DateTimeFormat {
*
* Specific format reference {@link java.text.SimpleDateFormat}
*
- * @return
+ * @return Format pattern
*/
String value() default "";
/**
- * true if date uses 1904 windowing, or false if using 1900 date windowing.
+ * True if date uses 1904 windowing, or false if using 1900 date windowing.
*
- * @return
+ * @return True if date uses 1904 windowing, or false if using 1900 date windowing.
*/
boolean use1904windowing() default false;
}
diff --git a/src/main/java/com/alibaba/excel/annotation/format/NumberFormat.java b/src/main/java/com/alibaba/excel/annotation/format/NumberFormat.java
index 1d371e33..8951681f 100644
--- a/src/main/java/com/alibaba/excel/annotation/format/NumberFormat.java
+++ b/src/main/java/com/alibaba/excel/annotation/format/NumberFormat.java
@@ -10,8 +10,10 @@ import java.math.RoundingMode;
/**
* Convert number format.
*
- *
+ * write: It can be used on classes that inherit {@link Number}
+ *
+ * read: It can be used on classes {@link String}
*
* @author Jiaju Zhuang
*/
@@ -24,14 +26,14 @@ public @interface NumberFormat {
*
* Specific format reference {@link org.apache.commons.math3.fraction.BigFractionFormat}
*
- * @return
+ * @return Format pattern
*/
String value() default "";
/**
* Rounded by default
*
- * @return
+ * @return RoundingMode
*/
RoundingMode roundingMode() default RoundingMode.HALF_UP;
}
diff --git a/src/main/java/com/alibaba/excel/annotation/write/style/ColumnWidth.java b/src/main/java/com/alibaba/excel/annotation/write/style/ColumnWidth.java
index ae07ff00..00306cc0 100644
--- a/src/main/java/com/alibaba/excel/annotation/write/style/ColumnWidth.java
+++ b/src/main/java/com/alibaba/excel/annotation/write/style/ColumnWidth.java
@@ -20,6 +20,8 @@ public @interface ColumnWidth {
* Column width
*
* -1 means the default column width is used
+ *
+ * @return Column width
*/
int value() default -1;
}
diff --git a/src/main/java/com/alibaba/excel/annotation/write/style/ContentRowHeight.java b/src/main/java/com/alibaba/excel/annotation/write/style/ContentRowHeight.java
index 30069734..8f338e86 100644
--- a/src/main/java/com/alibaba/excel/annotation/write/style/ContentRowHeight.java
+++ b/src/main/java/com/alibaba/excel/annotation/write/style/ContentRowHeight.java
@@ -21,7 +21,7 @@ public @interface ContentRowHeight {
*
* -1 mean the auto set height
*
- * @return
+ * @return Content height
*/
short value() default -1;
}
diff --git a/src/main/java/com/alibaba/excel/annotation/write/style/HeadRowHeight.java b/src/main/java/com/alibaba/excel/annotation/write/style/HeadRowHeight.java
index 98245b7f..828d2c06 100644
--- a/src/main/java/com/alibaba/excel/annotation/write/style/HeadRowHeight.java
+++ b/src/main/java/com/alibaba/excel/annotation/write/style/HeadRowHeight.java
@@ -20,7 +20,7 @@ public @interface HeadRowHeight {
*
* -1 mean the auto set height
*
- * @return
+ * @return Header height
*/
short value() default -1;
}
diff --git a/src/main/java/com/alibaba/excel/cache/ReadCache.java b/src/main/java/com/alibaba/excel/cache/ReadCache.java
index 8bc0558a..48072fae 100644
--- a/src/main/java/com/alibaba/excel/cache/ReadCache.java
+++ b/src/main/java/com/alibaba/excel/cache/ReadCache.java
@@ -13,6 +13,7 @@ public interface ReadCache {
* Initialize cache
*
* @param analysisContext
+ * A context is the main anchorage point of a excel reader.
*/
void init(AnalysisContext analysisContext);
@@ -20,6 +21,7 @@ public interface ReadCache {
* Automatically generate the key and put it in the cache.Key start from 0
*
* @param value
+ * Cache value
*/
void put(String value);
@@ -27,7 +29,8 @@ public interface ReadCache {
* Get value
*
* @param key
- * @return
+ * Index
+ * @return Value
*/
String get(Integer key);
diff --git a/src/main/java/com/alibaba/excel/context/AnalysisContext.java b/src/main/java/com/alibaba/excel/context/AnalysisContext.java
index 2704bfd9..7b8ba86c 100644
--- a/src/main/java/com/alibaba/excel/context/AnalysisContext.java
+++ b/src/main/java/com/alibaba/excel/context/AnalysisContext.java
@@ -15,56 +15,59 @@ import com.alibaba.excel.support.ExcelTypeEnum;
/**
*
* A context is the main anchorage point of a excel reader.
- *
+ *
* @author jipengfei
*/
public interface AnalysisContext {
/**
* Select the current table
- *
+ *
* @param excelExecutor
+ * Excel file Executor
* @param readSheet
+ * sheet to read
*/
void currentSheet(ExcelExecutor excelExecutor, ReadSheet readSheet);
/**
* All information about the workbook you are currently working on
*
- * @return
+ * @return Current workbook holder
*/
ReadWorkbookHolder readWorkbookHolder();
/**
* All information about the sheet you are currently working on
*
- * @return
+ * @return Current sheet holder
*/
ReadSheetHolder readSheetHolder();
/**
* Set row of currently operated cell
- *
+ *
* @param readRowHolder
+ * Current row holder
*/
void readRowHolder(ReadRowHolder readRowHolder);
/**
* Row of currently operated cell
*
- * @return
+ * @return Current row holder
*/
ReadRowHolder readRowHolder();
/**
- * The current read operation corresponds to the 'readSheetHolder' or 'readWorkbookHolder'
- *
- * @return
+ * The current read operation corresponds to the
+ * Read key:
+ *
+ * Write key:
*/
private Map
+ * if false,Will transfer 'inputStream' to temporary files to improve efficiency
*/
public ExcelReaderBuilder mandatoryUseInputStream(Boolean mandatoryUseInputStream) {
readWorkbook.setMandatoryUseInputStream(mandatoryUseInputStream);
@@ -110,9 +110,12 @@ public class ExcelReaderBuilder {
/**
* Count the number of added heads when read sheet.
*
- *
+ * 0 - This Sheet has no head ,since the first row are the data
+ *
+ * 1 - This Sheet has one row head , this is the default
+ *
+ * 2 - This Sheet has two row head ,since the third row is the data
*
* @param headRowNumber
* @return
diff --git a/src/main/java/com/alibaba/excel/read/builder/ExcelReaderSheetBuilder.java b/src/main/java/com/alibaba/excel/read/builder/ExcelReaderSheetBuilder.java
index eb03981d..af3b05e1 100644
--- a/src/main/java/com/alibaba/excel/read/builder/ExcelReaderSheetBuilder.java
+++ b/src/main/java/com/alibaba/excel/read/builder/ExcelReaderSheetBuilder.java
@@ -57,9 +57,12 @@ public class ExcelReaderSheetBuilder {
/**
* Count the number of added heads when read sheet.
*
- *
+ * 0 - This Sheet has no head ,since the first row are the data
+ *
+ * 1 - This Sheet has one row head , this is the default
+ *
+ * 2 - This Sheet has two row head ,since the third row is the data
*
* @param headRowNumber
* @return
@@ -149,8 +152,6 @@ public class ExcelReaderSheetBuilder {
/**
* Sax read
- *
- * @return
*/
public void doRead() {
if (excelReader == null) {
diff --git a/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java b/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java
index 58baeae9..07bc68c2 100644
--- a/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java
+++ b/src/main/java/com/alibaba/excel/read/listener/ReadListenerRegistryCenter.java
@@ -13,8 +13,9 @@ public interface ReadListenerRegistryCenter {
/**
* register
- *
+ *
* @param listener
+ * Analysis listener
*/
void register(AnalysisEventListener listener);
@@ -24,13 +25,15 @@ public interface ReadListenerRegistryCenter {
* @param event
* parse event
* @param analysisContext
+ * Analysis context
*/
void notifyEndOneRow(AnalysisFinishEvent event, AnalysisContext analysisContext);
/**
* Notify after all analysed
- *
+ *
* @param analysisContext
+ * Analysis context
*/
void notifyAfterAllAnalysed(AnalysisContext analysisContext);
}
diff --git a/src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java b/src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java
index 6141aef1..d4035873 100644
--- a/src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java
+++ b/src/main/java/com/alibaba/excel/read/metadata/ReadBasicParameter.java
@@ -15,9 +15,12 @@ public class ReadBasicParameter extends BasicParameter {
/**
* Count the number of added heads when read sheet.
*
- *
+ * 0 - This Sheet has no head ,since the first row are the data
+ *
+ * 1 - This Sheet has one row head , this is the default
+ *
+ * 2 - This Sheet has two row head ,since the third row is the data
*/
private Integer headRowNumber;
/**
diff --git a/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java b/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java
index 0113b542..360f941f 100644
--- a/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java
+++ b/src/main/java/com/alibaba/excel/read/metadata/ReadWorkbook.java
@@ -32,7 +32,8 @@ public class ReadWorkbook extends ReadBasicParameter {
private File file;
/**
* Mandatory use 'inputStream' .Default is false.
- *
+ * if false,Will transfer 'inputStream' to temporary files to improve efficiency
*/
private Boolean mandatoryUseInputStream;
/**
@@ -51,8 +52,10 @@ public class ReadWorkbook extends ReadBasicParameter {
private ReadCache readCache;
/**
* The default is all excel objects.Default is true.
- *
+ * if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a field.
+ *
+ * if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
*
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
index 27367887..61aa8137 100644
--- a/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/AbstractReadHolder.java
@@ -37,9 +37,12 @@ public abstract class AbstractReadHolder extends AbstractHolder implements ReadH
/**
* Count the number of added heads when read sheet.
*
- *
+ * 0 - This Sheet has no head ,since the first row are the data
+ *
+ * 1 - This Sheet has one row head , this is the default
+ *
+ * 2 - This Sheet has two row head ,since the third row is the data
*/
private Integer headRowNumber;
/**
diff --git a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java
index bda58225..43e13013 100644
--- a/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java
+++ b/src/main/java/com/alibaba/excel/read/metadata/holder/ReadHolder.java
@@ -16,14 +16,14 @@ public interface ReadHolder extends ConfigurationHolder {
/**
* What handler does the currently operated cell need to execute
*
- * @return
+ * @return Current {@link ReadListener}
*/
List
+ * if false,Will transfer 'inputStream' to temporary files to improve efficiency
*/
private Boolean mandatoryUseInputStream;
/**
diff --git a/src/main/java/com/alibaba/excel/util/BooleanUtils.java b/src/main/java/com/alibaba/excel/util/BooleanUtils.java
index bb588968..afd1495d 100644
--- a/src/main/java/com/alibaba/excel/util/BooleanUtils.java
+++ b/src/main/java/com/alibaba/excel/util/BooleanUtils.java
@@ -13,8 +13,6 @@ public class BooleanUtils {
/**
* String to boolean
*
- *
+ * if true , you can use {@link com.alibaba.excel.annotation.ExcelIgnore} ignore a field.
+ *
+ * if false , you must use {@link com.alibaba.excel.annotation.ExcelProperty} to use a filed.
*
* @deprecated Just to be compatible with historical data, The default is always going to be convert all filed.
*/
diff --git a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java
index 64f90894..da5e53bc 100644
--- a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java
+++ b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java
@@ -25,7 +25,8 @@ public class HorizontalCellStyleStrategy extends AbstractCellStyleStrategy {
private CellStyle headCellStyle;
private List
+ * if return null,ignore
*
* @param head
* Nullable
diff --git a/src/test/java/com/alibaba/easyexcel/test/core/exception/ExceptionDataTest.java b/src/test/java/com/alibaba/easyexcel/test/core/exception/ExceptionDataTest.java
index 0a5d0a72..93210cfd 100644
--- a/src/test/java/com/alibaba/easyexcel/test/core/exception/ExceptionDataTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/core/exception/ExceptionDataTest.java
@@ -42,8 +42,7 @@ public class ExceptionDataTest {
private void readAndWrite(File file) throws Exception {
EasyExcel.write(new FileOutputStream(file), ExceptionData.class).sheet().doWrite(data());
- EasyExcel.read(new FileInputStream(file), ExceptionData.class, new ExceptionDataListener()).sheet()
- .doRead();
+ EasyExcel.read(new FileInputStream(file), ExceptionData.class, new ExceptionDataListener()).sheet().doRead();
}
private List
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ *
+ * 3. 直接读即可
*/
@Test
public void simpleRead() {
@@ -53,9 +56,12 @@ public class ReadTest {
/**
* 指定列的下标或者列名
*
- *
+ * 1. 创建excel对应的实体对象,并使用{@link ExcelProperty}注解. 参照{@link IndexOrNameData}
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link IndexOrNameDataListener}
+ *
+ * 3. 直接读即可
*/
@Test
public void indexOrNameRead() {
@@ -66,9 +72,12 @@ public class ReadTest {
/**
* 读多个sheet,这里注意一个sheet不能读取多次,多次读取需要重新读取文件
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ *
+ * 3. 直接读即可
*/
@Test
public void repeatedRead() {
@@ -86,9 +95,12 @@ public class ReadTest {
* 日期、数字或者自定义格式转换
*
* 默认读的转换器{@link DefaultConverterLoader#loadDefaultReadConverter()}
- *
+ * 1. 创建excel对应的实体对象 参照{@link ConverterData}.里面可以使用注解{@link DateTimeFormat}、{@link NumberFormat}或者自定义注解
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link ConverterDataListener}
+ *
+ * 3. 直接读即可
*/
@Test
public void converterRead() {
@@ -105,9 +117,12 @@ public class ReadTest {
/**
* 多行头
*
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
+ *
+ * 3. 设置headRowNumber参数,然后读。 这里要注意headRowNumber如果不指定, 会根据你传入的class的{@link ExcelProperty#value()}里面的表头的数量来决定行数,
* 如果不传入class则默认为1.当然你指定了headRowNumber不管是否传入class都是以你传入的为准。
*/
@Test
diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java b/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java
index 108ba00c..d96f89bc 100644
--- a/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java
@@ -24,9 +24,12 @@ import com.alibaba.excel.EasyExcel;
public class WebTest {
/**
* 文件下载
- *
+ * 1. 创建excel对应的实体对象 参照{@link DownloadData}
+ *
+ * 2. 设置返回的 参数
+ *
+ * 3. 直接写,这里注意,finish的时候会自动关闭OutputStream,当然你外面再关闭流问题不大
*/
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
@@ -38,9 +41,12 @@ public class WebTest {
/**
* 文件上传
- *
+ * 1. 创建excel对应的实体对象 参照{@link UploadData}
+ *
+ * 2. 由于默认异步读取excel,所以需要创建excel一行一行的回调监听器,参照{@link UploadDataListener}
+ *
+ * 3. 直接读即可
*/
@PostMapping("upload")
@ResponseBody
diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java
index 9bd94677..482f8f72 100644
--- a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java
@@ -39,8 +39,10 @@ import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy
public class WriteTest {
/**
* 最简单的写
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 直接写即可
*/
@Test
public void simpleWrite() {
@@ -62,9 +64,12 @@ public class WriteTest {
/**
* 指定写入的列
- *
+ * 1. 创建excel对应的实体对象 参照{@link IndexData}
+ *
+ * 2. 使用{@link ExcelProperty}注解指定写入的列
+ *
+ * 3. 直接写即可
*/
@Test
public void indexWrite() {
@@ -75,9 +80,12 @@ public class WriteTest {
/**
* 复杂头写入
- *
+ * 1. 创建excel对应的实体对象 参照{@link ComplexHeadData}
+ *
+ * 2. 使用{@link ExcelProperty}注解指定复杂的头
+ *
+ * 3. 直接写即可
*/
@Test
public void complexHeadWrite() {
@@ -88,9 +96,12 @@ public class WriteTest {
/**
* 重复多次写入
- *
+ * 1. 创建excel对应的实体对象 参照{@link ComplexHeadData}
+ *
+ * 2. 使用{@link ExcelProperty}注解指定复杂的头
+ *
+ * 3. 直接调用二次写入即可
*/
@Test
public void repeatedWrite() {
@@ -108,9 +119,12 @@ public class WriteTest {
/**
* 日期、数字或者自定义格式转换
- *
+ * 1. 创建excel对应的实体对象 参照{@link ConverterData}
+ *
+ * 2. 使用{@link ExcelProperty}配合使用注解{@link DateTimeFormat}、{@link NumberFormat}或者自定义注解
+ *
+ * 3. 直接写即可
*/
@Test
public void converterWrite() {
@@ -121,8 +135,10 @@ public class WriteTest {
/**
* 图片导出
- *
+ * 1. 创建excel对应的实体对象 参照{@link ImageData}
+ *
+ * 2. 直接写即可
*/
@Test
public void imageWrite() throws Exception {
@@ -150,10 +166,14 @@ public class WriteTest {
/**
* 根据模板写入
- *
+ * 1. 创建excel对应的实体对象 参照{@link IndexData}
+ *
+ * 2. 使用{@link ExcelProperty}注解指定写入的列
+ *
+ * 3. 使用withTemplate 读取模板
+ *
+ * 4. 直接写即可
*/
@Test
public void templateWrite() {
@@ -165,9 +185,12 @@ public class WriteTest {
/**
* 列宽、行高
- *
+ * 1. 创建excel对应的实体对象 参照{@link WidthAndHeightData}
+ *
+ * 2. 使用注解{@link ColumnWidth}、{@link HeadRowHeight}、{@link ContentRowHeight}指定宽度或高度
+ *
+ * 3. 直接写即可
*/
@Test
public void widthAndHeightWrite() {
@@ -178,9 +201,12 @@ public class WriteTest {
/**
* 自定义样式
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 创建一个style策略 并注册
+ *
+ * 3. 直接写即可
*/
@Test
public void styleWrite() {
@@ -213,9 +239,12 @@ public class WriteTest {
/**
* 合并单元格
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 创建一个merge策略 并注册
+ *
+ * 3. 直接写即可
*/
@Test
public void mergeWrite() {
@@ -228,8 +257,10 @@ public class WriteTest {
/**
* 使用table去写入
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 然后写入table即可
*/
@Test
public void tableWrite() {
@@ -255,8 +286,10 @@ public class WriteTest {
*
* 思路是这样子的,先创建List
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 2. 然后写入table即可
*/
@Test
public void dynamicHeadWrite() {
@@ -277,9 +310,12 @@ public class WriteTest {
*
* poi 自带{@link SXSSFSheet#autoSizeColumn(int)} 对中文支持也不太好。目前没找到很好的算法。 有的话可以推荐下。
*
- *
+ * 1. 创建excel对应的实体对象 参照{@link DemoData}
+ *
+ * 3. 注册策略{@link LongestMatchColumnWidthStyleStrategy}
+ *
+ * 2. 直接写即可
*/
@Test
public void longestMatchColumnWidthWrite() {
writerSheet
*
- * @return
+ * @return Excel sheet writer builder
*/
public static ExcelWriterSheetBuilder writerSheet() {
return writerSheet(null, null);
}
/**
- * Build excel the 'writerSheet'
+ * Build excel the writerSheet
*
* @param sheetNo
- * @return
+ * Index of sheet,0 base.
+ * @return Excel sheet writer builder.
*/
public static ExcelWriterSheetBuilder writerSheet(Integer sheetNo) {
return writerSheet(sheetNo, null);
@@ -279,7 +292,8 @@ public class EasyExcelFactory {
* Build excel the 'writerSheet'
*
* @param sheetName
- * @return
+ * The name of sheet.
+ * @return Excel sheet writer builder.
*/
public static ExcelWriterSheetBuilder writerSheet(String sheetName) {
return writerSheet(null, sheetName);
@@ -289,8 +303,10 @@ public class EasyExcelFactory {
* Build excel the 'writerSheet'
*
* @param sheetNo
+ * Index of sheet,0 base.
* @param sheetName
- * @return
+ * The name of sheet.
+ * @return Excel sheet writer builder.
*/
public static ExcelWriterSheetBuilder writerSheet(Integer sheetNo, String sheetName) {
ExcelWriterSheetBuilder excelWriterSheetBuilder = new ExcelWriterSheetBuilder();
@@ -304,9 +320,9 @@ public class EasyExcelFactory {
}
/**
- * Build excel the 'writerTable'
+ * Build excel the writerTable
*
- * @return
+ * @return Excel table writer builder.
*/
public static ExcelWriterTableBuilder writerTable() {
return writerTable(null);
@@ -316,7 +332,8 @@ public class EasyExcelFactory {
* Build excel the 'writerTable'
*
* @param tableNo
- * @return
+ * Index of table,0 base.
+ * @return Excel table writer builder.
*/
public static ExcelWriterTableBuilder writerTable(Integer tableNo) {
ExcelWriterTableBuilder excelWriterTableBuilder = new ExcelWriterTableBuilder();
@@ -329,7 +346,7 @@ public class EasyExcelFactory {
/**
* Build excel the read
*
- * @return
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read() {
return new ExcelReaderBuilder();
@@ -339,7 +356,8 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param file
- * @return
+ * File to read.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(File file) {
return read(file, null, null);
@@ -349,8 +367,10 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param file
+ * File to read.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(File file, ReadListener readListener) {
return read(file, null, readListener);
@@ -360,9 +380,12 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param file
+ * File to read.
* @param head
+ * Annotate the class for configuration information.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(File file, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
@@ -380,7 +403,8 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param pathName
- * @return
+ * File path to read.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(String pathName) {
return read(pathName, null, null);
@@ -390,8 +414,10 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param pathName
+ * File path to read.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(String pathName, ReadListener readListener) {
return read(pathName, null, readListener);
@@ -401,9 +427,12 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param pathName
+ * File path to read.
* @param head
+ * Annotate the class for configuration information.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(String pathName, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
@@ -421,7 +450,8 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param inputStream
- * @return
+ * Input stream to read.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(InputStream inputStream) {
return read(inputStream, null, null);
@@ -431,8 +461,10 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param inputStream
+ * Input stream to read.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(InputStream inputStream, ReadListener readListener) {
return read(inputStream, null, readListener);
@@ -442,9 +474,12 @@ public class EasyExcelFactory {
* Build excel the read
*
* @param inputStream
+ * Input stream to read.
* @param head
+ * Annotate the class for configuration information.
* @param readListener
- * @return
+ * Read listener.
+ * @return Excel reader builder.
*/
public static ExcelReaderBuilder read(InputStream inputStream, Class head, ReadListener readListener) {
ExcelReaderBuilder excelReaderBuilder = new ExcelReaderBuilder();
@@ -461,7 +496,7 @@ public class EasyExcelFactory {
/**
* Build excel the 'readSheet'
*
- * @return
+ * @return Excel sheet reader builder.
*/
public static ExcelReaderSheetBuilder readSheet() {
return readSheet(null, null);
@@ -471,7 +506,8 @@ public class EasyExcelFactory {
* Build excel the 'readSheet'
*
* @param sheetNo
- * @return
+ * Index of sheet,0 base.
+ * @return Excel sheet reader builder.
*/
public static ExcelReaderSheetBuilder readSheet(Integer sheetNo) {
return readSheet(sheetNo, null);
@@ -481,7 +517,8 @@ public class EasyExcelFactory {
* Build excel the 'readSheet'
*
* @param sheetName
- * @return
+ * The name of sheet.
+ * @return Excel sheet reader builder.
*/
public static ExcelReaderSheetBuilder readSheet(String sheetName) {
return readSheet(null, sheetName);
@@ -491,8 +528,10 @@ public class EasyExcelFactory {
* Build excel the 'readSheet'
*
* @param sheetNo
+ * Index of sheet,0 base.
* @param sheetName
- * @return
+ * The name of sheet.
+ * @return Excel sheet reader builder.
*/
public static ExcelReaderSheetBuilder readSheet(Integer sheetNo, String sheetName) {
ExcelReaderSheetBuilder excelReaderSheetBuilder = new ExcelReaderSheetBuilder();
diff --git a/src/main/java/com/alibaba/excel/ExcelReader.java b/src/main/java/com/alibaba/excel/ExcelReader.java
index 4fcb3cab..3cb6b01e 100644
--- a/src/main/java/com/alibaba/excel/ExcelReader.java
+++ b/src/main/java/com/alibaba/excel/ExcelReader.java
@@ -276,7 +276,6 @@ public class ExcelReader {
/**
* Prevents calls to {@link #finish} from freeing the cache
*
- * @throws Throwable
*/
@Override
protected void finalize() {
diff --git a/src/main/java/com/alibaba/excel/analysis/ExcelAnalyser.java b/src/main/java/com/alibaba/excel/analysis/ExcelAnalyser.java
index f82b52fc..8d987eaf 100644
--- a/src/main/java/com/alibaba/excel/analysis/ExcelAnalyser.java
+++ b/src/main/java/com/alibaba/excel/analysis/ExcelAnalyser.java
@@ -13,6 +13,7 @@ public interface ExcelAnalyser {
* parse one sheet
*
* @param readSheet
+ * sheet to read
*/
void analysis(ReadSheet readSheet);
@@ -23,14 +24,14 @@ public interface ExcelAnalyser {
/**
* Acquisition excel executor
- *
- * @return
+ *
+ * @return Excel file Executor
*/
ExcelExecutor excelExecutor();
/**
* get the analysis context.
- *
+ *
* @return analysis context
*/
AnalysisContext analysisContext();
diff --git a/src/main/java/com/alibaba/excel/analysis/ExcelExecutor.java b/src/main/java/com/alibaba/excel/analysis/ExcelExecutor.java
index 9553afbf..8868d2ee 100644
--- a/src/main/java/com/alibaba/excel/analysis/ExcelExecutor.java
+++ b/src/main/java/com/alibaba/excel/analysis/ExcelExecutor.java
@@ -14,7 +14,7 @@ public interface ExcelExecutor {
/**
* Returns the actual sheet in excel
*
- * @return
+ * @return Actual sheet in excel
*/
ListreadSheetHolder
or readWorkbookHolder
+ *
+ * @return Current holder
*/
ReadHolder currentReadHolder();
/**
* Custom attribute
- *
+ *
* @return
*/
Object getCustom();
@@ -81,7 +84,7 @@ public interface AnalysisContext {
/**
*
* get excel type
- *
+ *
* @return excel type
* @deprecated please use {@link #readWorkbookHolder()}
*/
@@ -90,7 +93,7 @@ public interface AnalysisContext {
/**
* get in io
- *
+ *
* @return file io
* @deprecated please use {@link #readWorkbookHolder()}
*/
@@ -99,7 +102,7 @@ public interface AnalysisContext {
/**
* get current row
- *
+ *
* @return
* @deprecated please use {@link #readRowHolder()}
*/
@@ -108,7 +111,7 @@ public interface AnalysisContext {
/**
* get total row ,Data may be inaccurate
- *
+ *
* @return
* @deprecated please use {@link #readRowHolder()}
*/
@@ -126,7 +129,7 @@ public interface AnalysisContext {
/**
* Interrupt execution
- *
+ *
* @deprecated please use {@link AnalysisEventListener#hasNext(AnalysisContext)}
*/
@Deprecated
diff --git a/src/main/java/com/alibaba/excel/converters/Converter.java b/src/main/java/com/alibaba/excel/converters/Converter.java
index 22d8c3cf..8700d127 100644
--- a/src/main/java/com/alibaba/excel/converters/Converter.java
+++ b/src/main/java/com/alibaba/excel/converters/Converter.java
@@ -16,14 +16,14 @@ public interface Converter