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
5bc5b244
Commit
5bc5b244
authored
Oct 08, 2019
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了合并模板
parent
a4f7fa0a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
40 deletions
+80
-40
FrmMain.Designer.cs
Kivii.Client.OfficeSample/FrmMain.Designer.cs
+54
-19
FrmMain.cs
Kivii.Client.OfficeSample/FrmMain.cs
+16
-2
FrmMain.resx
Kivii.Client.OfficeSample/FrmMain.resx
+0
-10
Kivii.Client.OfficeSample.csproj
Kivii.Client.OfficeSample/Kivii.Client.OfficeSample.csproj
+6
-6
packages.config
Kivii.Client.OfficeSample/packages.config
+4
-3
No files found.
Kivii.Client.OfficeSample/FrmMain.Designer.cs
View file @
5bc5b244
...
@@ -42,16 +42,19 @@
...
@@ -42,16 +42,19 @@
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
lblSpendTime
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
lblSpendTime
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
panel2
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panel2
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
groupBox2
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
dgTasks
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
dgTasks
=
new
System
.
Windows
.
Forms
.
DataGridView
();
this
.
Title
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Title
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column1
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column1
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column2
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
Column2
=
new
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
();
this
.
groupBox2
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnSelectTemplateFile2
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
tbxTemplateFileName2
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
panel1
.
SuspendLayout
();
this
.
panel1
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
groupBox1
.
SuspendLayout
();
this
.
panel2
.
SuspendLayout
();
this
.
panel2
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dgTasks
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dgTasks
)).
BeginInit
();
this
.
groupBox2
.
SuspendLayout
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// btnGetReport
// btnGetReport
...
@@ -170,7 +173,7 @@
...
@@ -170,7 +173,7 @@
// lblSpendTime
// lblSpendTime
//
//
this
.
lblSpendTime
.
AutoSize
=
true
;
this
.
lblSpendTime
.
AutoSize
=
true
;
this
.
lblSpendTime
.
Location
=
new
System
.
Drawing
.
Point
(
15
,
57
);
this
.
lblSpendTime
.
Location
=
new
System
.
Drawing
.
Point
(
15
,
80
);
this
.
lblSpendTime
.
Name
=
"lblSpendTime"
;
this
.
lblSpendTime
.
Name
=
"lblSpendTime"
;
this
.
lblSpendTime
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblSpendTime
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
lblSpendTime
.
TabIndex
=
1
;
this
.
lblSpendTime
.
TabIndex
=
1
;
...
@@ -186,21 +189,6 @@
...
@@ -186,21 +189,6 @@
this
.
panel2
.
Size
=
new
System
.
Drawing
.
Size
(
601
,
736
);
this
.
panel2
.
Size
=
new
System
.
Drawing
.
Size
(
601
,
736
);
this
.
panel2
.
TabIndex
=
5
;
this
.
panel2
.
TabIndex
=
5
;
//
//
// groupBox2
//
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxTemplateFileName
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnGenerateXlsx
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnSelectTemplateFile
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label3
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
lblSpendTime
);
this
.
groupBox2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
601
,
95
);
this
.
groupBox2
.
TabIndex
=
0
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"groupBox2"
;
//
// dgTasks
// dgTasks
//
//
this
.
dgTasks
.
ColumnHeadersHeightSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnHeadersHeightSizeMode
.
AutoSize
;
this
.
dgTasks
.
ColumnHeadersHeightSizeMode
=
System
.
Windows
.
Forms
.
DataGridViewColumnHeadersHeightSizeMode
.
AutoSize
;
...
@@ -236,6 +224,50 @@
...
@@ -236,6 +224,50 @@
this
.
Column2
.
Name
=
"Column2"
;
this
.
Column2
.
Name
=
"Column2"
;
this
.
Column2
.
ReadOnly
=
true
;
this
.
Column2
.
ReadOnly
=
true
;
//
//
// groupBox2
//
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxTemplateFileName2
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxTemplateFileName
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnGenerateXlsx
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnSelectTemplateFile2
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
btnSelectTemplateFile
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label4
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
label3
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
lblSpendTime
);
this
.
groupBox2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
601
,
95
);
this
.
groupBox2
.
TabIndex
=
0
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"生成选项"
;
//
// label4
//
this
.
label4
.
AutoSize
=
true
;
this
.
label4
.
Location
=
new
System
.
Drawing
.
Point
(
15
,
54
);
this
.
label4
.
Name
=
"label4"
;
this
.
label4
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
12
);
this
.
label4
.
TabIndex
=
1
;
this
.
label4
.
Text
=
"选择模板2"
;
//
// btnSelectTemplateFile2
//
this
.
btnSelectTemplateFile2
.
Location
=
new
System
.
Drawing
.
Point
(
253
,
49
);
this
.
btnSelectTemplateFile2
.
Name
=
"btnSelectTemplateFile2"
;
this
.
btnSelectTemplateFile2
.
Size
=
new
System
.
Drawing
.
Size
(
50
,
23
);
this
.
btnSelectTemplateFile2
.
TabIndex
=
0
;
this
.
btnSelectTemplateFile2
.
Text
=
"..."
;
this
.
btnSelectTemplateFile2
.
UseVisualStyleBackColor
=
true
;
this
.
btnSelectTemplateFile2
.
Click
+=
new
System
.
EventHandler
(
this
.
btnSelectTemplateFile2_Click
);
//
// tbxTemplateFileName2
//
this
.
tbxTemplateFileName2
.
Location
=
new
System
.
Drawing
.
Point
(
85
,
51
);
this
.
tbxTemplateFileName2
.
Name
=
"tbxTemplateFileName2"
;
this
.
tbxTemplateFileName2
.
Size
=
new
System
.
Drawing
.
Size
(
162
,
21
);
this
.
tbxTemplateFileName2
.
TabIndex
=
2
;
//
// FrmMain
// FrmMain
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
...
@@ -250,9 +282,9 @@
...
@@ -250,9 +282,9 @@
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
PerformLayout
();
this
.
groupBox1
.
PerformLayout
();
this
.
panel2
.
ResumeLayout
(
false
);
this
.
panel2
.
ResumeLayout
(
false
);
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dgTasks
)).
EndInit
();
this
.
groupBox2
.
ResumeLayout
(
false
);
this
.
groupBox2
.
ResumeLayout
(
false
);
this
.
groupBox2
.
PerformLayout
();
this
.
groupBox2
.
PerformLayout
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
dgTasks
)).
EndInit
();
this
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
}
}
...
@@ -278,6 +310,9 @@
...
@@ -278,6 +310,9 @@
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Title
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Title
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column1
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column1
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column2
;
private
System
.
Windows
.
Forms
.
DataGridViewTextBoxColumn
Column2
;
private
System
.
Windows
.
Forms
.
TextBox
tbxTemplateFileName2
;
private
System
.
Windows
.
Forms
.
Button
btnSelectTemplateFile2
;
private
System
.
Windows
.
Forms
.
Label
label4
;
}
}
}
}
Kivii.Client.OfficeSample/FrmMain.cs
View file @
5bc5b244
...
@@ -64,16 +64,30 @@ namespace Kivii.Client.OfficeSample
...
@@ -64,16 +64,30 @@ namespace Kivii.Client.OfficeSample
//创建个模板引擎
//创建个模板引擎
var
template
=
new
TemplateExcel
();
var
template
=
new
TemplateExcel
();
template
.
Open
(
tbxTemplateFileName
.
Text
);
//打开模板文件
template
.
Open
(
tbxTemplateFileName
.
Text
);
//打开模板文件
template
.
Bind
(
"contract"
,
_contract
);
//将数据绑定到模板中,注意contract在模板中这是这个变量名了
template
.
Bind
(
"contract"
,
_contract
);
//将数据绑定到模板中,注意contract在模板中这是这个变量名了
template
.
Bind
(
"task"
,
_tasks
);
template
.
Bind
(
"task"
,
_tasks
);
var
rtns
=
template
.
Fill
();
//填充模板
var
rtns
=
template
.
Fill
();
//填充模板
var
template2
=
new
TemplateExcel
();
template2
.
Open
(
tbxTemplateFileName2
.
Text
);
//打开模板文件
template2
.
Bind
(
"contract"
,
_contract
);
//将数据绑定到模板中,注意contract在模板中这是这个变量名了
template2
.
Bind
(
"task"
,
_tasks
);
var
rtns2
=
template2
.
Fill
();
//填充模板
//合并两个模板
template
.
Contact
(
template2
.
Package
);
template
.
SaveAs
(
saveFileName
);
//最后另存当前的文件
template
.
SaveAs
(
saveFileName
);
//最后另存当前的文件
watch
.
Stop
();
watch
.
Stop
();
lblSpendTime
.
Text
=
$"共花费
{
watch
.
ElapsedMilliseconds
}
毫秒,共填充了
{
rtns
.
Count
}
个项目"
;
lblSpendTime
.
Text
=
$"共花费
{
watch
.
ElapsedMilliseconds
}
毫秒,共填充了
{
rtns
.
Count
}
个项目"
;
}
}
private
void
btnSelectTemplateFile2_Click
(
object
sender
,
EventArgs
e
)
{
OpenFileDialog
ofd
=
new
OpenFileDialog
();
ofd
.
Filter
=
"Excel模板文件|*.xlsx"
;
if
(
ofd
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
tbxTemplateFileName2
.
Text
=
ofd
.
FileName
;
}
}
}
}
}
Kivii.Client.OfficeSample/FrmMain.resx
View file @
5bc5b244
...
@@ -126,13 +126,4 @@
...
@@ -126,13 +126,4 @@
<metadata
name=
"Column2.UserAddedColumn"
type=
"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<metadata
name=
"Column2.UserAddedColumn"
type=
"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<value>
True
</value>
<value>
True
</value>
</metadata>
</metadata>
<metadata
name=
"Title.UserAddedColumn"
type=
"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<value>
True
</value>
</metadata>
<metadata
name=
"Column1.UserAddedColumn"
type=
"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<value>
True
</value>
</metadata>
<metadata
name=
"Column2.UserAddedColumn"
type=
"System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<value>
True
</value>
</metadata>
</root>
</root>
\ No newline at end of file
Kivii.Client.OfficeSample/Kivii.Client.OfficeSample.csproj
View file @
5bc5b244
...
@@ -32,14 +32,14 @@
...
@@ -32,14 +32,14 @@
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Kivii.Common.V4.0, Version=5.4.2019.92
0
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Common.V4.0, Version=5.4.2019.92
5
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Common.5.4.2019.92
0
0\lib\net40\Kivii.Common.V4.0.dll
</HintPath>
<HintPath>
..\packages\Kivii.Common.5.4.2019.92
5
0\lib\net40\Kivii.Common.V4.0.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Kivii.Core.V4.0, Version=5.4.2019.92
0
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Core.V4.0, Version=5.4.2019.92
5
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Core.5.4.2019.92
0
0\lib\net40\Kivii.Core.V4.0.dll
</HintPath>
<HintPath>
..\packages\Kivii.Core.5.4.2019.92
5
0\lib\net40\Kivii.Core.V4.0.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Kivii.Office.OpenXml.V4.0, Version=5.4.2019.92
2
0, Culture=neutral, processorArchitecture=MSIL"
>
<Reference
Include=
"Kivii.Office.OpenXml.V4.0, Version=5.4.2019.92
3
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Kivii.Office.OpenXml.5.4.2019.92
2
0\lib\net40\Kivii.Office.OpenXml.V4.0.dll
</HintPath>
<HintPath>
..\packages\Kivii.Office.OpenXml.5.4.2019.92
3
0\lib\net40\Kivii.Office.OpenXml.V4.0.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Core"
/>
...
...
Kivii.Client.OfficeSample/packages.config
View file @
5bc5b244
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
packages
>
<
package
id
=
"Kivii.Common"
version
=
"5.4.2019.92
0
0"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Common"
version
=
"5.4.2019.92
5
0"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.4.2019.92
0
0"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Core"
version
=
"5.4.2019.92
5
0"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Office.OpenXml"
version
=
"5.4.2019.92
2
0"
targetFramework
=
"net40"
/>
<
package
id
=
"Kivii.Office.OpenXml"
version
=
"5.4.2019.92
3
0"
targetFramework
=
"net40"
/>
</
packages
>
</
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