diff --git a/pom.xml b/pom.xml
index 3e76a55c..52bfae04 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.alibaba
easyexcel
- 2.0.3
+ 2.0.4
jar
easyexcel
diff --git a/quickstart.md b/quickstart.md
index cc968c99..ecee7607 100644
--- a/quickstart.md
+++ b/quickstart.md
@@ -7,9 +7,11 @@
* 单个文件的并发写入、读取
* 读取图片
* 宏
+ClassNotFoundException与java.lang.NoClassDefFoundError的区别
* csv读取(这个后续可能会考虑)
#### 常见问题
* 关于@Data,读写的对象都用到了[Lombok](https://www.projectlombok.org/),他会自动生成`get`,`set` ,如果不需要的话,自己创建对象并生成`get`,`set` 。
+* 出现`NoSuchMethodException`,`ClassNotFoundException`,`NoClassDefFoundError`极大概率是jar冲突,建议`clean`项目,或者统一`poi` 的版本,理论上来说`easyexcel`兼容poi的`3.17`,`4.0.1`,`4.1.0`所有较新版本
* 如果在读的时候`Listener`里面需要使用spring的`@Autowired`,给`Listener`创建成员变量,然后在构造方法里面传进去。而别必须不让spring管理`Listener`,每次读取都要`new`一个。
* 如果用`String`去接收数字,出现小数点等情况,这个是BUG,但是很难修复,后续版本会修复这个问题。目前请使用`@NumberFormat`直接,里面的参数就是调用了java自带的`NumberFormat.format`方法,不知道怎么入参的可以自己网上查询。
#### 详细参数介绍
diff --git a/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java b/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
index f16f9267..2a8b36ec 100644
--- a/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
+++ b/src/main/java/com/alibaba/excel/analysis/v07/XlsxSaxAnalyser.java
@@ -33,6 +33,7 @@ import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.read.metadata.holder.ReadWorkbookHolder;
+import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.excel.util.FileUtils;
/**
@@ -60,14 +61,18 @@ public class XlsxSaxAnalyser implements ExcelExecutor {
OPCPackage pkg = readOpcPackage(readWorkbookHolder, decryptedStream);
readWorkbookHolder.setOpcPackage(pkg);
- PackagePart sharedStringsTablePackagePart =
- pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType()).get(0);
- // Specify default cache
- defaultReadCache(readWorkbookHolder, sharedStringsTablePackagePart);
+ ArrayList packageParts = pkg.getPartsByContentType(XSSFRelation.SHARED_STRINGS.getContentType());
- // Analysis sharedStringsTable.xml
- analysisSharedStringsTable(sharedStringsTablePackagePart.getInputStream(), readWorkbookHolder);
+ if (!CollectionUtils.isEmpty(packageParts)) {
+ PackagePart sharedStringsTablePackagePart = packageParts.get(0);
+
+ // Specify default cache
+ defaultReadCache(readWorkbookHolder, sharedStringsTablePackagePart);
+
+ // Analysis sharedStringsTable.xml
+ analysisSharedStringsTable(sharedStringsTablePackagePart.getInputStream(), readWorkbookHolder);
+ }
XSSFReader xssfReader = new XSSFReader(pkg);
analysisUse1904WindowDate(xssfReader, readWorkbookHolder);
diff --git a/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java b/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
index c21d6cc3..0d44a95b 100644
--- a/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
+++ b/src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
@@ -27,7 +27,6 @@ import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.util.BooleanUtils;
import com.alibaba.excel.util.PositionUtils;
-import com.alibaba.excel.util.StringUtils;
/**
* Cell Handler
@@ -106,6 +105,7 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder
@Override
public void endHandle(String name) {
+ currentTagDeque.pop();
// cell is formula
if (CELL_FORMULA_TAG.equals(name)) {
currentCellData.setFormulaValue(formulaStringBuilder.toString());
@@ -158,7 +158,6 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder
currentCellData.checkEmpty();
curRowContent.put(curCol, currentCellData);
}
- currentTagDeque.pop();
}
@Override
diff --git a/src/main/java/com/alibaba/excel/util/NumberUtils.java b/src/main/java/com/alibaba/excel/util/NumberUtils.java
index 791687d4..e687fbfc 100644
--- a/src/main/java/com/alibaba/excel/util/NumberUtils.java
+++ b/src/main/java/com/alibaba/excel/util/NumberUtils.java
@@ -26,7 +26,11 @@ public class NumberUtils {
public static String format(Number num, ExcelContentProperty contentProperty) {
if (contentProperty == null || contentProperty.getNumberFormatProperty() == null
|| StringUtils.isEmpty(contentProperty.getNumberFormatProperty().getFormat())) {
- return num.toString();
+ if (num instanceof BigDecimal) {
+ return ((BigDecimal)num).toPlainString();
+ } else {
+ return num.toString();
+ }
}
String format = contentProperty.getNumberFormatProperty().getFormat();
RoundingMode roundingMode = contentProperty.getNumberFormatProperty().getRoundingMode();
diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java
index 1f1db7be..eed6f92e 100644
--- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgTest.java
@@ -24,7 +24,7 @@ public class HgTest {
@Test
public void hh() throws IOException {
List