Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Finances.Addons.V4.5
Project
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
陶然
Kivii.Finances.Addons.V4.5
Commits
b4161960
Commit
b4161960
authored
Oct 26, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
7a4865d5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
1 deletion
+72
-1
Finances.InvoiceTitle.xlsx
Src/Content/Templates/Finances.InvoiceTitle.xlsx
+0
-0
Kivii.Finances.Addons.V4.5.csproj
Src/Kivii.Finances.Addons.V4.5.csproj
+2
-1
Kivii.Finances.Addons.V4.5.csproj.user
Src/Kivii.Finances.Addons.V4.5.csproj.user
+7
-0
RestfulReadExcel.cs
Src/RestfulReadExcel.cs
+63
-0
No files found.
Src/Content/Templates/Finances.InvoiceTitle.xlsx
0 → 100644
View file @
b4161960
File added
Src/Kivii.Finances.Addons.V4.5.csproj
View file @
b4161960
...
...
@@ -54,7 +54,7 @@
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Restful
Payment
.cs"
/>
<Compile
Include=
"Restful
ReadExcel
.cs"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\..\Kivii.Biz.Finances\Src\Kivii.Biz.Finances.V4.5.csproj"
>
...
...
@@ -64,6 +64,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"Content\Templates\Finances.Payment.Receipt.xlsx"
/>
<EmbeddedResource
Include=
"Content\Templates\Finances.InvoiceTitle.xlsx"
/>
<None
Include=
"packages.config"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
...
...
Src/Kivii.Finances.Addons.V4.5.csproj.user
0 → 100644
View file @
b4161960
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<ProjectView>
ProjectFiles
</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
Src/Restful
Payment
.cs
→
Src/Restful
ReadExcel
.cs
View file @
b4161960
...
...
@@ -129,4 +129,67 @@ namespace Kivii.Finances.Addons
return
rtns
;
}
}
[
Api
(
Description
=
"读取Excel发票抬头"
)]
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
public
class
InvoiceTitleReadExcel
:
RestfulExecution
<
InvoiceTitle
>
{
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
(
Request
.
Files
.
Count
()
<
1
||
Request
.
Files
==
null
).
ThrowIfTrue
(
"未找到excel文件!"
);
var
httpFile
=
Request
.
Files
[
0
];
ExcelPackage
package
=
new
ExcelPackage
(
Request
.
Files
[
0
].
InputStream
);
(
package
.
Workbook
.
Worksheets
.
Count
==
0
).
ThrowIfTrue
(
"未找到Sheet!"
);
var
rtns
=
new
ReadExcelResponse
<
InvoiceTitle
>();
rtns
.
Results
=
new
List
<
InvoiceTitle
>();
try
{
var
sheet
=
package
.
Workbook
.
Worksheets
[
1
];
var
end
=
sheet
.
Dimension
.
End
.
Row
;
for
(
int
i
=
2
;
i
<=
end
;
i
++)
{
#
region
格式化
Excel
中每行数据
,
必填项若不符合验证条件就抛出异常
var
eCompanyName
=
sheet
.
Cells
[
i
,
2
].
Value
;
if
(
eCompanyName
==
null
)
{
throw
new
Exception
(
$"Excel第
{
i
}
行第2列不可为空,请传入不重复的名称!"
);
}
var
companyName
=
eCompanyName
.
ToString
();
var
eTaxNumber
=
sheet
.
Cells
[
i
,
3
].
Value
;
if
(
eTaxNumber
==
null
)
{
throw
new
Exception
(
$"Excel第
{
i
}
行第3列不可为空,请传入不重复的税号!"
);
}
var
taxNumber
=
eTaxNumber
.
ToString
();
var
eCompanyAddress
=
sheet
.
Cells
[
i
,
4
].
Value
;
var
companyAddress
=
eCompanyAddress
==
null
?
string
.
Empty
:
eCompanyAddress
.
ToString
();
var
ePhone
=
sheet
.
Cells
[
i
,
5
].
Value
;
var
phone
=
ePhone
==
null
?
string
.
Empty
:
ePhone
.
ToString
();
var
eBankName
=
sheet
.
Cells
[
i
,
6
].
Value
;
var
bankName
=
eBankName
==
null
?
string
.
Empty
:
eBankName
.
ToString
();
var
eBankAccount
=
sheet
.
Cells
[
i
,
7
].
Value
;
var
bankAccount
=
eBankAccount
==
null
?
string
.
Empty
:
eBankAccount
.
ToString
();
#
endregion
var
invoiceTitle
=
new
InvoiceTitle
();
invoiceTitle
.
CompanyName
=
companyName
;
invoiceTitle
.
TaxNumber
=
taxNumber
;
invoiceTitle
.
CompanyAddress
=
companyAddress
;
invoiceTitle
.
Phone
=
phone
;
invoiceTitle
.
BankName
=
bankName
;
invoiceTitle
.
BankAccount
=
bankAccount
;
if
(!
rtns
.
Results
.
Exists
(
o
=>
o
.
CompanyName
==
invoiceTitle
.
CompanyName
))
rtns
.
Results
.
Add
(
invoiceTitle
);
}
}
catch
(
Exception
ex
)
{
throw
ex
;
}
rtns
.
Total
=
rtns
.
Results
.
Count
;
rtns
.
success
=
true
;
return
rtns
;
}
}
}
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