惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - 寒天飞雪

项目中用到Excel上传到Sql数据库 转载: 房贷的两种还款方式介绍 RFC访问SAP(C#) VB.net连接SAP实例(vb.net写法) VB.net连接SAP实例 - 寒天飞雪 - 博客园 Winform 树型菜单例子 - 寒天飞雪 - 博客园 介绍: MRP和MPS 收藏: SQLServer的存储结构 转载: 正则表达式介绍 .net 连接ORACLE 数据库的例子 - 寒天飞雪 C#调用iTextSharp组件生成PDF文件, 在VS2005下已经调试通过! SQLSERVER 2005 BI的帮助文档说明: 9.2 定义和浏览翻译 9.1 定义和浏览透视 8.1 定义操作 7.1 定义关键指标KPI 6.3使用脚本命令定义作用域分配 6.2 定义命名集 6.1 定义计算成员
转载: ReportViewer : RDLC自定义工具栏
寒天飞雪 · 2008-07-01 · via 博客园 - 寒天飞雪

RDLC自定义工具栏:

既然我们使用这种方法进行报表的打印,那么Visual Studio的控件ReportViewer的工具栏就不再符合我们的要求了。因为这个报表浏览器的工具栏上的按钮虽然可以设置属性显示或隐藏其中的一部分,但是我们却不能自己往这个工具栏上添加按钮(显然,我们需要实现自己的页面设置、预览和打印按钮),在这一点上,建议Microsoft将工具栏和报表浏览器分离,应该做得和BindingNavigator那样就好了。

        我们先设置ReportViewer控件的ShowToolBar方法为false,然后在ReportViewer控件纸上添加除页面设置、预览、打印外的应该有的按钮,像刷新、终止、导出、缩放、搜索、导航等,这些按钮的Click事件定义如下:

        /// <summary>
        
/// 获取当前时间组成的字符串,用作生成不会重复的文件名
        
/// </summary>
        
/// <returns></returns>

        private string GetTimeStamp()
        
{
            
string strRet = string.Empty;
            System.DateTime dtNow 
= Pub.DateTimeEx.ServerTime;
            strRet 
+=   dtNow.Year.ToString() +
                        dtNow.Month.ToString(
"00"+
                        dtNow.Day.ToString(
"00"+
                        dtNow.Hour.ToString(
"00"+
                        dtNow.Minute.ToString(
"00"+
                        dtNow.Second.ToString(
"00"+
                        System.DateTime.Now.Millisecond.ToString(
"000");
            
return strRet;

        }


        
/// <summary>
        
/// 导出到Excel
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void toolExcel_Click(object sender, EventArgs e)
        
{

            Microsoft.Reporting.WinForms.Warning[] Warnings;
            
string[] strStreamIds;
            
string strMimeType;
            
string strEncoding;
            
string strFileNameExtension;

            
byte[] bytes = this.rptViewer.LocalReport.Render("Excel"nullout strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings);

            
string strFilePath = @"D:\" + this.GetTimeStamp() + ".xls";

            
using (System.IO.FileStream fs = new FileStream(strFilePath, FileMode.Create))
            
{
                fs.Write(bytes, 
0, bytes.Length);
            }


            
if (Pub.WinForm.Msg.Question("报表打印: \r\n    成功导出Excel文件!" + strFilePath + "\r\n    要现在打开文件" + strFilePath + "吗?"== DialogResult.Yes)
            
{
                System.Diagnostics.Process.Start(strFilePath);
            }


        }


        
/// <summary>
        
/// 刷新报表数据
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool刷新_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.RefreshReport();
        }


        
/// <summary>
        
/// 在加载报表数据时终止报表数据的加载
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool终止_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.CancelRendering(0);
        }


        
/// <summary>
        
/// 从DrillThrough报表返回到导航页面
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool返回_Click(object sender, EventArgs e)
        
{
            
if (this.rptViewer.LocalReport.IsDrillthroughReport)
                
this.rptViewer.PerformBack();
        }


        
/// <summary>
        
/// 回到报表的第一页
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool第一页_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.CurrentPage = 1;
        }


        
/// <summary>
        
/// 跳转到报表的最后一页
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool最后一页_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.CurrentPage = this.rptViewer.LocalReport.GetTotalPages();
        }


        
/// <summary>
        
/// 以25%的比例显示报表
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool25_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.Percent;
            
this.rptViewer.ZoomPercent = 25;
        }


        
/// <summary>
        
/// 以50%的比例显示报表
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool50_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.Percent;
            
this.rptViewer.ZoomPercent = 50;
        }


        
/// <summary>
        
/// 以100%的比例显示报表
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool100_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.Percent;
            
this.rptViewer.ZoomPercent = 100;
        }


        
/// <summary>
        
/// 以200%的比例显示报表
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool200_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.Percent;
            
this.rptViewer.ZoomPercent = 200;
        }


        
/// <summary>
        
/// 以400%的比例显示报表
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool400_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.Percent;
            
this.rptViewer.ZoomPercent = 400;
        }


        
/// <summary>
        
/// 将缩放模式设置为整页
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool整页_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.FullPage;
        }


        
/// <summary>
        
/// 将缩放模式设置为页宽
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool页宽_Click(object sender, EventArgs e)
        
{
            
this.rptViewer.ZoomMode = ZoomMode.PageWidth;
        }


        
/// <summary>
        
/// 在报表中搜索txtSearch中的字符
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool搜索_Click(object sender, EventArgs e)
        
{
            
if (this.txtSearch.Text.Trim() == string.Empty)
                
return;

            
this.rptViewer.Find(this.txtSearch.Text.Trim(), 1);
        }


        
/// <summary>
        
/// 搜索报表中下一处txtSearch中的字符
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool搜索下一个_Click(object sender, EventArgs e)
        
{
            
if (this.txtSearch.Text.Trim() == string.Empty)
                
return;

            
this.rptViewer.FindNext();
        }


        
/// <summary>
        
/// 跳转到上一页
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool上一页_Click(object sender, EventArgs e)
        
{
            
if (this.rptViewer.CurrentPage != 1)
                
this.rptViewer.CurrentPage--;
        }


        
/// <summary>
        
/// 跳转到下一页
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool下一页_Click(object sender, EventArgs e)
        
{
            
if (this.rptViewer.CurrentPage != this.rptViewer.LocalReport.GetTotalPages())
                
this.rptViewer.CurrentPage++;
        }


        
/// <summary>
        
/// 跳转到由txt跳转中指定的页数
        
/// </summary>
        
/// <param name="sender"></param>
        
/// <param name="e"></param>

        private void tool跳转_Click(object sender, EventArgs e)
        
{
            
if (this.txt跳转.Text.Trim() == string.Empty)
                
return;

            
int intJump = 0;

            
if (System.Int32.TryParse(this.txt跳转.Text.Trim(), out intJump))
                
if (intJump <= this.rptViewer.LocalReport.GetTotalPages())
                    
this.rptViewer.CurrentPage = intJump;

        }

未完...