Commit 17a739a7 by 施晓雨

三个模板合并

parent 5bc5b244
...@@ -40,21 +40,24 @@ ...@@ -40,21 +40,24 @@
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.pgResult = new System.Windows.Forms.PropertyGrid(); this.pgResult = new System.Windows.Forms.PropertyGrid();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
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.tbxTemplateFileName2 = new System.Windows.Forms.TextBox();
this.btnSelectTemplateFile2 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.lblSpendTime = new System.Windows.Forms.Label();
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.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.btnSelectTemplateFile3 = new System.Windows.Forms.Button();
this.btnSelectTemplateFile2 = new System.Windows.Forms.Button(); this.tbxTemplateFileName3 = new System.Windows.Forms.TextBox();
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();
((System.ComponentModel.ISupportInitialize)(this.dgTasks)).BeginInit();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgTasks)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnGetReport // btnGetReport
...@@ -114,7 +117,7 @@ ...@@ -114,7 +117,7 @@
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(15, 23); this.label3.Location = new System.Drawing.Point(15, 19);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12); this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 1; this.label3.TabIndex = 1;
...@@ -122,14 +125,14 @@ ...@@ -122,14 +125,14 @@
// //
// tbxTemplateFileName // tbxTemplateFileName
// //
this.tbxTemplateFileName.Location = new System.Drawing.Point(85, 20); this.tbxTemplateFileName.Location = new System.Drawing.Point(85, 16);
this.tbxTemplateFileName.Name = "tbxTemplateFileName"; this.tbxTemplateFileName.Name = "tbxTemplateFileName";
this.tbxTemplateFileName.Size = new System.Drawing.Size(162, 21); this.tbxTemplateFileName.Size = new System.Drawing.Size(162, 21);
this.tbxTemplateFileName.TabIndex = 2; this.tbxTemplateFileName.TabIndex = 2;
// //
// btnSelectTemplateFile // btnSelectTemplateFile
// //
this.btnSelectTemplateFile.Location = new System.Drawing.Point(253, 18); this.btnSelectTemplateFile.Location = new System.Drawing.Point(253, 15);
this.btnSelectTemplateFile.Name = "btnSelectTemplateFile"; this.btnSelectTemplateFile.Name = "btnSelectTemplateFile";
this.btnSelectTemplateFile.Size = new System.Drawing.Size(50, 23); this.btnSelectTemplateFile.Size = new System.Drawing.Size(50, 23);
this.btnSelectTemplateFile.TabIndex = 0; this.btnSelectTemplateFile.TabIndex = 0;
...@@ -170,18 +173,10 @@ ...@@ -170,18 +173,10 @@
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "获取数据"; this.groupBox1.Text = "获取数据";
// //
// lblSpendTime
//
this.lblSpendTime.AutoSize = true;
this.lblSpendTime.Location = new System.Drawing.Point(15, 80);
this.lblSpendTime.Name = "lblSpendTime";
this.lblSpendTime.Size = new System.Drawing.Size(65, 12);
this.lblSpendTime.TabIndex = 1;
this.lblSpendTime.Text = "生成时间:";
//
// panel2 // panel2
// //
this.panel2.Controls.Add(this.dgTasks); this.panel2.Controls.Add(this.dgTasks);
this.panel2.Controls.Add(this.lblSpendTime);
this.panel2.Controls.Add(this.groupBox2); this.panel2.Controls.Add(this.groupBox2);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(339, 0); this.panel2.Location = new System.Drawing.Point(339, 0);
...@@ -189,6 +184,62 @@ ...@@ -189,6 +184,62 @@
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.tbxTemplateFileName3);
this.groupBox2.Controls.Add(this.tbxTemplateFileName2);
this.groupBox2.Controls.Add(this.tbxTemplateFileName);
this.groupBox2.Controls.Add(this.btnGenerateXlsx);
this.groupBox2.Controls.Add(this.btnSelectTemplateFile3);
this.groupBox2.Controls.Add(this.btnSelectTemplateFile2);
this.groupBox2.Controls.Add(this.btnSelectTemplateFile);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
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 = "生成选项";
//
// tbxTemplateFileName2
//
this.tbxTemplateFileName2.Location = new System.Drawing.Point(85, 41);
this.tbxTemplateFileName2.Name = "tbxTemplateFileName2";
this.tbxTemplateFileName2.Size = new System.Drawing.Size(162, 21);
this.tbxTemplateFileName2.TabIndex = 2;
//
// btnSelectTemplateFile2
//
this.btnSelectTemplateFile2.Location = new System.Drawing.Point(253, 40);
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);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(15, 44);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(59, 12);
this.label4.TabIndex = 1;
this.label4.Text = "选择模板2";
//
// lblSpendTime
//
this.lblSpendTime.AutoSize = true;
this.lblSpendTime.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblSpendTime.Location = new System.Drawing.Point(0, 724);
this.lblSpendTime.Name = "lblSpendTime";
this.lblSpendTime.Size = new System.Drawing.Size(65, 12);
this.lblSpendTime.TabIndex = 2;
this.lblSpendTime.Text = "生成时间:";
//
// dgTasks // dgTasks
// //
this.dgTasks.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgTasks.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
...@@ -200,8 +251,8 @@ ...@@ -200,8 +251,8 @@
this.dgTasks.Location = new System.Drawing.Point(0, 95); this.dgTasks.Location = new System.Drawing.Point(0, 95);
this.dgTasks.Name = "dgTasks"; this.dgTasks.Name = "dgTasks";
this.dgTasks.RowTemplate.Height = 23; this.dgTasks.RowTemplate.Height = 23;
this.dgTasks.Size = new System.Drawing.Size(601, 641); this.dgTasks.Size = new System.Drawing.Size(601, 629);
this.dgTasks.TabIndex = 1; this.dgTasks.TabIndex = 3;
// //
// Title // Title
// //
...@@ -224,49 +275,31 @@ ...@@ -224,49 +275,31 @@
this.Column2.Name = "Column2"; this.Column2.Name = "Column2";
this.Column2.ReadOnly = true; this.Column2.ReadOnly = true;
// //
// groupBox2 // label5
// //
this.groupBox2.Controls.Add(this.tbxTemplateFileName2); this.label5.AutoSize = true;
this.groupBox2.Controls.Add(this.tbxTemplateFileName); this.label5.Location = new System.Drawing.Point(15, 69);
this.groupBox2.Controls.Add(this.btnGenerateXlsx); this.label5.Name = "label5";
this.groupBox2.Controls.Add(this.btnSelectTemplateFile2); this.label5.Size = new System.Drawing.Size(59, 12);
this.groupBox2.Controls.Add(this.btnSelectTemplateFile); this.label5.TabIndex = 1;
this.groupBox2.Controls.Add(this.label4); this.label5.Text = "选择模板3";
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 // btnSelectTemplateFile3
// //
this.label4.AutoSize = true; this.btnSelectTemplateFile3.Location = new System.Drawing.Point(253, 65);
this.label4.Location = new System.Drawing.Point(15, 54); this.btnSelectTemplateFile3.Name = "btnSelectTemplateFile3";
this.label4.Name = "label4"; this.btnSelectTemplateFile3.Size = new System.Drawing.Size(50, 23);
this.label4.Size = new System.Drawing.Size(59, 12); this.btnSelectTemplateFile3.TabIndex = 0;
this.label4.TabIndex = 1; this.btnSelectTemplateFile3.Text = "...";
this.label4.Text = "选择模板2"; this.btnSelectTemplateFile3.UseVisualStyleBackColor = true;
this.btnSelectTemplateFile3.Click += new System.EventHandler(this.btnSelectTemplateFile3_Click);
// //
// btnSelectTemplateFile2 // tbxTemplateFileName3
//
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.tbxTemplateFileName3.Location = new System.Drawing.Point(85, 66);
// this.tbxTemplateFileName3.Name = "tbxTemplateFileName3";
this.tbxTemplateFileName2.Location = new System.Drawing.Point(85, 51); this.tbxTemplateFileName3.Size = new System.Drawing.Size(162, 21);
this.tbxTemplateFileName2.Name = "tbxTemplateFileName2"; this.tbxTemplateFileName3.TabIndex = 2;
this.tbxTemplateFileName2.Size = new System.Drawing.Size(162, 21);
this.tbxTemplateFileName2.TabIndex = 2;
// //
// FrmMain // FrmMain
// //
...@@ -282,9 +315,10 @@ ...@@ -282,9 +315,10 @@
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.panel2.PerformLayout();
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);
} }
...@@ -303,16 +337,19 @@ ...@@ -303,16 +337,19 @@
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PropertyGrid pgResult; private System.Windows.Forms.PropertyGrid pgResult;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblSpendTime;
private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox tbxTemplateFileName2;
private System.Windows.Forms.Button btnSelectTemplateFile2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.DataGridView dgTasks; private System.Windows.Forms.DataGridView dgTasks;
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.Label lblSpendTime;
private System.Windows.Forms.Button btnSelectTemplateFile2; private System.Windows.Forms.TextBox tbxTemplateFileName3;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Button btnSelectTemplateFile3;
private System.Windows.Forms.Label label5;
} }
} }
...@@ -17,7 +17,9 @@ namespace Kivii.Client.OfficeSample ...@@ -17,7 +17,9 @@ namespace Kivii.Client.OfficeSample
} }
private void FrmMain_Load(object sender, EventArgs e) private void FrmMain_Load(object sender, EventArgs e)
{ {
tbxTemplateFileName.Text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "附页模板.xlsx"); tbxTemplateFileName.Text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "首页模板.xlsx");
tbxTemplateFileName2.Text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "附页模板.xlsx");
tbxTemplateFileName3.Text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "报告底页.xlsx");
dgTasks.AutoGenerateColumns = false; dgTasks.AutoGenerateColumns = false;
} }
private void btnGetReport_Click(object sender, EventArgs e) private void btnGetReport_Click(object sender, EventArgs e)
...@@ -74,8 +76,15 @@ namespace Kivii.Client.OfficeSample ...@@ -74,8 +76,15 @@ namespace Kivii.Client.OfficeSample
template2.Bind("task", _tasks); template2.Bind("task", _tasks);
var rtns2 = template2.Fill();//填充模板 var rtns2 = template2.Fill();//填充模板
var template3 = new TemplateExcel();
template3.Open(tbxTemplateFileName3.Text);//打开模板文件
template3.Bind("contract", _contract);//将数据绑定到模板中,注意contract在模板中这是这个变量名了
template3.Bind("task", _tasks);
var rtns3 = template3.Fill();//填充模板
//合并两个模板 //合并两个模板
template.Contact(template2.Package); template.Contact(template2.Package);
template.Contact(template3.Package);
template.SaveAs(saveFileName);//最后另存当前的文件 template.SaveAs(saveFileName);//最后另存当前的文件
watch.Stop(); watch.Stop();
...@@ -89,5 +98,13 @@ namespace Kivii.Client.OfficeSample ...@@ -89,5 +98,13 @@ namespace Kivii.Client.OfficeSample
if (ofd.ShowDialog() != DialogResult.OK) return; if (ofd.ShowDialog() != DialogResult.OK) return;
tbxTemplateFileName2.Text = ofd.FileName; tbxTemplateFileName2.Text = ofd.FileName;
} }
private void btnSelectTemplateFile3_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Excel模板文件|*.xlsx";
if (ofd.ShowDialog() != DialogResult.OK) return;
tbxTemplateFileName3.Text = ofd.FileName;
}
} }
} }
...@@ -85,6 +85,9 @@ ...@@ -85,6 +85,9 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<None Include="报告底页.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="附页模板.xlsx"> <None Include="附页模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment