Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Laubin729
easyexcel
提交
b9c0187c
E
easyexcel
项目概览
Laubin729
/
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,发现更多精彩内容 >>
提交
b9c0187c
编写于
9月 25, 2019
作者:
庄家钜
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into 2.1.0-beta1
# Conflicts: # pom.xml # update.md
上级
14696aa6
f69ebda8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
54 deletion
+64
-54
quickstart.md
quickstart.md
+2
-0
src/main/java/com/alibaba/excel/analysis/v07/SharedStringsTableHandler.java
...alibaba/excel/analysis/v07/SharedStringsTableHandler.java
+1
-1
src/main/java/com/alibaba/excel/analysis/v07/XlsxRowHandler.java
...n/java/com/alibaba/excel/analysis/v07/XlsxRowHandler.java
+1
-1
src/main/java/com/alibaba/excel/analysis/v07/XlsxRowResultHolder.java
...a/com/alibaba/excel/analysis/v07/XlsxRowResultHolder.java
+4
-2
src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
...ibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
+53
-50
update.md
update.md
+3
-0
未找到文件。
quickstart.md
浏览文件 @
b9c0187c
# easyexcel核心功能
## 各位读取文件务必使用2.0.3起
2.
0.0-beta1到2.0.2有小概率会丢失数字。
## 目录
### 前言
#### 以下功能目前不支持
...
...
src/main/java/com/alibaba/excel/analysis/v07/SharedStringsTableHandler.java
浏览文件 @
b9c0187c
...
...
@@ -82,6 +82,6 @@ public class SharedStringsTableHandler extends DefaultHandler {
if
(
currentElementData
==
null
)
{
currentElementData
=
new
StringBuilder
();
}
currentElementData
.
append
(
new
String
(
ch
,
start
,
length
)
);
currentElementData
.
append
(
ch
,
start
,
length
);
}
}
src/main/java/com/alibaba/excel/analysis/v07/XlsxRowHandler.java
浏览文件 @
b9c0187c
...
...
@@ -49,7 +49,7 @@ public class XlsxRowHandler extends DefaultHandler {
@Override
public
void
characters
(
char
[]
ch
,
int
start
,
int
length
)
throws
SAXException
{
if
(
rowResultHolder
!=
null
)
{
rowResultHolder
.
appendCurrentCellValue
(
new
String
(
ch
,
start
,
length
)
);
rowResultHolder
.
appendCurrentCellValue
(
ch
,
start
,
length
);
}
}
}
src/main/java/com/alibaba/excel/analysis/v07/XlsxRowResultHolder.java
浏览文件 @
b9c0187c
...
...
@@ -18,9 +18,11 @@ public interface XlsxRowResultHolder {
/**
* Append current 'cellValue'
*
* @param currentCellValue
* @param ch
* @param start
* @param length
*/
void
appendCurrentCellValue
(
String
currentCellValue
);
void
appendCurrentCellValue
(
char
[]
ch
,
int
start
,
int
length
);
/**
* Get row content
...
...
src/main/java/com/alibaba/excel/analysis/v07/handlers/DefaultCellHandler.java
浏览文件 @
b9c0187c
...
...
@@ -40,6 +40,9 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder
private
int
curCol
;
private
Map
<
Integer
,
CellData
>
curRowContent
=
new
TreeMap
<
Integer
,
CellData
>();
private
CellData
currentCellData
;
private
StringBuilder
dataStringBuilder
;
private
StringBuilder
formulaStringBuilder
;
/**
* Current style information
*/
...
...
@@ -77,6 +80,7 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder
// t is null ,it's means Empty or Number
CellDataTypeEnum
type
=
CellDataTypeEnum
.
buildFromCellType
(
attributes
.
getValue
(
CELL_VALUE_TYPE_TAG
));
currentCellData
=
new
CellData
(
type
);
dataStringBuilder
=
new
StringBuilder
();
// Put in data transformation information
String
dateFormatIndex
=
attributes
.
getValue
(
CELL_DATA_FORMAT_TAG
);
...
...
@@ -96,82 +100,81 @@ public class DefaultCellHandler implements XlsxCellHandler, XlsxRowResultHolder
// cell is formula
if
(
CELL_FORMULA_TAG
.
equals
(
name
))
{
currentCellData
.
setFormula
(
Boolean
.
TRUE
);
formulaStringBuilder
=
new
StringBuilder
();
}
}
@Override
public
void
endHandle
(
String
name
)
{
currentTagDeque
.
pop
();
if
(
CELL_VALUE_TAG
.
equals
(
name
))
{
// Have to go "sharedStrings.xml" and get it
if
(
currentCellData
.
getType
()
==
CellDataTypeEnum
.
STRING
)
{
String
stringValue
=
analysisContext
.
readWorkbookHolder
().
getReadCache
()
.
get
(
Integer
.
valueOf
(
currentCellData
.
getStringValue
()));
// cell is formula
if
(
CELL_FORMULA_TAG
.
equals
(
name
))
{
currentCellData
.
setFormulaValue
(
formulaStringBuilder
.
toString
());
return
;
}
if
(
CELL_VALUE_TAG
.
equals
(
name
)
||
CELL_INLINE_STRING_VALUE_TAG
.
equals
(
name
))
{
CellDataTypeEnum
oldType
=
currentCellData
.
getType
();
switch
(
oldType
)
{
case
DIRECT_STRING:
case
STRING:
case
ERROR:
currentCellData
.
setStringValue
(
dataStringBuilder
.
toString
());
break
;
case
BOOLEAN:
currentCellData
.
setBooleanValue
(
BooleanUtils
.
valueOf
(
dataStringBuilder
.
toString
()));
break
;
case
NUMBER:
case
EMPTY:
currentCellData
.
setType
(
CellDataTypeEnum
.
NUMBER
);
currentCellData
.
setNumberValue
(
new
BigDecimal
(
dataStringBuilder
.
toString
()));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set values now"
);
}
if
(
CELL_VALUE_TAG
.
equals
(
name
))
{
// Have to go "sharedStrings.xml" and get it
if
(
currentCellData
.
getType
()
==
CellDataTypeEnum
.
STRING
)
{
String
stringValue
=
analysisContext
.
readWorkbookHolder
().
getReadCache
()
.
get
(
Integer
.
valueOf
(
currentCellData
.
getStringValue
()));
if
(
stringValue
!=
null
&&
analysisContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
stringValue
=
stringValue
.
trim
();
}
currentCellData
.
setStringValue
(
stringValue
);
}
else
if
(
currentCellData
.
getType
()
==
CellDataTypeEnum
.
DIRECT_STRING
)
{
currentCellData
.
setType
(
CellDataTypeEnum
.
STRING
);
}
}
// This is a special form of string
if
(
CELL_INLINE_STRING_VALUE_TAG
.
equals
(
name
))
{
XSSFRichTextString
richTextString
=
new
XSSFRichTextString
(
currentCellData
.
getStringValue
());
String
stringValue
=
richTextString
.
toString
();
if
(
stringValue
!=
null
&&
analysisContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
stringValue
=
stringValue
.
trim
();
}
currentCellData
.
setStringValue
(
stringValue
);
}
else
if
(
currentCellData
.
getType
()
==
CellDataTypeEnum
.
DIRECT_STRING
)
{
currentCellData
.
setType
(
CellDataTypeEnum
.
STRING
);
}
currentCellData
.
checkEmpty
();
curRowContent
.
put
(
curCol
,
currentCellData
);
}
// This is a special form of string
if
(
CELL_INLINE_STRING_VALUE_TAG
.
equals
(
name
))
{
XSSFRichTextString
richTextString
=
new
XSSFRichTextString
(
currentCellData
.
getStringValue
());
String
stringValue
=
richTextString
.
toString
();
if
(
stringValue
!=
null
&&
analysisContext
.
currentReadHolder
().
globalConfiguration
().
getAutoTrim
())
{
stringValue
=
stringValue
.
trim
();
}
currentCellData
.
setStringValue
(
stringValue
);
currentCellData
.
checkEmpty
();
curRowContent
.
put
(
curCol
,
currentCellData
);
}
currentTagDeque
.
pop
();
}
@Override
public
void
appendCurrentCellValue
(
String
currentCellValue
)
{
if
(
StringUtils
.
isEmpty
(
currentCellValue
))
{
return
;
}
public
void
appendCurrentCellValue
(
char
[]
ch
,
int
start
,
int
length
)
{
String
currentTag
=
currentTagDeque
.
peek
();
if
(
currentTag
==
null
)
{
return
;
}
if
(
CELL_FORMULA_TAG
.
equals
(
currentTag
))
{
currentCellData
.
setFormulaValue
(
currentCellValue
);
formulaStringBuilder
.
append
(
ch
,
start
,
length
);
return
;
}
if
(!
CELL_VALUE_TAG
.
equals
(
currentTag
)
&&
!
CELL_INLINE_STRING_VALUE_TAG
.
equals
(
currentTag
))
{
return
;
}
CellDataTypeEnum
oldType
=
currentCellData
.
getType
();
switch
(
oldType
)
{
case
DIRECT_STRING:
case
STRING:
case
ERROR:
if
(
currentCellData
.
getStringValue
()
==
null
)
{
currentCellData
.
setStringValue
(
currentCellValue
);
}
else
{
currentCellData
.
setStringValue
(
currentCellData
.
getStringValue
()
+
currentCellValue
);
}
break
;
case
BOOLEAN:
if
(
currentCellData
.
getBooleanValue
()
==
null
)
{
currentCellData
.
setBooleanValue
(
BooleanUtils
.
valueOf
(
currentCellValue
));
}
break
;
case
NUMBER:
case
EMPTY:
currentCellData
.
setType
(
CellDataTypeEnum
.
NUMBER
);
if
(
currentCellData
.
getNumberValue
()
==
null
)
{
currentCellData
.
setNumberValue
(
new
BigDecimal
(
currentCellValue
));
}
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set values now"
);
}
dataStringBuilder
.
append
(
ch
,
start
,
length
);
}
@Override
...
...
update.md
浏览文件 @
b9c0187c
...
...
@@ -4,6 +4,9 @@
*
新增支持读取单元格类型、写入指定单元格类型
*
支持通过模板填充数据
# 2.0.3
*
修复重大bug 在07版读取文件的时候 小概率导致数字部分丢失
# 2.0.2
*
修复xls无法获取sheetList的bug
[
Issue #621
](
https://github.com/alibaba/easyexcel/issues/621
)
*
修复监听器转换异常会重复提示的bug
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录