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

推荐订阅源

GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
F
Full Disclosure
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
NISL@THU
NISL@THU
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Privacy International News Feed
Latest news
Latest news
C
CERT Recently Published Vulnerability Notes
P
Privacy & Cybersecurity Law Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
T
Tor Project blog
A
About on SuperTechFans
博客园 - 司徒正美
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LINUX DO - 热门话题
Know Your Adversary
Know Your Adversary
T
Tenable Blog
K
Kaspersky official blog
Simon Willison's Weblog
Simon Willison's Weblog
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
Cisco Talos Blog
Cisco Talos Blog
U
Unit 42
T
The Blog of Author Tim Ferriss
T
Threatpost
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
P
Palo Alto Networks Blog

博客园 - David

TFS Server 不存在时,如何去除对应Server的Workspaces 更改已有程序集中的资源 记录:如何删除TFS Project SQL – TRUNCATE vs DELETE SQL – Character data (varchar) 又好久没写东西了! Powershell: Send mail with attachment 【Update】 - David SSIS: Execute SSIS Package in command prompt 【Update】 随感 Windows Workflow Foundation 了解 通过代码将Word 2007 template (dotx)文档转换Word 2007 (docx)文档(续) 通过代码将Word 2007 template (dotx)文档转换Word 2007 (docx)文档 创建Word2007文档而无需安装Word2007 Visual WebGUI - 如何处理MessageBox的DialogResult值 Visual WebGUI - 如何将Dialog的结果传回主窗体 Visual WebGUI 在 Vista IIS 7 中的配置 项目管理片语 - Schedule 在IIS 7设置ASP.NET 1.1(在Vista中使用VS2003) 给儿子的歌!
Visual WebGUI Report - 导出到PDF
David · 2008-01-03 · via 博客园 - David

      在Visual WebGUI处理Report的导出问题,跟在WebForm中的做法真不一样,还真头疼了一阵。但是在Visual WebGUI的论坛里找到了解决方法。一样是用 HttpResponse 来解决,但是Visual WebGUI中需要有它自己的方法才行,不然,最后导出只是在页面上显示的一大堆乱码而已。

       这是论坛中介绍解决方法的链接:Visual WebGUI Forum

       下面来段摘抄(位于上面的链接的最后一个Post)吧,Open-mouthed。这个例子用的Visual Studio自带的Report控件rdlc,大家将就着看吧。Tongue out

        The form which tries to open the pdf file must be a gizmox gateway control ("IGatewayControl") so it will handle the file writing response disconected from WebGUI's main response. In order to solve your problem, implement the Gizmox.WebGUI.Common.Interfaces.IGatewayControl interface as follow:

public class Form1 : Form, IGatewayControl
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Link.Open(new GatewayReference(this, "open"));
        }

        #region IGatewayControl Members

        public IGatewayHandler GetGatewayHandler(IContext objContext, string strAction)
        {
            LocalReport local = new LocalReport();
            local.ReportPath = Context.Server.MapPath("~/Report1.rdlc");

            DataSet1 dataSet = new DataSet1();
            DataSet1TableAdapters.Tabla1TableAdapter Adapter = new WebGUIApplication1.DataSet1TableAdapters.Tabla1TableAdapter();
            Adapter.Fill(dataSet.Tabla1);
            ReportDataSource dataSource = new ReportDataSource("DataSet1_Tabla1", dataSet.Tabla1);
            local.DataSources.Add(dataSource);

            string reportType = "PDF";
            string mimeType = "application/pdf";
            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx

            string deviceInfo =
            "<DeviceInfo>" +
            "  <OutputFormat>PDF</OutputFormat>" +
            "  <PageWidth>8.5in</PageWidth>" +
            "  <PageHeight>11in</PageHeight>" +
            "  <MarginTop>0.5in</MarginTop>" +
            "  <MarginLeft>1in</MarginLeft>" +
            "  <MarginRight>1in</MarginRight>" +
            "  <MarginBottom>0.5in</MarginBottom>" +
            "</DeviceInfo>";

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            //Render the report
            renderedBytes = local.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            //Clear the response stream and write the bytes to the outputstream
            //Set content-disposition to "attachment" so that user is prompted to take an action
            //on the file (open or save)

            HttpResponse objResponse = this.Context.HttpContext.Response;

            objResponse.Clear();
            objResponse.ClearHeaders();
            objResponse.ContentType = mimeType;
            objResponse.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
            objResponse.BinaryWrite(renderedBytes);
            objResponse.Flush();
            objResponse.End();

          
            return null;
        }

        #endregion
    }