Commit 17a739a7 by 施晓雨

三个模板合并

parent 5bc5b244
......@@ -17,7 +17,9 @@ namespace Kivii.Client.OfficeSample
}
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;
}
private void btnGetReport_Click(object sender, EventArgs e)
......@@ -74,8 +76,15 @@ namespace Kivii.Client.OfficeSample
template2.Bind("task", _tasks);
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(template3.Package);
template.SaveAs(saveFileName);//最后另存当前的文件
watch.Stop();
......@@ -89,5 +98,13 @@ namespace Kivii.Client.OfficeSample
if (ofd.ShowDialog() != DialogResult.OK) return;
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 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="报告底页.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="附页模板.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</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