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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
腾讯CDC
T
Tailwind CSS Blog
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
The Cloudflare Blog
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
B
Blog
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - 司徒正美
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - 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();
            }

        }