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

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - wngwz

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

在做打印时,经常需要把要打印的页面展现给客户端浏览,如果客户还需要倒出(例如倒出到Word文档),则我们可以使用水晶报表自代的倒出的功能完成。

        private void btnout_Click(object sender, System.EventArgs e)
        
{
            
///<value>它这里的倒出使用的是水晶报表自己的倒出属性</value>
            if (Session["reportname"]!=null && Session[lblName.Text]!=null )
            
{
                ReportDocument MyReport
=new ReportDocument();
                MyReport 
= (ReportDocument)Session[lblName.Text];
                crvMain.ReportSource
=MyReport;    
                String Pathdoc
=Server.MapPath(Request.ApplicationPath);
                
string FileName=Pathdoc+"\Common\打印报表.doc";

                
///<value>DiskFileDestinationOptions  提供属性 以便设置倒出到磁盘时的文件名</value>
                DiskFileDestinationOptions mydesc=new DiskFileDestinationOptions();

                
///<value>DiskFileName 获取或设置数据库表的位置</value>
                mydesc.DiskFileName=Pathdoc+"\Common\打印报表.doc"

                
///<value>提供属性 以便检索和设置用于倒出报表的选项</value>
                ExportOptions exportOpts=MyReport.ExportOptions;

                
///<value>ExportDestinationType 获取或设置倒出目标的类型</value>
                exportOpts.ExportDestinationType=ExportDestinationType.DiskFile;

                
///<value></value>
                exportOpts.DestinationOptions=mydesc;

                
///</value>获取或设置倒出格式类型</value>
                exportOpts.ExportFormatType= ExportFormatType.WordForWindows;

                
///<value>将报表倒出到在ExportOptions对象内指定的格式和目标</value>
                MyReport.Export();

                
//读WORD文件下载
                FileInfo byteinfile=new FileInfo(FileName);
                instream
=byteinfile.OpenRead();
                FileStream f 
= File.OpenRead(FileName);
                
byte[] b = new byte[instream.Length];
                f.Read(b,
0,b.Length);
                instream.Close();
                HttpResponse rps
=Page.Response;
                rps.ContentEncoding 
= System.Text.Encoding.GetEncoding("GB2312");
                rps.Charset 
= "utf-8";
                rps.BufferOutput
=false;
                rps.ContentType
="application/doc";
                FileName 
= HttpUtility.UrlEncode(FileName).Replace("+""%20");
                rps.AppendHeader(
"Content-Disposition""attachment;FileName="+FileName);
                rps.BinaryWrite(b);                    
                rps.Close();
                rps.End();
            }

        }

这是一个自己在项目中得例子。希望对用得到的朋友有所帮助!