Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_879456671
easyexcel
提交
939f712c
E
easyexcel
项目概览
qq_879456671
/
easyexcel
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
easyexcel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
939f712c
编写于
9月 17, 2021
作者:
庄家钜
提交者:
GitHub
9月 17, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2072 from alibaba/bugfix
Bugfix
上级
d99651a6
a131a4e4
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
70 addition
and
125 deletion
+70
-125
.travis.yml
.travis.yml
+0
-10
README.md
README.md
+1
-1
pom.xml
pom.xml
+1
-1
src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java
...el/analysis/v07/handlers/AbstractCellValueTagHandler.java
+0
-59
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellInlineStringValueTagHandler.java
...nalysis/v07/handlers/CellInlineStringValueTagHandler.java
+0
-13
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
...m/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
+55
-2
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java
...baba/excel/analysis/v07/handlers/CellValueTagHandler.java
+0
-29
src/main/java/com/alibaba/excel/enums/CellDataTypeEnum.java
src/main/java/com/alibaba/excel/enums/CellDataTypeEnum.java
+1
-1
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
+9
-9
update.md
update.md
+3
-0
未找到文件。
.travis.yml
已删除
100644 → 0
浏览文件 @
d99651a6
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
\ No newline at end of file
README.md
浏览文件 @
939f712c
EasyExcel
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)
[
![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)
[
![License
](
http://img.shields.io/:license-apache-brightgreen.svg
)
](http://www.apache.org/licenses/LICENSE-2.0.html)
...
...
pom.xml
浏览文件 @
939f712c
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.alibaba
</groupId>
<groupId>
com.alibaba
</groupId>
<artifactId>
easyexcel
</artifactId>
<artifactId>
easyexcel
</artifactId>
<version>
2.2.1
0
</version>
<version>
2.2.1
1
</version>
<packaging>
jar
</packaging>
<packaging>
jar
</packaging>
<name>
easyexcel
</name>
<name>
easyexcel
</name>
...
...
src/main/java/com/alibaba/excel/analysis/v07/handlers/AbstractCellValueTagHandler.java
浏览文件 @
939f712c
package
com.alibaba.excel.analysis.v07.handlers
;
package
com.alibaba.excel.analysis.v07.handlers
;
import
java.math.BigDecimal
;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder
;
import
com.alibaba.excel.util.BooleanUtils
;
import
com.alibaba.excel.util.StringUtils
;
/**
/**
* Cell Value Handler
* Cell Value Handler
...
@@ -16,61 +9,9 @@ import com.alibaba.excel.util.StringUtils;
...
@@ -16,61 +9,9 @@ import com.alibaba.excel.util.StringUtils;
*/
*/
public
abstract
class
AbstractCellValueTagHandler
extends
AbstractXlsxTagHandler
{
public
abstract
class
AbstractCellValueTagHandler
extends
AbstractXlsxTagHandler
{
@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
DIRECT_STRING:
case
STRING:
case
ERROR:
tempCellData
.
setStringValue
(
tempData
.
toString
());
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"
);
}
// set string value
setStringValue
(
xlsxReadContext
);
if
(
tempCellData
.
getStringValue
()
!=
null
&&
xlsxReadContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
tempCellData
.
setStringValue
(
tempCellData
.
getStringValue
());
}
tempCellData
.
checkEmpty
();
xlsxReadSheetHolder
.
getCellMap
().
put
(
xlsxReadSheetHolder
.
getColumnIndex
(),
tempCellData
);
}
@Override
@Override
public
void
characters
(
XlsxReadContext
xlsxReadContext
,
char
[]
ch
,
int
start
,
int
length
)
{
public
void
characters
(
XlsxReadContext
xlsxReadContext
,
char
[]
ch
,
int
start
,
int
length
)
{
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempData
().
append
(
ch
,
start
,
length
);
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempData
().
append
(
ch
,
start
,
length
);
}
}
/**
* Set string value.
*
* @param xlsxReadContext
*/
protected
abstract
void
setStringValue
(
XlsxReadContext
xlsxReadContext
);
}
}
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellInlineStringValueTagHandler.java
浏览文件 @
939f712c
package
com.alibaba.excel.analysis.v07.handlers
;
package
com.alibaba.excel.analysis.v07.handlers
;
import
org.apache.poi.xssf.usermodel.XSSFRichTextString
;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.metadata.CellData
;
/**
/**
* Cell inline string value handler
* Cell inline string value handler
*
*
...
@@ -12,12 +7,4 @@ import com.alibaba.excel.metadata.CellData;
...
@@ -12,12 +7,4 @@ import com.alibaba.excel.metadata.CellData;
*/
*/
public
class
CellInlineStringValueTagHandler
extends
AbstractCellValueTagHandler
{
public
class
CellInlineStringValueTagHandler
extends
AbstractCellValueTagHandler
{
@Override
protected
void
setStringValue
(
XlsxReadContext
xlsxReadContext
)
{
// This is a special form of string
CellData
tempCellData
=
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempCellData
();
XSSFRichTextString
richTextString
=
new
XSSFRichTextString
(
tempCellData
.
getStringValue
());
tempCellData
.
setStringValue
(
richTextString
.
toString
());
}
}
}
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellTagHandler.java
浏览文件 @
939f712c
package
com.alibaba.excel.analysis.v07.handlers
;
package
com.alibaba.excel.analysis.v07.handlers
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
java.math.BigDecimal
;
import
org.xml.sax.Attributes
;
import
com.alibaba.excel.constant.BuiltinFormats
;
import
com.alibaba.excel.constant.BuiltinFormats
;
import
com.alibaba.excel.constant.ExcelXmlConstants
;
import
com.alibaba.excel.constant.ExcelXmlConstants
;
...
@@ -9,9 +8,13 @@ import com.alibaba.excel.context.xlsx.XlsxReadContext;
...
@@ -9,9 +8,13 @@ import com.alibaba.excel.context.xlsx.XlsxReadContext;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder
;
import
com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder
;
import
com.alibaba.excel.util.BooleanUtils
;
import
com.alibaba.excel.util.PositionUtils
;
import
com.alibaba.excel.util.PositionUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
com.alibaba.excel.util.StringUtils
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
import
org.xml.sax.Attributes
;
/**
/**
* Cell Handler
* Cell Handler
*
*
...
@@ -54,4 +57,54 @@ public class CellTagHandler extends AbstractXlsxTagHandler {
...
@@ -54,4 +57,54 @@ public class CellTagHandler extends AbstractXlsxTagHandler {
xssfCellStyle
.
getDataFormatString
(),
xlsxReadSheetHolder
.
getGlobalConfiguration
().
getLocale
()));
xssfCellStyle
.
getDataFormatString
(),
xlsxReadSheetHolder
.
getGlobalConfiguration
().
getLocale
()));
}
}
@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
);
}
}
}
src/main/java/com/alibaba/excel/analysis/v07/handlers/CellValueTagHandler.java
浏览文件 @
939f712c
package
com.alibaba.excel.analysis.v07.handlers
;
package
com.alibaba.excel.analysis.v07.handlers
;
import
com.alibaba.excel.context.xlsx.XlsxReadContext
;
import
com.alibaba.excel.enums.CellDataTypeEnum
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.util.StringUtils
;
/**
/**
* Cell Value Handler
* Cell Value Handler
*
*
...
@@ -12,28 +7,4 @@ import com.alibaba.excel.util.StringUtils;
...
@@ -12,28 +7,4 @@ import com.alibaba.excel.util.StringUtils;
*/
*/
public
class
CellValueTagHandler
extends
AbstractCellValueTagHandler
{
public
class
CellValueTagHandler
extends
AbstractCellValueTagHandler
{
@Override
protected
void
setStringValue
(
XlsxReadContext
xlsxReadContext
)
{
// Have to go "sharedStrings.xml" and get it
CellData
tempCellData
=
xlsxReadContext
.
xlsxReadSheetHolder
().
getTempCellData
();
switch
(
tempCellData
.
getType
())
{
case
STRING:
// In some cases, although cell type is a string, it may be an empty tag
if
(
StringUtils
.
isEmpty
(
tempCellData
.
getStringValue
())){
break
;
}
String
stringValue
=
xlsxReadContext
.
readWorkbookHolder
().
getReadCache
()
.
get
(
Integer
.
valueOf
(
tempCellData
.
getStringValue
()));
if
(
stringValue
!=
null
&&
xlsxReadContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
stringValue
=
stringValue
.
trim
();
}
tempCellData
.
setStringValue
(
stringValue
);
break
;
case
DIRECT_STRING:
tempCellData
.
setType
(
CellDataTypeEnum
.
STRING
);
break
;
default
:
}
}
}
}
src/main/java/com/alibaba/excel/enums/CellDataTypeEnum.java
浏览文件 @
939f712c
...
@@ -45,7 +45,7 @@ public enum CellDataTypeEnum {
...
@@ -45,7 +45,7 @@ public enum CellDataTypeEnum {
static
{
static
{
TYPE_ROUTING_MAP
.
put
(
"s"
,
STRING
);
TYPE_ROUTING_MAP
.
put
(
"s"
,
STRING
);
TYPE_ROUTING_MAP
.
put
(
"str"
,
DIRECT_STRING
);
TYPE_ROUTING_MAP
.
put
(
"str"
,
DIRECT_STRING
);
TYPE_ROUTING_MAP
.
put
(
"inlineStr"
,
STRING
);
TYPE_ROUTING_MAP
.
put
(
"inlineStr"
,
DIRECT_
STRING
);
TYPE_ROUTING_MAP
.
put
(
"e"
,
ERROR
);
TYPE_ROUTING_MAP
.
put
(
"e"
,
ERROR
);
TYPE_ROUTING_MAP
.
put
(
"b"
,
BOOLEAN
);
TYPE_ROUTING_MAP
.
put
(
"b"
,
BOOLEAN
);
TYPE_ROUTING_MAP
.
put
(
"n"
,
NUMBER
);
TYPE_ROUTING_MAP
.
put
(
"n"
,
NUMBER
);
...
...
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
浏览文件 @
939f712c
...
@@ -5,14 +5,6 @@ import java.util.ArrayList;
...
@@ -5,14 +5,6 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
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
;
import
com.alibaba.easyexcel.test.demo.write.DemoData
;
import
com.alibaba.easyexcel.test.demo.write.DemoData
;
import
com.alibaba.easyexcel.test.util.TestFileUtil
;
import
com.alibaba.easyexcel.test.util.TestFileUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcel
;
...
@@ -21,6 +13,14 @@ import com.alibaba.excel.write.metadata.style.WriteFont;
...
@@ -21,6 +13,14 @@ import com.alibaba.excel.write.metadata.style.WriteFont;
import
com.alibaba.excel.write.style.HorizontalCellStyleStrategy
;
import
com.alibaba.excel.write.style.HorizontalCellStyleStrategy
;
import
com.alibaba.fastjson.JSON
;
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 +34,7 @@ public class Lock2Test {
...
@@ -34,7 +34,7 @@ public class Lock2Test {
@Test
@Test
public
void
test
()
throws
Exception
{
public
void
test
()
throws
Exception
{
// File file = TestFileUtil.readUserHomeFile("test/test6.xls");
// File file = TestFileUtil.readUserHomeFile("test/test6.xls");
File
file
=
new
File
(
"/Users/zhuangjiaju/
test/签到金模板-0507-v5
.xlsx"
);
File
file
=
new
File
(
"/Users/zhuangjiaju/
IdeaProjects/easyexcel/src/test/resources/converter/converter07
.xlsx"
);
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
sheet
(
0
).
headRowNumber
(
0
).
doReadSync
();
List
<
Object
>
list
=
EasyExcel
.
read
(
file
).
sheet
(
0
).
headRowNumber
(
0
).
doReadSync
();
LOGGER
.
info
(
"数据:{}"
,
list
.
size
());
LOGGER
.
info
(
"数据:{}"
,
list
.
size
());
...
...
update.md
浏览文件 @
939f712c
# 2.2.11
*
修复有些xlsx解析失败的bug
[
Issue #1595
](
https://github.com/alibaba/easyexcel/issues/1595
)
# 2.2.10
# 2.2.10
*
修复读取的时候用string接收数字 可能四舍五入不一致的bug
*
修复读取的时候用string接收数字 可能四舍五入不一致的bug
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录