Browse Source

Merge branch 'master' into developing

# Conflicts:
#	pom.xml
#	src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
#	src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
#	update.md
developing
Jiaju Zhuang 3 years ago
parent
commit
9a63692bd5
  1. 43
      .github/workflows/ci.yml
  2. 10
      .travis.yml
  3. 2
      README.md
  4. 53
      src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
  5. 20
      src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  6. 3
      update.md

43
.github/workflows/ci.yml

@ -0,0 +1,43 @@
#
# Copyright 2009-2021 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Java CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Cache Maven
uses: actions/cache@v2.1.6
with:
path: ~/.m2
key: m2
restore-keys: m2
- name: Chmod
run: chmod +x mvnw
- name: Maven Build
run: ./mvnw install -B -V -Dmaven.test.skip=true
- name: Java Doc
run: ./mvnw javadoc:javadoc

10
.travis.yml

@ -1,10 +0,0 @@
language: java
jdk: openjdk8
cache:
directories:
- $HOME/.m2
before_install:
- chmod +x mvnw
install:
- ./mvnw install -B -V -Dmaven.test.skip=true
- ./mvnw javadoc:javadoc

2
README.md

@ -1,6 +1,6 @@
EasyExcel
======================
[![Build Status](https://travis-ci.org/alibaba/easyexcel.svg?branch=master)](https://travis-ci.org/alibaba/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)

53
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java

@ -17,6 +17,9 @@ import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.xml.sax.Attributes;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.xml.sax.Attributes;
/**
* Cell Handler
*
@ -111,6 +114,56 @@ public class CellTagHandler extends AbstractXlsxTagHandler {
tempCellData.setStringValue(tempCellData.getStringValue().trim());
}
@Override
public void endElement(XlsxReadContext xlsxReadContext, String name) {
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder();
CellData tempCellData = xlsxReadSheetHolder.getTempCellData();
StringBuilder tempData = xlsxReadSheetHolder.getTempData();
String tempDataString = tempData.toString();
CellDataTypeEnum oldType = tempCellData.getType();
switch (oldType) {
case STRING:
// In some cases, although cell type is a string, it may be an empty tag
if (StringUtils.isEmpty(tempDataString)) {
break;
}
String stringValue = xlsxReadContext.readWorkbookHolder().getReadCache().get(
Integer.valueOf(tempDataString));
tempCellData.setStringValue(stringValue);
break;
case DIRECT_STRING:
case ERROR:
tempCellData.setStringValue(tempDataString);
tempCellData.setType(CellDataTypeEnum.STRING);
break;
case BOOLEAN:
if (StringUtils.isEmpty(tempDataString)) {
tempCellData.setType(CellDataTypeEnum.EMPTY);
break;
}
tempCellData.setBooleanValue(BooleanUtils.valueOf(tempData.toString()));
break;
case NUMBER:
case EMPTY:
if (StringUtils.isEmpty(tempDataString)) {
tempCellData.setType(CellDataTypeEnum.EMPTY);
break;
}
tempCellData.setType(CellDataTypeEnum.NUMBER);
tempCellData.setNumberValue(BigDecimal.valueOf(Double.parseDouble(tempDataString)));
break;
default:
throw new IllegalStateException("Cannot set values now");
}
if (tempCellData.getStringValue() != null
&& xlsxReadContext.currentReadHolder().globalConfiguration().getAutoTrim()) {
tempCellData.setStringValue(tempCellData.getStringValue());
}
tempCellData.checkEmpty();
xlsxReadSheetHolder.getCellMap().put(xlsxReadSheetHolder.getColumnIndex(), tempCellData);
}
tempCellData.checkEmpty();
xlsxReadSheetHolder.getCellMap().put(xlsxReadSheetHolder.getColumnIndex(), tempCellData);
}

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

@ -22,6 +22,22 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.easyexcel.test.demo.write.DemoData;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.fastjson.JSON;
import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 临时测试
*
@ -34,7 +50,9 @@ public class Lock2Test {
@Test
public void test() throws Exception {
File file = TestFileUtil.readUserHomeFile("test/test4.xlsx");
// File file = TestFileUtil.readUserHomeFile("test/test4.xlsx");
// File file = TestFileUtil.readUserHomeFile("test/test6.xls");
File file = new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/src/test/resources/converter/converter07.xlsx");
List<Object> list = EasyExcel.read("/Users/zhuangjiaju/Downloads/olay (1).xlsx").sheet(0).doReadSync();
LOGGER.info("数据:{}", list.size());

3
update.md

@ -29,6 +29,9 @@
* 修复忽略字段后可能排序不一致的问题
# 2.2.11
* 修复有些xlsx解析失败的bug [Issue #1595](https://github.com/alibaba/easyexcel/issues/1595)
# 2.2.10
* 修复读取的时候用string接收数字 可能四舍五入不一致的bug

Loading…
Cancel
Save