Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-hmhj
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangweidong
patzn-cloud-service-hmhj
Commits
449f71e1
Commit
449f71e1
authored
Jan 10, 2022
by
lijingjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增行未带入公式问题修改;
优化匹配公式
parent
c54d2839
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
SingleSheetMoreItemOperation.java
...vice/lims/hmhj/original/SingleSheetMoreItemOperation.java
+10
-15
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/original/SingleSheetMoreItemOperation.java
View file @
449f71e1
...
@@ -10,7 +10,10 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
...
@@ -10,7 +10,10 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.*
;
import
org.apache.poi.xssf.usermodel.*
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
SingleSheetMoreItemOperation
implements
Operation
{
public
class
SingleSheetMoreItemOperation
implements
Operation
{
...
@@ -81,6 +84,9 @@ public class SingleSheetMoreItemOperation implements Operation {
...
@@ -81,6 +84,9 @@ public class SingleSheetMoreItemOperation implements Operation {
XSSFRow
hideRow
=
sheetOne
.
getRow
(
beginRow
-
1
);
XSSFRow
hideRow
=
sheetOne
.
getRow
(
beginRow
-
1
);
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
XSSFRow
zeroRow
=
sheetOne
.
getRow
(
beginRow
);
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
int
lastCellNum
=
zeroRow
.
getLastCellNum
();
// 提取属性对应公式
Map
<
String
,
String
>
formulaMap
=
this
.
configList
.
stream
().
filter
(
t
->
Objects
.
nonNull
(
t
.
getFormula
()))
.
collect
(
Collectors
.
toMap
(
OriginalTemplateConfig:
:
getAttributeName
,
OriginalTemplateConfig:
:
getFormula
));
int
insertCount
=
voList
.
size
()
-
templateSampleNum
;
int
insertCount
=
voList
.
size
()
-
templateSampleNum
;
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
for
(
int
m
=
0
;
m
<
insertCount
;
m
++)
{
...
@@ -95,8 +101,9 @@ public class SingleSheetMoreItemOperation implements Operation {
...
@@ -95,8 +101,9 @@ public class SingleSheetMoreItemOperation implements Operation {
// 根据标题行处理公式
// 根据标题行处理公式
// 若标题(Si%等等)为空,那么不进行处理,如若不为空,再根据是否存在公式进行处理
// 若标题(Si%等等)为空,那么不进行处理,如若不为空,再根据是否存在公式进行处理
String
title
=
hideRow
.
getCell
(
j
).
getStringCellValue
();
String
title
=
hideRow
.
getCell
(
j
).
getStringCellValue
();
if
(
StringUtils
.
isNotBlank
(
title
))
{
if
(
StringUtils
.
isNotBlank
(
title
)
&&
formulaMap
.
containsKey
(
title
.
trim
()))
{
xssfCell
.
setCellFormula
(
getCellFormula
(
title
.
trim
(),
newRowIndex
+
m
));
String
formula
=
formulaMap
.
get
(
title
.
trim
());
xssfCell
.
setCellFormula
(
OriginalUtil
.
initFormula
(
formula
,
newRowIndex
+
m
));
}
}
}
}
insertRow
++;
insertRow
++;
...
@@ -239,15 +246,4 @@ public class SingleSheetMoreItemOperation implements Operation {
...
@@ -239,15 +246,4 @@ public class SingleSheetMoreItemOperation implements Operation {
}
}
}
}
}
}
private
String
getCellFormula
(
String
key
,
int
rowIndex
)
{
Optional
<
OriginalTemplateConfig
>
optional
=
this
.
configList
.
stream
().
filter
(
t
->
Objects
.
equals
(
key
,
t
.
getAttributeName
())).
findAny
();
if
(
optional
.
isPresent
())
{
String
formula
=
optional
.
get
().
getFormula
();
if
(
StringUtils
.
isNotBlank
(
formula
))
{
return
OriginalUtil
.
initFormula
(
formula
,
rowIndex
);
}
}
return
null
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment