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

推荐订阅源

Y
Y Combinator Blog
有赞技术团队
有赞技术团队
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
The Cloudflare Blog
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
MyScale Blog
MyScale Blog
博客园_首页
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
罗磊的独立博客

博客园 - Michael.li

excel中使用sum函数计算包含小数列,结果出现多位小数值 使用 SqlBulkCopy 向 destinationTableName 表插入数据 使用Wireshark抓包QQ聊天用户IP地址 MSSQL数据库设计心得 Html5大文件断点续传 c# 使用protobuf格式操作 Redis Web网站架构设计 extjs中的tabpanle下的combobox提交问题 Asp.net下from认证统一认证配置 Extjs 4.07 对类型定义引发的匹配问题 Supesoft权限管理系统(FrameWork) 1.0.9 Release 手机6120C 玩仙剑dos版 ASP.NET权限管理系统(FrameWork) 1.0.8 Release ASP.NET权限管理系统(FrameWork) 1.0.7 Release 广告统计分析系统(ADCount) 1.0.0 Beta DDBuildTools 1.3.0 Release发布 ASP.NET权限管理系统(FrameWork) 1.0.6 Release remoting缓存设计总结 - Michael.li - 博客园 ASP.NET权限管理系统(FrameWork) 1.0.5 Release
关于在Page_Load定义外部变量输出 - Michael.li - 博客园
Michael.li · 2008-12-27 · via 博客园 - Michael.li

string cmd = (string)Common.sink("cmd", MethodType.Get, 255, 0, DataType.Str);      

  protected void Page_Load(object sender, EventArgs e)
        {

            if (cmd == "DownLoad")
            {
                DownXslFile();
            }

        }

/// <summary>
        /// 导出Excel文档
        /// </summary>
        protected void DownXslFile()
        {


            System.IO.StringWriter sw = new System.IO.StringWriter();

            Server.Execute("report.aspx?cmd=ssss", sw, false);
            string abcd = sw.ToString();
            string fileName = "考勤报表_" + DateTime.Now.Date.ToString("yyyyMMdd") + ".xls";

            //Response.Headers.Clear();
            Response.Clear();
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName));
            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "application/ms-excel";
            Response.Write(abcd.ToString());
            Response.End();
        }

 发现生成的文件内容为空.

后来将string cmd = (string)Common.sink("cmd", MethodType.Get, 255, 0, DataType.Str);      放入page_load方法中才成功.

如下:

  protected void Page_Load(object sender, EventArgs e)
        {

          string cmd = (string)Common.sink("cmd", MethodType.Get, 255, 0, DataType.Str);      

            if (cmd == "DownLoad")
            {
                DownXslFile();
            }

        }