Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
2dcae3d1
提交
2dcae3d1
authored
9月 28, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 创建MySQL数据源时出现 Public Key Retrieval is not allowed错误
上级
acc28ccd
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
13 行删除
+27
-13
ExcelReaderUtil.java
.../main/java/io/dataease/commons/utils/ExcelReaderUtil.java
+9
-5
ExcelXlsxReader.java
.../main/java/io/dataease/commons/utils/ExcelXlsxReader.java
+17
-7
MysqlConfigration.java
...in/java/io/dataease/datasource/dto/MysqlConfigration.java
+1
-1
没有找到文件。
backend/src/main/java/io/dataease/commons/utils/ExcelReaderUtil.java
浏览文件 @
2dcae3d1
package
io
.
dataease
.
commons
.
utils
;
import
com.google.gson.Gson
;
import
io.dataease.datasource.dto.TableFiled
;
import
org.apache.poi.hssf.usermodel.HSSFCell
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
...
...
@@ -56,8 +57,9 @@ public class ExcelReaderUtil {
}
else
if
(
fileName
.
endsWith
(
EXCEL07_EXTENSION
))
{
//处理excel2007文件
ExcelXlsxReader
excelXlsxReader
=
new
ExcelXlsxReader
();
excelXlsxReader
.
process
(
inputStream
);
System
.
out
.
println
(
excelXlsxReader
.
totalSheets
.
size
());
System
.
out
.
println
(
excelXlsxReader
.
totalSheets
.
get
(
0
).
getExcelLable
());
System
.
out
.
println
(
excelXlsxReader
.
totalSheets
.
get
(
0
).
getFields
().
size
());
for
(
TableFiled
field
:
excelXlsxReader
.
totalSheets
.
get
(
0
).
getFields
())
{
System
.
out
.
println
(
new
Gson
().
toJson
(
field
));
}
...
...
@@ -68,8 +70,10 @@ public class ExcelReaderUtil {
}
}
/* public static void main(String[] args) throws Exception {
String file ="Metersphere_case_DataEase功能用例.xlsx";
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
file
=
"各省市GDP-表格_加内容.xlsx"
;
ExcelReaderUtil
.
readExcel
(
file
,
new
FileInputStream
(
"/Users/taojinlong/Desktop/"
+
file
));
}
*/
}
}
backend/src/main/java/io/dataease/commons/utils/ExcelXlsxReader.java
浏览文件 @
2dcae3d1
...
...
@@ -234,7 +234,7 @@ public class ExcelXlsxReader extends DefaultHandler {
return
;
}
//t元素也包含字符串
if
(
isTElement
)
{
//这个程序没经过
if
(
isTElement
)
{
//这个程序没经过
//将单元格内容加入rowlist中,在这之前先去掉字符串前后的空白符
String
value
=
lastIndex
.
trim
();
if
(
curRow
==
1
){
...
...
@@ -271,6 +271,9 @@ public class ExcelXlsxReader extends DefaultHandler {
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
curCol
<
this
.
fields
.
size
()){
cellList
.
add
(
curCol
,
""
);
if
(
curRow
==
1
){
addField
(
""
,
curCol
);
}
curCol
++;
}
}
...
...
@@ -413,12 +416,7 @@ public class ExcelXlsxReader extends DefaultHandler {
break
;
}
if
(
curRow
==
1
){
TableFiled
tableFiled
=
new
TableFiled
();
tableFiled
.
setFieldType
(
"TEXT"
);
tableFiled
.
setFieldSize
(
65533
);
tableFiled
.
setFieldName
(
thisStr
);
tableFiled
.
setRemarks
(
thisStr
);
this
.
fields
.
add
(
tableFiled
);
addField
(
thisStr
,
null
);
}
else
{
if
(
CollectionUtils
.
isEmpty
(
this
.
getFields
())){
throw
new
RuntimeException
(
Translator
.
get
(
"i18n_excel_header_empty"
));
...
...
@@ -443,6 +441,18 @@ public class ExcelXlsxReader extends DefaultHandler {
return
thisStr
;
}
private
void
addField
(
String
columeName
,
Integer
index
){
TableFiled
tableFiled
=
new
TableFiled
();
tableFiled
.
setFieldType
(
"TEXT"
);
tableFiled
.
setFieldSize
(
65533
);
tableFiled
.
setFieldName
(
columeName
);
tableFiled
.
setRemarks
(
columeName
);
if
(
index
!=
null
){
this
.
fields
.
add
(
index
,
tableFiled
);
}
else
{
this
.
fields
.
add
(
tableFiled
);
}
}
private
String
getType
(
String
thisStr
){
if
(
totalRows
==
0
){
return
"TEXT"
;
...
...
backend/src/main/java/io/dataease/datasource/dto/MysqlConfigration.java
浏览文件 @
2dcae3d1
...
...
@@ -11,7 +11,7 @@ public class MysqlConfigration extends JdbcDTO {
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false"
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false
&allowPublicKeyRetrieval=true
"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论