Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
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
bltdc
DataCenter_Core2.1_20190520
Commits
f50a81db
Commit
f50a81db
authored
Aug 03, 2021
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加适配表格的公式值
parent
0e31cc62
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
12 deletions
+50
-12
LogisticsController.cs
...eb/Areas/DataWareHouse/Controllers/LogisticsController.cs
+1
-1
NpolHelper.cs
Bailun.DC.Web/Base/NpolHelper.cs
+49
-11
No files found.
Bailun.DC.Web/Areas/DataWareHouse/Controllers/LogisticsController.cs
View file @
f50a81db
...
@@ -136,7 +136,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
...
@@ -136,7 +136,7 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
jsondata
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
item
),
jsondata
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
item
),
month
=
month
,
month
=
month
,
platformtype
=
platform
,
platformtype
=
platform
,
website
=
website
,
website
=
website
??
""
,
createuser
=
"页面上传"
,
createuser
=
"页面上传"
,
datatype
=
1
,
datatype
=
1
,
datatypename
=
"物流账单"
,
datatypename
=
"物流账单"
,
...
...
Bailun.DC.Web/Base/NpolHelper.cs
View file @
f50a81db
...
@@ -144,16 +144,18 @@ namespace Bailun.DC.Web.Base
...
@@ -144,16 +144,18 @@ namespace Bailun.DC.Web.Base
if
(
cell
==
null
)
{
dataRow
[
j
]
=
""
;
}
if
(
cell
==
null
)
{
dataRow
[
j
]
=
""
;
}
else
else
{
{
switch
(
cell
.
CellType
)
dataRow
[
j
]
=
GetCellValue
(
cell
);
{
case
CellType
.
Blank
:
dataRow
[
j
]
=
""
;
break
;
//switch (cell.CellType)
case
CellType
.
Numeric
:
//{
short
format
=
cell
.
CellStyle
.
DataFormat
;
// case CellType.Blank: dataRow[j] = ""; break;
if
(
format
==
14
||
format
==
31
||
format
==
57
||
format
==
58
||
HSSFDateUtil
.
IsCellDateFormatted
(
cell
))
dataRow
[
j
]
=
cell
.
DateCellValue
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
// case CellType.Numeric:
else
dataRow
[
j
]
=
cell
.
NumericCellValue
;
// short format = cell.CellStyle.DataFormat;
break
;
// if (format == 14 || format == 31 || format == 57 || format == 58 || HSSFDateUtil.IsCellDateFormatted(cell)) dataRow[j] = cell.DateCellValue.ToString("yyyy-MM-dd HH:mm:ss");
case
CellType
.
String
:
dataRow
[
j
]
=
cell
.
StringCellValue
;
break
;
// else dataRow[j] = cell.NumericCellValue;
}
// break;
// case CellType.String: dataRow[j] = cell.StringCellValue; break;
//}
}
}
}
}
dataTable
.
Rows
.
Add
(
dataRow
);
dataTable
.
Rows
.
Add
(
dataRow
);
...
@@ -182,7 +184,43 @@ namespace Bailun.DC.Web.Base
...
@@ -182,7 +184,43 @@ namespace Bailun.DC.Web.Base
}
}
}
}
public
static
string
GetCellValue
(
ICell
cell
)
{
if
(
cell
==
null
)
return
string
.
Empty
;
switch
(
cell
.
CellType
)
{
case
CellType
.
Blank
:
return
string
.
Empty
;
case
CellType
.
Boolean
:
return
cell
.
BooleanCellValue
.
ToString
();
case
CellType
.
Error
:
return
cell
.
ErrorCellValue
.
ToString
();
case
CellType
.
Numeric
:
short
format
=
cell
.
CellStyle
.
DataFormat
;
if
(
format
==
14
||
format
==
31
||
format
==
57
||
format
==
58
||
HSSFDateUtil
.
IsCellDateFormatted
(
cell
))
return
cell
.
DateCellValue
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
return
cell
.
NumericCellValue
.
ToString
();
case
CellType
.
Unknown
:
default
:
return
cell
.
ToString
();
case
CellType
.
String
:
return
cell
.
StringCellValue
;
case
CellType
.
Formula
:
try
{
HSSFFormulaEvaluator
e
=
new
HSSFFormulaEvaluator
(
cell
.
Sheet
.
Workbook
);
e
.
EvaluateInCell
(
cell
);
return
cell
.
ToString
();
}
catch
{
return
cell
.
NumericCellValue
.
ToString
();
}
}
}
#
endregion
#
endregion
}
}
}
}
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