Browse Source

修复xls仅公式行 不读取的bug #1324

developing
Jiaju Zhuang 5 years ago
parent
commit
58fdceb2c0
  1. 2
      src/main/java/com/alibaba/excel/analysis/v03/handlers/FormulaRecordHandler.java
  2. 4
      src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  3. 2
      update.md

2
src/main/java/com/alibaba/excel/analysis/v03/handlers/FormulaRecordHandler.java

@ -14,6 +14,7 @@ import com.alibaba.excel.analysis.v03.IgnorableXlsRecordHandler;
import com.alibaba.excel.constant.BuiltinFormats; import com.alibaba.excel.constant.BuiltinFormats;
import com.alibaba.excel.context.xls.XlsReadContext; import com.alibaba.excel.context.xls.XlsReadContext;
import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.enums.RowTypeEnum;
import com.alibaba.excel.metadata.Cell; import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.CellData; import com.alibaba.excel.metadata.CellData;
@ -43,6 +44,7 @@ public class FormulaRecordHandler extends AbstractXlsRecordHandler implements Ig
} }
tempCellData.setFormula(Boolean.TRUE); tempCellData.setFormula(Boolean.TRUE);
tempCellData.setFormulaValue(formulaValue); tempCellData.setFormulaValue(formulaValue);
xlsReadContext.xlsReadSheetHolder().setTempRowType(RowTypeEnum.DATA);
switch (cellType) { switch (cellType) {
case STRING: case STRING:
// Formula result is a string // Formula result is a string

4
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java

@ -32,9 +32,9 @@ public class Lock2Test {
@Test @Test
public void test() throws Exception { public void test() throws Exception {
File file = TestFileUtil.readUserHomeFile("test/test.xlsx"); File file = TestFileUtil.readUserHomeFile("test/test4.xlsx");
List<Object> list = EasyExcel.read(file).ignoreEmptyRow(true).sheet().headRowNumber(0).doReadSync(); List<Object> list = EasyExcel.read(file).sheet().headRowNumber(0).doReadSync();
LOGGER.info("数据:{}", list.size()); LOGGER.info("数据:{}", list.size());
for (Object data : list) { for (Object data : list) {
LOGGER.info("返回数据:{}", JSON.toJSONString(data)); LOGGER.info("返回数据:{}", JSON.toJSONString(data));

2
update.md

@ -5,7 +5,7 @@
* 写入`sheet`不设置`index`和`name`默认不为0的问题 * 写入`sheet`不设置`index`和`name`默认不为0的问题
* 修复多个`sheet`不按照顺序写入 会乱序的bug [Issue #1332](https://github.com/alibaba/easyexcel/issues/1332) * 修复多个`sheet`不按照顺序写入 会乱序的bug [Issue #1332](https://github.com/alibaba/easyexcel/issues/1332)
* 修改head是List时,内容单元格的样式不生效 [Issue #1339](https://github.com/alibaba/easyexcel/issues/1339) * 修改head是List时,内容单元格的样式不生效 [Issue #1339](https://github.com/alibaba/easyexcel/issues/1339)
* 新增写入`class`和`list`同时传入 `field`数量不一致报错 [Issue #1333](https://github.com/alibaba/easyexcel/issues/1333) * 修复xls仅公式行 不读取的bug [Issue #1324](https://github.com/alibaba/easyexcel/issues/1324)
# 2.2.3 # 2.2.3

Loading…
Cancel
Save