Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
074ca1f9
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
074ca1f9
编写于
6月 05, 2019
作者:
S
Serge Rider
提交者:
GitHub
6月 05, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6058 from dbeaver/OnlyCaptionAuto
Only caption autowidth Former-commit-id:
c14c62c8
上级
a54016e9
052fa212
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
44 deletion
+46
-44
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
...rg/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
+46
-44
未找到文件。
plugins/org.jkiss.dbeaver.data.office/src/org/jkiss/dbeaver/data/office/export/DataExporterXLSX.java
浏览文件 @
074ca1f9
...
...
@@ -73,7 +73,7 @@ public class DataExporterXLSX extends StreamExporterAbstract {
private
static
final
String
PROP_SPLIT_BYROWCOUNT
=
"splitByRowCount"
;
private
static
final
String
PROP_SPLIT_BYCOL
=
"splitByColNum"
;
private
static
final
String
PROP_DATE_FORMAT
=
"dateFormat"
;
private
static
final
int
EXCEL2007MAXROWS
=
1048575
;
...
...
@@ -96,7 +96,7 @@ public class DataExporterXLSX extends StreamExporterAbstract {
private
boolean
booleRedefined
;
private
boolean
exportSql
=
false
;
private
boolean
splitSqlText
=
false
;
private
String
dateFormat
=
""
;
private
String
dateFormat
=
""
;
private
int
splitByRowCount
=
EXCEL2007MAXROWS
;
private
int
splitByCol
=
0
;
...
...
@@ -179,21 +179,19 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
catch
(
Exception
e
)
{
splitByCol
=
-
1
;
}
try
{
dateFormat
=
(
String
)
site
.
getProperties
().
get
(
PROP_DATE_FORMAT
);
}
catch
(
Exception
e
)
{
dateFormat
=
""
;
}
wb
=
new
SXSSFWorkbook
(
ROW_WINDOW
);
worksheets
=
new
HashMap
<>(
1
);
styleHeader
=
(
XSSFCellStyle
)
wb
.
createCellStyle
();
BorderStyle
border
;
try
{
...
...
@@ -218,7 +216,6 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
styleHeader
.
setBorderTop
(
border
);
styleHeader
.
setBorderBottom
(
border
);
styleHeader
.
setBorderLeft
(
border
);
...
...
@@ -228,24 +225,24 @@ public class DataExporterXLSX extends StreamExporterAbstract {
switch
(
fontStyle
)
{
case
BOLD:
fontBold
.
setBold
(
true
);
break
;
case
BOLD:
fontBold
.
setBold
(
true
);
break
;
case
ITALIC:
fontBold
.
setItalic
(
true
);
break
;
case
ITALIC:
fontBold
.
setItalic
(
true
);
break
;
case
STRIKEOUT:
fontBold
.
setStrikeout
(
true
);
break
;
case
STRIKEOUT:
fontBold
.
setStrikeout
(
true
);
break
;
case
UNDERLINE:
fontBold
.
setUnderline
((
byte
)
3
);
break
;
case
UNDERLINE:
fontBold
.
setUnderline
((
byte
)
3
);
break
;
default
:
break
;
default
:
break
;
}
styleHeader
.
setFont
(
fontBold
);
...
...
@@ -255,20 +252,20 @@ public class DataExporterXLSX extends StreamExporterAbstract {
style
.
setBorderBottom
(
border
);
style
.
setBorderLeft
(
border
);
style
.
setBorderRight
(
border
);
styleDate
=
(
XSSFCellStyle
)
wb
.
createCellStyle
();
styleDate
.
setBorderTop
(
border
);
styleDate
.
setBorderBottom
(
border
);
styleDate
.
setBorderLeft
(
border
);
styleDate
.
setBorderRight
(
border
);
if
(
dateFormat
==
null
||
dateFormat
.
length
()
==
0
)
{
styleDate
.
setDataFormat
((
short
)
14
);
styleDate
.
setDataFormat
((
short
)
14
);
}
else
{
styleDate
.
setDataFormat
(
wb
.
getCreationHelper
().
createDataFormat
().
getFormat
(
dateFormat
));
}
this
.
rowCount
=
0
;
super
.
init
(
site
);
...
...
@@ -283,7 +280,8 @@ public class DataExporterXLSX extends StreamExporterAbstract {
Sheet
sh
=
wb
.
createSheet
();
if
(
splitSqlText
)
{
String
[]
sqlText
=
getSite
().
getSource
().
getName
().
split
(
"\n"
,
wb
.
getSpreadsheetVersion
().
getMaxRows
());
String
[]
sqlText
=
getSite
().
getSource
().
getName
().
split
(
"\n"
,
wb
.
getSpreadsheetVersion
().
getMaxRows
());
int
sqlRownum
=
0
;
...
...
@@ -321,7 +319,8 @@ public class DataExporterXLSX extends StreamExporterAbstract {
public
void
exportHeader
(
DBCSession
session
)
throws
DBException
,
IOException
{
columns
=
getSite
().
getAttributes
();
showDescription
=
session
.
getDataSource
().
getContainer
().
getPreferenceStore
().
getBoolean
(
ResultSetPreferences
.
RESULT_SET_SHOW_DESCRIPTION
);
showDescription
=
session
.
getDataSource
().
getContainer
().
getPreferenceStore
()
.
getBoolean
(
ResultSetPreferences
.
RESULT_SET_SHOW_DESCRIPTION
);
}
private
void
printHeader
(
DBCResultSet
resultSet
,
Worksheet
wsh
)
throws
DBException
{
...
...
@@ -354,13 +353,13 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
}
SXSSFSheet
sh
=
(
SXSSFSheet
)
wsh
.
getSh
();
SXSSFSheet
sh
=
(
SXSSFSheet
)
wsh
.
getSh
();
Row
row
=
sh
.
createRow
(
wsh
.
getCurrentRow
());
int
startCol
=
rowNumber
?
1
:
0
;
sh
.
trackAllColumnsForAutoSizing
();
for
(
int
i
=
0
,
columnsSize
=
columns
.
size
();
i
<
columnsSize
;
i
++)
{
sh
.
trackColumnForAutoSizing
(
i
);
DBDAttributeBinding
column
=
columns
.
get
(
i
);
String
colName
=
column
.
getLabel
();
...
...
@@ -391,14 +390,21 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
wsh
.
incRow
();
}
try
{
sh
.
flushRows
();
}
catch
(
IOException
e
)
{
throw
new
DBException
(
"Error processing header"
,
e
);
}
sh
.
untrackAllColumnsForAutoSizing
();
}
private
void
writeCellValue
(
Cell
cell
,
Reader
reader
)
throws
IOException
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
char
buffer
[]
=
new
char
[
2000
];
for
(;
;
)
{
for
(;
;
)
{
int
count
=
reader
.
read
(
buffer
);
if
(
count
<=
0
)
{
break
;
...
...
@@ -413,7 +419,6 @@ public class DataExporterXLSX extends StreamExporterAbstract {
}
}
private
Worksheet
createSheet
(
DBCResultSet
resultSet
,
Object
colValue
)
throws
DBException
{
Worksheet
w
=
new
Worksheet
(
wb
.
createSheet
(),
colValue
,
0
);
if
(
printHeader
)
{
...
...
@@ -496,7 +501,7 @@ public class DataExporterXLSX extends StreamExporterAbstract {
cell
.
setCellValue
((
Date
)
row
[
i
]);
cell
.
setCellStyle
(
styleDate
);
}
else
{
String
stringValue
=
super
.
getValueDisplayString
(
column
,
row
[
i
]);
...
...
@@ -510,25 +515,22 @@ public class DataExporterXLSX extends StreamExporterAbstract {
private
CellType
getCellType
(
DBDAttributeBinding
column
)
{
switch
(
column
.
getDataKind
())
{
case
NUMERIC:
return
CellType
.
NUMERIC
;
case
BOOLEAN:
return
CellType
.
BOOLEAN
;
case
STRING:
return
CellType
.
STRING
;
default
:
return
CellType
.
BLANK
;
case
NUMERIC:
return
CellType
.
NUMERIC
;
case
BOOLEAN:
return
CellType
.
BOOLEAN
;
case
STRING:
return
CellType
.
STRING
;
default
:
return
CellType
.
BLANK
;
}
}
@Override
public
void
exportFooter
(
DBRProgressMonitor
monitor
)
throws
DBException
,
IOException
{
public
void
exportFooter
(
DBRProgressMonitor
monitor
)
throws
DBException
,
IOException
{
if
(
rowCount
==
0
)
{
exportRow
(
null
,
null
,
new
Object
[
columns
.
size
()]);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录