Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
test-data-manalysis
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
朱广松
test-data-manalysis
Commits
a28c00ab
Commit
a28c00ab
authored
Sep 19, 2025
by
zhugs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:excel文件数据分析测试
parent
0916374e
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
72 行增加
和
1 行删除
+72
-1
src/main/java/Main.java
+1
-1
src/main/java/execl/ExcelHandler.java
+58
-0
src/main/java/execl/ExcelHandlerFactory.java
+13
-0
没有找到文件。
src/main/java/Main.java
View file @
a28c00ab
...
@@ -34,7 +34,7 @@ public class Main {
...
@@ -34,7 +34,7 @@ public class Main {
Path
dirExcel
=
Path
.
of
(
"C:\\Users\\zhugso\\Projects\\chenyang\\testdata\\exc"
);
Path
dirExcel
=
Path
.
of
(
"C:\\Users\\zhugso\\Projects\\chenyang\\testdata\\exc"
);
Predicate
<
File
>
excelFilter
=
file
->
{
Predicate
<
File
>
excelFilter
=
file
->
{
String
name
=
file
.
getName
();
String
name
=
file
.
getName
();
return
!
name
.
contains
(
"$"
);
return
!
name
.
contains
(
"$"
)
&&
name
.
endsWith
(
".xlsx"
)
;
};
};
new
DirWatcher
(
dirExcel
,
excelFilter
,
new
ExcelHandlerFactory
()).
startWatch
();
new
DirWatcher
(
dirExcel
,
excelFilter
,
new
ExcelHandlerFactory
()).
startWatch
();
...
...
src/main/java/execl/ExcelHandler.java
0 → 100644
View file @
a28c00ab
package
execl
;
import
handler.AbstractFileHandler
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
@Slf4j
public
class
ExcelHandler
extends
AbstractFileHandler
{
public
ExcelHandler
(
File
file
)
{
super
(
file
);
}
@Override
protected
void
processFile
(
File
file
)
{
try
(
FileInputStream
fis
=
new
FileInputStream
(
file
);
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
fis
))
{
String
currentTestName
;
int
count
=
0
;
XSSFSheet
sheet
=
xssfWorkbook
.
getSheetAt
(
0
);
int
lastRowNum
=
sheet
.
getLastRowNum
();
for
(
int
i
=
0
;
i
<
lastRowNum
+
1
;
i
++)
{
XSSFRow
row
=
sheet
.
getRow
(
i
);
if
(
row
!=
null
)
{
Cell
firstCell
=
row
.
getCell
(
2
);
if
(
firstCell
==
null
)
{
count
=
0
;
continue
;
}
if
(
count
==
0
)
{
currentTestName
=
firstCell
.
getStringCellValue
().
trim
();
System
.
out
.
println
(
currentTestName
);
}
else
{
Cell
itemCell
=
row
.
getCell
(
2
);
// chain0 RSSI
Cell
valueCell
=
row
.
getCell
(
3
);
// -69.0
Cell
specCell
=
row
.
getCell
(
4
);
// (-75 <= x <= -65)
System
.
out
.
println
(
itemCell
.
getStringCellValue
()
+
valueCell
.
getStringCellValue
()
+
specCell
.
getStringCellValue
());
}
count
++;
}
else
{
count
=
0
;
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
());
}
}
}
src/main/java/execl/ExcelHandlerFactory.java
0 → 100644
View file @
a28c00ab
package
execl
;
import
handler.AbstractFileHandler
;
import
handler.FileHandlerFactory
;
import
java.io.File
;
public
class
ExcelHandlerFactory
implements
FileHandlerFactory
{
@Override
public
AbstractFileHandler
create
(
File
file
)
{
return
new
ExcelHandler
(
file
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论