Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_879456671
easyexcel
提交
fd000d51
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,发现更多精彩内容 >>
提交
fd000d51
编写于
9月 10, 2021
作者:
庄家钜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完成csv测试
上级
d475f98b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
66 addition
and
40 deletion
+66
-40
src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java
src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java
+27
-0
src/main/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java
...ain/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java
+14
-3
src/main/java/com/alibaba/excel/metadata/csv/CsvRow.java
src/main/java/com/alibaba/excel/metadata/csv/CsvRow.java
+2
-0
src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
+0
-22
src/main/java/com/alibaba/excel/metadata/data/DataFormatData.java
.../java/com/alibaba/excel/metadata/data/DataFormatData.java
+4
-0
src/main/java/com/alibaba/excel/util/WorkBookUtil.java
src/main/java/com/alibaba/excel/util/WorkBookUtil.java
+3
-11
src/main/java/com/alibaba/excel/write/metadata/WriteWorkbook.java
.../java/com/alibaba/excel/write/metadata/WriteWorkbook.java
+5
-0
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
...baba/excel/write/metadata/holder/WriteWorkbookHolder.java
+11
-4
未找到文件。
src/main/java/com/alibaba/excel/metadata/csv/CsvCell.java
浏览文件 @
fd000d51
...
...
@@ -8,6 +8,10 @@ import java.util.Date;
import
com.alibaba.excel.metadata.data.FormulaData
;
import
lombok.AccessLevel
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.apache.poi.ss.SpreadsheetVersion
;
import
org.apache.poi.ss.usermodel.CellBase
;
import
org.apache.poi.ss.usermodel.CellStyle
;
...
...
@@ -24,16 +28,21 @@ import org.apache.poi.ss.util.CellRangeAddress;
*
* @author Jiaju Zhuang
*/
@Data
public
class
CsvCell
extends
CellBase
{
/**
* column index
*/
@Getter
(
value
=
AccessLevel
.
NONE
)
@Setter
(
value
=
AccessLevel
.
NONE
)
private
Integer
columnIndex
;
/**
* cell type
*/
@Getter
(
value
=
AccessLevel
.
NONE
)
@Setter
(
value
=
AccessLevel
.
NONE
)
private
CellType
cellType
;
/**
* row
...
...
@@ -132,6 +141,24 @@ public class CsvCell extends CellBase {
richTextString
=
value
;
}
@Override
public
void
setCellValue
(
String
value
)
{
if
(
value
==
null
)
{
setBlank
();
return
;
}
setCellValueImpl
(
value
);
}
@Override
public
void
setCellValue
(
RichTextString
value
)
{
if
(
value
==
null
||
value
.
getString
()
==
null
)
{
setBlank
();
return
;
}
setCellValueImpl
(
value
);
}
@Override
protected
SpreadsheetVersion
getSpreadsheetVersion
()
{
return
null
;
...
...
src/main/java/com/alibaba/excel/metadata/csv/CsvCellStyle.java
浏览文件 @
fd000d51
...
...
@@ -2,6 +2,7 @@ package com.alibaba.excel.metadata.csv;
import
com.alibaba.excel.metadata.data.DataFormatData
;
import
lombok.Data
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Color
;
...
...
@@ -15,6 +16,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
*
* @author Jiaju Zhuang
*/
@Data
public
class
CsvCellStyle
implements
CellStyle
{
/**
...
...
@@ -33,22 +35,31 @@ public class CsvCellStyle implements CellStyle {
@Override
public
short
getIndex
()
{
return
0
;
return
index
;
}
@Override
public
void
setDataFormat
(
short
fmt
)
{
initDataFormatData
();
dataFormatData
.
setIndex
(
fmt
);
}
private
void
initDataFormatData
()
{
if
(
dataFormatData
==
null
)
{
dataFormatData
=
new
DataFormatData
();
}
}
@Override
public
short
getDataFormat
()
{
return
0
;
initDataFormatData
();
return
dataFormatData
.
getIndex
();
}
@Override
public
String
getDataFormatString
()
{
return
null
;
initDataFormatData
();
return
dataFormatData
.
getFormat
();
}
@Override
...
...
src/main/java/com/alibaba/excel/metadata/csv/CsvRow.java
浏览文件 @
fd000d51
...
...
@@ -3,6 +3,7 @@ package com.alibaba.excel.metadata.csv;
import
java.util.Iterator
;
import
java.util.List
;
import
lombok.Data
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.compress.utils.Lists
;
import
org.apache.poi.ss.usermodel.Cell
;
...
...
@@ -16,6 +17,7 @@ import org.apache.poi.ss.usermodel.Sheet;
*
* @author Jiaju Zhuang
*/
@Data
public
class
CsvRow
implements
Row
{
/**
...
...
src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java
浏览文件 @
fd000d51
package
com.alibaba.excel.metadata.csv
;
import
java.io.Closeable
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.nio.charset.Charset
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -77,22 +71,6 @@ public class CsvSheet implements Sheet, Closeable {
*/
private
CSVPrinter
csvPrinter
;
public
CsvSheet
(
CsvWorkbook
csvWorkbook
,
File
file
,
Charset
charset
)
throws
FileNotFoundException
{
this
.
csvWorkbook
=
csvWorkbook
;
this
.
out
=
new
OutputStreamWriter
(
new
FileOutputStream
(
file
),
charset
);
this
.
rowCacheCount
=
500
;
this
.
csvFormat
=
CSVFormat
.
DEFAULT
;
this
.
lastRowIndex
=
-
1
;
}
public
CsvSheet
(
CsvWorkbook
csvWorkbook
,
OutputStream
outputStream
)
{
this
.
csvWorkbook
=
csvWorkbook
;
this
.
out
=
new
OutputStreamWriter
(
outputStream
);
this
.
rowCacheCount
=
500
;
this
.
csvFormat
=
CSVFormat
.
DEFAULT
;
this
.
lastRowIndex
=
-
1
;
}
public
CsvSheet
(
CsvWorkbook
csvWorkbook
,
Appendable
out
)
{
this
.
csvWorkbook
=
csvWorkbook
;
this
.
out
=
out
;
...
...
src/main/java/com/alibaba/excel/metadata/data/DataFormatData.java
浏览文件 @
fd000d51
...
...
@@ -19,6 +19,10 @@ public class DataFormatData {
*/
private
String
format
;
public
DataFormatData
()
{
this
.
index
=
0
;
}
@Override
public
DataFormatData
clone
()
{
DataFormatData
dataFormatData
=
new
DataFormatData
();
...
...
src/main/java/com/alibaba/excel/util/WorkBookUtil.java
浏览文件 @
fd000d51
package
com.alibaba.excel.util
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
...
...
@@ -68,16 +67,9 @@ public class WorkBookUtil {
}
return
;
case
CSV:
CsvWorkbook
csvWorkbook
;
if
(
writeWorkbookHolder
.
getFile
()
!=
null
)
{
csvWorkbook
=
new
CsvWorkbook
(
new
OutputStreamWriter
(
new
FileOutputStream
(
writeWorkbookHolder
.
getFile
()),
writeWorkbookHolder
.
getFileCharset
()),
writeWorkbookHolder
.
getGlobalConfiguration
().
getLocale
());
}
else
{
csvWorkbook
=
new
CsvWorkbook
(
null
,
writeWorkbookHolder
.
getGlobalConfiguration
().
getLocale
());
}
CsvWorkbook
csvWorkbook
=
new
CsvWorkbook
(
writeWorkbookHolder
);
CsvWorkbook
csvWorkbook
=
new
CsvWorkbook
(
new
OutputStreamWriter
(
writeWorkbookHolder
.
getOutputStream
(),
writeWorkbookHolder
.
getCharset
()),
writeWorkbookHolder
.
getGlobalConfiguration
().
getLocale
());
writeWorkbookHolder
.
setCachedWorkbook
(
csvWorkbook
);
writeWorkbookHolder
.
setWorkbook
(
csvWorkbook
);
return
;
...
...
src/main/java/com/alibaba/excel/write/metadata/WriteWorkbook.java
浏览文件 @
fd000d51
...
...
@@ -3,6 +3,7 @@ package com.alibaba.excel.write.metadata;
import
java.io.File
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.charset.Charset
;
import
com.alibaba.excel.support.ExcelTypeEnum
;
...
...
@@ -31,6 +32,10 @@ public class WriteWorkbook extends WriteBasicParameter {
* If 'outputStream' and 'file' all not empty,file first
*/
private
OutputStream
outputStream
;
/**
* output charset
*/
private
Charset
charset
;
/**
* Template input stream
* <p>
...
...
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
浏览文件 @
fd000d51
...
...
@@ -65,14 +65,14 @@ public class WriteWorkbookHolder extends AbstractWriteHolder {
* If 'outputStream' and 'file' all not empty,file first
*/
private
File
file
;
/**
* charset of final output file
*/
private
Charset
fileCharset
;
/**
* Final output stream
*/
private
OutputStream
outputStream
;
/**
* output charset
*/
private
Charset
charset
;
/**
* Template input stream
* <p>
...
...
@@ -152,6 +152,13 @@ public class WriteWorkbookHolder extends AbstractWriteHolder {
}
else
{
this
.
outputStream
=
writeWorkbook
.
getOutputStream
();
}
if
(
writeWorkbook
.
getCharset
()
==
null
)
{
this
.
charset
=
Charset
.
defaultCharset
();
}
else
{
this
.
charset
=
writeWorkbook
.
getCharset
();
}
if
(
writeWorkbook
.
getAutoCloseStream
()
==
null
)
{
this
.
autoCloseStream
=
Boolean
.
TRUE
;
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录