Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.OfficeSample
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.Client.OfficeSample
Commits
e79cd512
Commit
e79cd512
authored
Sep 20, 2019
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新Nuget版本
parent
7f809d62
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
19 deletions
+31
-19
FrmMain.Designer.cs
Kivii.Client.OfficeSample/FrmMain.Designer.cs
+20
-8
FrmMain.cs
Kivii.Client.OfficeSample/FrmMain.cs
+7
-8
Kivii.Client.OfficeSample.csproj
Kivii.Client.OfficeSample/Kivii.Client.OfficeSample.csproj
+2
-2
packages.config
Kivii.Client.OfficeSample/packages.config
+2
-1
No files found.
Kivii.Client.OfficeSample/FrmMain.Designer.cs
View file @
e79cd512
...
...
@@ -38,8 +38,9 @@
this
.
tbxTemplateFileName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnSelectTemplateFile
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel1
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
pgResult
=
new
System
.
Windows
.
Forms
.
PropertyGrid
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
lblSpendTime
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
panel1
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
SuspendLayout
();
...
...
@@ -89,7 +90,7 @@
//
// btnGenerateXlsx
//
this
.
btnGenerateXlsx
.
Location
=
new
System
.
Drawing
.
Point
(
374
,
72
);
this
.
btnGenerateXlsx
.
Location
=
new
System
.
Drawing
.
Point
(
539
,
72
);
this
.
btnGenerateXlsx
.
Name
=
"btnGenerateXlsx"
;
this
.
btnGenerateXlsx
.
Size
=
new
System
.
Drawing
.
Size
(
112
,
23
);
this
.
btnGenerateXlsx
.
TabIndex
=
0
;
...
...
@@ -133,6 +134,14 @@
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
339
,
736
);
this
.
panel1
.
TabIndex
=
4
;
//
// pgResult
//
this
.
pgResult
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
pgResult
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
95
);
this
.
pgResult
.
Name
=
"pgResult"
;
this
.
pgResult
.
Size
=
new
System
.
Drawing
.
Size
(
339
,
641
);
this
.
pgResult
.
TabIndex
=
4
;
//
// groupBox1
//
this
.
groupBox1
.
Controls
.
Add
(
this
.
tbxReportId
);
...
...
@@ -148,13 +157,14 @@
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"获取数据"
;
//
//
pgResult
//
lblSpendTime
//
this
.
pgResult
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
pgResult
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
95
);
this
.
pgResult
.
Name
=
"pgResult"
;
this
.
pgResult
.
Size
=
new
System
.
Drawing
.
Size
(
339
,
641
);
this
.
pgResult
.
TabIndex
=
4
;
this
.
lblSpendTime
.
AutoSize
=
true
;
this
.
lblSpendTime
.
Location
=
new
System
.
Drawing
.
Point
(
375
,
83
);
this
.
lblSpendTime
.
Name
=
"lblSpendTime"
;
this
.
lblSpendTime
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblSpendTime
.
TabIndex
=
1
;
this
.
lblSpendTime
.
Text
=
"生成时间:"
;
//
// FrmMain
//
...
...
@@ -164,6 +174,7 @@
this
.
Controls
.
Add
(
this
.
panel1
);
this
.
Controls
.
Add
(
this
.
tbxTemplateFileName
);
this
.
Controls
.
Add
(
this
.
label3
);
this
.
Controls
.
Add
(
this
.
lblSpendTime
);
this
.
Controls
.
Add
(
this
.
btnSelectTemplateFile
);
this
.
Controls
.
Add
(
this
.
btnGenerateXlsx
);
this
.
Name
=
"FrmMain"
;
...
...
@@ -190,6 +201,7 @@
private
System
.
Windows
.
Forms
.
Panel
panel1
;
private
System
.
Windows
.
Forms
.
PropertyGrid
pgResult
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
Label
lblSpendTime
;
}
}
Kivii.Client.OfficeSample/FrmMain.cs
View file @
e79cd512
using
Kivii.Client.OfficeSample.Entities
;
using
Kivii.Office.OpenXml.Templates
;
using
Kivii.Office.OpenXml.
Excel.
Templates
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Diagnostics
;
using
System.Windows.Forms
;
namespace
Kivii.Client.OfficeSample
...
...
@@ -52,15 +47,19 @@ namespace Kivii.Client.OfficeSample
if
(
sfd
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
var
saveFileName
=
sfd
.
FileName
;
Stopwatch
watch
=
new
Stopwatch
();
watch
.
Start
();
//创建个模板引擎
var
template
=
new
TemplateExcel
();
template
.
Open
(
tbxTemplateFileName
.
Text
);
//打开模板文件
template
.
Bind
(
"contract"
,
_contract
);
//将数据绑定到模板中,注意contract在模板中这是这个变量名了
template
.
Fill
();
//填充模板
var
rtns
=
template
.
Fill
();
//填充模板
template
.
SaveAs
(
saveFileName
);
//最后另存当前的文件
watch
.
Stop
();
lblSpendTime
.
Text
=
$"共花费
{
watch
.
ElapsedMilliseconds
}
毫秒,共填充了
{
rtns
.
Count
}
个项目"
;
}
}
}
Kivii.Client.OfficeSample/Kivii.Client.OfficeSample.csproj
View file @
e79cd512
...
...
@@ -36,8 +36,8 @@
<HintPath>
..\packages\Kivii.Common.5.4.2019.8201\lib\net40\Kivii.Common.V4.0.dll
</HintPath>
<Private>
True
</Private>
</Reference>
<Reference
Include=
"Kivii.Office.OpenXml.V4.0, Version=5.4.2019.910
0
, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Office.OpenXml.5.4.2019.910
0
\lib\net40\Kivii.Office.OpenXml.V4.0.dll
</HintPath>
<Reference
Include=
"Kivii.Office.OpenXml.V4.0, Version=5.4.2019.910
2
, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Office.OpenXml.5.4.2019.910
2
\lib\net40\Kivii.Office.OpenXml.V4.0.dll
</HintPath>
<Private>
True
</Private>
</Reference>
<Reference
Include=
"System"
/>
...
...
Kivii.Client.OfficeSample/packages.config
View file @
e79cd512
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.4.2019.8201"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Office.OpenXml"
version
=
"5.4.2019.910
0
"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Office.OpenXml"
version
=
"5.4.2019.910
2
"
targetFramework
=
"net40"
/>
</
packages
>
\ 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