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
This commit is contained in:
commit
9a63692bd5
43
.github/workflows/ci.yml
vendored
Normal file
43
.github/workflows/ci.yml
vendored
Normal file
@ -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
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
|
@ -1,6 +1,6 @@
|
||||
EasyExcel
|
||||
======================
|
||||
[](https://travis-ci.org/alibaba/easyexcel)
|
||||
[](https://github.com/alibaba/easyexcel/actions/workflows/ci.yml?query=branch%3Amaster)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/com.alibaba/easyexcel)
|
||||
[](http://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user