System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// reptype.RenderControl(htw);//reptype为要导出的对象,当前是reptype,如果是DataGrid,DataList等都可以
Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Response.ContentType";//Response.ContentType是输出流的 HTTP MIME 类型
//Response.ContentType --- word文件
//application/vnd.ms-excel --- excel文件
Response.Charset = "utf-8";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("试卷", System.Text.Encoding.UTF8) + ".doc");
//attachment --- 作为附件下载
//inline --- 在线打开
//filename如果是中文,则可以用HttpUtility.UrlEncode(fileName,System.Text.Encoding.UTF8)进行进行编码,以解决文件名乱码的问题

Response.Write("aa"+"\n"+"sd");
Response.Flush();
Response.Close();

aspx导出文件的更多相关文章

  1. ajax请求和aspx返回数据

    ajax请求: $(function () {            $.ajax({                url: "index.aspx?method=send",  ...

  2. Atitit.java c#.net php项目中的view复用(jsp,aspx,php的复用)

    Atitit.java c#.net php项目中的view复用(jsp,aspx,php的复用) 1.1. Keyword1 1.2. 前言1 2. Java项目使用.Net的aspx页面view1 ...

  3. 多页的TIFF图片在aspx页面分页显示

    一.逻辑实现:将数据库中的二进制TIFF图片读出并分页显示在页面上. 1.显示界面 public FrameDimension MyGuid; ; ; public static MemoryStre ...

  4. XP安装IIS来加载aspx页面(Web调用SAP数据)

    1,安装IIS 在XP中安装IIS方法很简单,安装时需要提供安装光盘来加载I386文件,可以使用虚拟光驱或光盘.在此做个简单说明(控制面板-添加/删除 Windows组件-勾选Internet信息服务 ...

  5. 仅用aspx文件实现Ajax调用后台cs程序。(实例)

    仅用aspx文件实现Ajax调用后台cs无刷新程序.(实例) 两个文件:aaa.aspx 和aaa.aspx.cs 一.aaa.aspx <script type="text/java ...

  6. http://www.microsoft.com/en-pk/download/details.aspx?id=40762

    http://www.microsoft.com/en-pk/download/details.aspx?id=40762

  7. JavaFx导出文件

    导出文件格式可选 protected void handExportDateAction(ActionEvent event) { // ShowDialog.showConfirmDialog(FX ...

  8. 在一个aspx或ashx页面里进行多次ajax调用

    在用ajax开发asp.net程序里.利用ashx页面与前台页面进行数据交互.但是每个ajax交互都需要一个ashx页面.结果是项目里一大堆ashx页面.使项目难以管理.现在我们就想办法让一个ashx ...

  9. Aspx页面模拟WebService功能

    在后台引入 using System.Web.Services 命名空间 然后在编写web服务方法: [WebMethod] public static string GetData(string t ...

随机推荐

  1. mysql开启查询日志功能

    1.开启查询日志  https://www.cnblogs.com/kerrycode/p/7130403.html MYsql 查询日志配置    mysql> show variables ...

  2. testng报告发邮件后css样式缺失问题

    问题:用reportng把代替testng报告后,邮件中不显示html样式 解决方案:把依赖的文件,加到邮件附件 Jenkins发邮件的时候,把依赖文件作为附件发送. 结果看到样式了:

  3. jsp 回车代替tab 自动切换text焦点

    方法一keyCode (IE11以后失效) <html> <head> <meta http-equiv="Content-Type" content ...

  4. J2SE 8的输入输出--缓冲

    FileChannel带缓冲 //1. read the point location FileChannel channelRead = FileChannel.open(Paths.get(&qu ...

  5. AS3获取对象类名,getDefinitionByName,getQualifiedClassName,getQualifiedSuperclassName

    首先先告诉大家,我要讲的是flash.utils包中的getDefinitionByName,getQualifiedClassName,getQualifiedSuperclassName可能帮助文 ...

  6. Gearman安装及使用

    基础安装包 yum install vim wget gcc gcc-c++ make dos2unix gperf libevent libevent-devel zlib-devel bzip2- ...

  7. (一)由浅入深学习springboot中使用redis

    很多时候,我们会在springboot中配置redis,但是就那么几个配置就配好了,没办法知道为什么,这里就详细的讲解一下 这里假设已经成功创建了一个springboot项目. redis连接工厂类 ...

  8. one by one 项目 part 1

    今天安装MySQL,我的系统是win8.1,安装包是mysql-5.7.17-winx64.zip,遇到了不少问题,特在此总结,希望能帮到遇到同样情况的人. 1.前面按照网上教程,先解压,然后在cmd ...

  9. 利用简单的参数传递来实现单条查询的easyui-datagrid

    前一阵子老师给出了一个题目, 说让设计个表格, 学生系统的, 可以查询学生的信息和成绩, 科目自己定, 数据库建表也自己定. 数据库的建表可是建的相当的简陋, 反正老师不是很满意, 后来数据表格做出来 ...

  10. 85. Maximal Rectangle (Graph; Stack, DP)

    Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...