VSTO 学习笔记(六)在 Excel 2010中使用RDLC报表
2015-06-16 10:00
330 查看
原文:VSTO 学习笔记(六)在 Excel 2010中使用RDLC报表Excel具有强大的图表显示、分析功能,这点毋庸置疑,但是如果将常规MIS系统中的数据以报表的形式在Excel中显示,却并不那么容易。在VSTO中,我们可以借助RDLC报表组件来满足这种需求。
示例代码下载
本系列所有示例代码均在 Visual Studio 2010 Ultimate RTM + Office 2010 Professional Plus Beta x64 下测试通过
注:本次数据库使用的是 SQL Server 2008 R2 x64 RTM
1、在VS2010中,新建一个Excel 2010 Workbook项目:
代码
private void Sheet1_Startup(object sender, System.EventArgs e)
{
this.fnDataIni();
this.fnBuildDataSource(this.comCountry.Text);
}
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.comCountry.SelectedIndexChanged += new System.EventHandler(this.comCountry_SelectedIndexChanged);
this.Startup += new System.EventHandler(this.Sheet1_Startup);
this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);
}
#endregion
private void comCountry_SelectedIndexChanged(object sender, EventArgs e)
{
this.rptExcel.LocalReport.DataSources.Clear();
this.fnBuildDataSource(this.comCountry.Text);
}
10、最终运行效果:
11、生产的Excel位于Debug/Release下:
小结:
本次我们在VSTO中做了一个简单的报表,使用了Linq to SQL,当然,如果能用Excel的原生功能做报表效果更好,使用VSTO可以大大简化实现相同功能的方法,使得我们可以用更熟悉的方法来完成一些需求。
示例代码下载
本系列所有示例代码均在 Visual Studio 2010 Ultimate RTM + Office 2010 Professional Plus Beta x64 下测试通过
注:本次数据库使用的是 SQL Server 2008 R2 x64 RTM
1、在VS2010中,新建一个Excel 2010 Workbook项目:
代码
private void Sheet1_Startup(object sender, System.EventArgs e)
{
this.fnDataIni();
this.fnBuildDataSource(this.comCountry.Text);
}
private void Sheet1_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.comCountry.SelectedIndexChanged += new System.EventHandler(this.comCountry_SelectedIndexChanged);
this.Startup += new System.EventHandler(this.Sheet1_Startup);
this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);
}
#endregion
private void comCountry_SelectedIndexChanged(object sender, EventArgs e)
{
this.rptExcel.LocalReport.DataSources.Clear();
this.fnBuildDataSource(this.comCountry.Text);
}
10、最终运行效果:
11、生产的Excel位于Debug/Release下:
小结:
本次我们在VSTO中做了一个简单的报表,使用了Linq to SQL,当然,如果能用Excel的原生功能做报表效果更好,使用VSTO可以大大简化实现相同功能的方法,使得我们可以用更熟悉的方法来完成一些需求。
相关文章推荐
- 构造方法中使用this的含义
- 内存泄露情况
- IOS设计模式之二(门面模式,装饰器模式)
- 为VMCEPC增加HIVE-Based注册表
- ubuntu14.04下配置使用openCV3.0
- iOS开发工具——网络封包分析工具Charles
- 滑动返回上一层级
- Android CircleMenu 圆形旋转菜单
- 浙江大学PAT_甲级_1031. Hello World for U (20)
- 再探java基础——throw与throws
- 游戏感:虚拟感觉的游戏设计师指南——第九章 润色的测量方法
- struts2中的constant配置详解
- 一例千万级pv高性能高并发网站架构
- ORACLE
- VSTO学习笔记(五)批量编辑Excel 2010 x64
- 11-2实战混合模式合成图像
- IOS设计模式之一(MVC模式,单例模式)
- 获得Properties文件的内容
- C++ - C++0x/C++11 Support in GCC
- 游戏感:虚拟感觉的游戏设计师指南——第八章 环境的测量方法