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

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
小众软件
小众软件
美团技术团队
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
D
Docker
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
B
Blog
雷峰网
雷峰网
The Cloudflare Blog

博客园 - wngwz

单点登陆 - wngwz - 博客园 IP地址 - wngwz - 博客园 金额转换.小To大 - wngwz - 博客园 简,繁体转换工具. 弹出模态窗体,关闭后。重新绑定页面(这个仅仅是对粗心大意的纪录) - wngwz - 博客园 分页存储过程 关于水晶报表的版本问题! 大年30祝大家, 不知道说还要GMail的油箱! 打印的一些知识! 求助!水晶报表! 收获!关于引用计数器! 把文件或图片存在数据库中! 水晶报表倒出! 关于(学习!Excel)的问题。 解决问题总结 水晶报表操作中遇到的问题 javascript 打印报表! javascript 学习
解决把水晶报表下载到客户端过程中,出现下载整个页面(.aspx)...
wngwz · 2004-11-23 · via 博客园 - wngwz

private void btnOutForWord_Click( object sender, System.EventArgs e )
        
{
            
if ( Session["reportname"!= null && Session[Session["reportname"].ToString()] != null )
            
{
                ReportDocument oRpt 
= new ReportDocument();
                oRpt 
= ( ReportDocument )Session[Session["reportname"].ToString()];
                crvMain.ReportSource 
= oRpt;    

                
//设置导出选项。
                ExportOptions myExp = new ExportOptions();

                myExp.ExportFormatType 
= ExportFormatType.WordForWindows;        //导出到Word格式
                
//myExp.ExportFormatType = ExportFormatType.Excel;                //导出到Excel格式
        
                
//myExp.ExportFormatType = ExportFormatType.PortableDocFormat;    //导出到Pdf格式

                
//定义导出内容
                ExportRequestContext myExpReq = new ExportRequestContext();
                myExpReq.ExportInfo 
= myExp;

                
//产生报表Stream
                Stream myReportStream;
                myReportStream 
= oRpt.FormatEngine.ExportToStream(myExpReq);
                Response.ClearHeaders();
                Response.ClearContent();

                Response.ContentType 
= "application/msword";
                Response.AddHeader(
"Content-disposition","attachment; filename=" + DateTime.Now.ToString("yyyyMMddhhssmm"+ ".doc");

                
//Response.ContentType = "application/vnd.ms-excel";
                
//Response.AddHeader("Content-disposition","attachment; filename=" + year.ToString() + "." + month.ToString() + ".xls");

                
//Response.ContentType = "application/pdf";
                
//Response.AddHeader("Content-disposition","attachment; filename=" + year.ToString() + "." + month.ToString() + ".pdf");

                
byte[] myReportByte = new byte[myReportStream.Length];
                myReportStream.Read( myReportByte,
0,(int)myReportStream.Length );
                Response.BinaryWrite( myReportByte );
                Response.Flush();
                Response.End();
            }

        }