明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
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
zengfanpei
jt_backend
Commits
10d70d3a
Commit
10d70d3a
authored
Mar 11, 2026
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3105652c
Pipeline
#108205
passed with stage
in 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
templateController.js
controller/templateController.js
+20
-5
request.js
middleware/request.js
+1
-1
No files found.
controller/templateController.js
View file @
10d70d3a
...
...
@@ -57,7 +57,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
rows
=
Array
(
worksheet
.
actualRowCount
-
3
).
fill
(
Array
(
columns
.
length
).
fill
(
""
))
}
}
else
{
rows
=
Array
(
worksheet
.
actualRowCount
-
3
).
fill
(
Array
(
columns
.
length
).
fill
(
""
))
rows
=
Array
(
worksheet
.
actualRowCount
-
3
).
fill
(
Array
(
columns
.
length
).
fill
(
0
))
}
// console.log(rows, "=============")
...
...
@@ -89,7 +89,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
worksheet
.
eachRow
((
row
,
rowNumber
)
=>
{
row
.
eachCell
((
cell
,
colNumber
)
=>
{
if
(
rowNumber
>=
4
&&
rowNumber
<=
worksheet
.
actualRowCount
&&
colNumber
>=
4
&&
colNumber
<=
(
3
+
columns
.
length
))
{
cell
.
numFmt
=
'#,##0.00'
;
//数字格式
//
cell.numFmt = '#,##0.00'; //数字格式
}
cell
.
alignment
=
{
horizontal
:
'center'
,
...
...
@@ -99,6 +99,9 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
cell
.
border
=
BLACK_BORDER
;
//边框
if
(
tampName
==
"tjjh"
)
{
let
enColNum
=
getExcelColumnLetter
(
colNumber
)
if
([
4
,
14
,
25
,
32
].
includes
(
rowNumber
)){
cell
.
value
=
""
;
}
if
(
rowNumber
==
13
&&
colNumber
>=
4
)
{
cell
.
value
=
{
formula
:
`=SUM(
${
enColNum
}
5,
${
enColNum
}
8,
${
enColNum
}
11)`
}
}
...
...
@@ -120,6 +123,7 @@ async function getXmtzzjllTem({ startYear, endYear, tampName, projectId }) {
if
(
rowNumber
==
41
&&
colNumber
>=
4
)
{
cell
.
value
=
{
formula
:
`=SUM(
${
enColNum
}
42-
${
enColNum
}
43)`
}
}
}
});
});
...
...
@@ -198,6 +202,7 @@ async function importExcelTempData(req, res, next) {
worksheet
.
eachRow
({
includeEmpty
:
true
},
(
row
,
ri
)
=>
{
const
rowData
=
[];
row
.
eachCell
({
includeEmpty
:
true
},
(
cell
,
ci
)
=>
{
console
.
log
(
cell
.
value
,
"==="
)
if
(
cell
.
formula
)
{
rowData
.
push
(
cell
.
formula
);
}
else
if
(
cell
.
type
===
ExcelJS
.
ValueType
.
String
)
{
...
...
@@ -214,15 +219,25 @@ async function importExcelTempData(req, res, next) {
});
sheetData
.
push
(
rowData
);
});
hf
.
addSheet
(
'Sheet1'
);
// 先建表
hf
.
setSheetContent
(
0
,
sheetData
);
// 灌数据+公式
hf
.
addSheet
(
'Sheet1'
);
// 先建表
hf
.
setSheetContent
(
0
,
sheetData
);
// 灌数据+公式
const
{
height
,
width
}
=
hf
.
getSheetDimensions
(
0
);
const
out
=
[];
for
(
let
r
=
0
;
r
<
height
;
r
++
)
{
let
cc
=
[];
for
(
let
c
=
0
;
c
<
sheetData
[
0
].
length
;
c
++
)
{
// const formulaString = hf.getCellFormula({ sheet: 0, row: r, col: c });
let
calculated
=
hf
.
getCellValue
({
sheet
:
0
,
row
:
r
,
col
:
c
});
let
calculated
=
hf
.
getCellValue
({
sheet
:
0
,
row
:
r
,
col
:
c
});
// console.log( calculated, " === ")
try
{
const
result
=
hf
.
calculateFormula
(
"="
+
calculated
,
0
)
// console.log(typeof result, "-----------------")
if
(
typeof
result
==
"number"
)
{
calculated
=
result
;
}
}
catch
(
error
)
{
// console.log(error)
}
// console.log(formulaString, calculated)
if
(
typeof
calculated
==
'string'
)
{
calculated
=
removeSuffix
(
String
(
calculated
),
'_suffix'
)
...
...
middleware/request.js
View file @
10d70d3a
...
...
@@ -64,7 +64,7 @@ function checkPath(path) {
const
allowedPatterns
=
[
/^
\/
user
\/
login$/
,
/^
\/
user
\/
regist$/
,
/^
\/
template
\/
getExcelTemplate$/
,
/^
\/
template
\/
getExcelTemplate
2
$/
,
/^
\/
file
\/
download
\/\d
+$/
,
/^
\/
file
\/
show
\/\d
+$/
,
];
...
...
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