aspx导出文件
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导出文件的更多相关文章
- ajax请求和aspx返回数据
ajax请求: $(function () { $.ajax({ url: "index.aspx?method=send", ...
- 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 ...
- 多页的TIFF图片在aspx页面分页显示
一.逻辑实现:将数据库中的二进制TIFF图片读出并分页显示在页面上. 1.显示界面 public FrameDimension MyGuid; ; ; public static MemoryStre ...
- XP安装IIS来加载aspx页面(Web调用SAP数据)
1,安装IIS 在XP中安装IIS方法很简单,安装时需要提供安装光盘来加载I386文件,可以使用虚拟光驱或光盘.在此做个简单说明(控制面板-添加/删除 Windows组件-勾选Internet信息服务 ...
- 仅用aspx文件实现Ajax调用后台cs程序。(实例)
仅用aspx文件实现Ajax调用后台cs无刷新程序.(实例) 两个文件:aaa.aspx 和aaa.aspx.cs 一.aaa.aspx <script type="text/java ...
- http://www.microsoft.com/en-pk/download/details.aspx?id=40762
http://www.microsoft.com/en-pk/download/details.aspx?id=40762
- JavaFx导出文件
导出文件格式可选 protected void handExportDateAction(ActionEvent event) { // ShowDialog.showConfirmDialog(FX ...
- 在一个aspx或ashx页面里进行多次ajax调用
在用ajax开发asp.net程序里.利用ashx页面与前台页面进行数据交互.但是每个ajax交互都需要一个ashx页面.结果是项目里一大堆ashx页面.使项目难以管理.现在我们就想办法让一个ashx ...
- Aspx页面模拟WebService功能
在后台引入 using System.Web.Services 命名空间 然后在编写web服务方法: [WebMethod] public static string GetData(string t ...
随机推荐
- c++官方文档-命名空间
#include<stdio.h> #include<iostream> #include<queue> #include<map> #include& ...
- 马尔可夫毯(Markov Blanket)
马尔可夫毯(Markov Blanket) 最近接触到马尔可夫毯(MarkovBlanket)这个概念,发现网上资料不多,通俗易懂的解释甚少,查了一些资料后,决定写一个总结. 提到马尔可夫毯,就会有一 ...
- 【RabbitMQ】ubuntu下RabbitMQ安装与简单使用
参考:https://blog.csdn.net/the_fool_/article/details/80570971 1.安装: https://blog.csdn.net/a295277302/a ...
- leetcode976
public class Solution { public int LargestPerimeter(int[] A) { var list = A.OrderByDescending(x => ...
- spring Cloud 定时任务 @Scheduled
本文主要记录:如何使用spring的@Scheduled注解实现定时作业,基于spring cloud 1)pom.xml 文件引入相关依赖.spring-maven插件 <?xml versi ...
- The type org.springframework.dao.support.DaoSupport cannot be resolved. It is indirectly referenced
springmvc mybatis整合,遇到错误:The type org.springframework.dao.support.DaoSupport cannot be resolved. It ...
- cnapckSurround c++builder Region 代码折叠快捷键
C++Builder代码折叠 cnapckSurround c++builder Region 代码折叠快捷键,可以导入导出,IDE code edit,cnpack menu surround wi ...
- Git----分支管理之解决冲突03
人生不如意之事十之八九,合并分支往往也不是一帆风顺. 准备新的feature1分支,继续我们的新分支开发: $ git checkout -b feature1Switched to a new br ...
- memcache命令
Command Description Example get 读取键值 get mykey set 设置新键值 set mykey 0 60 5 add 新增键值 add newkey 0 60 5 ...
- Jena TDB Assembler
TDB Assembler Assemblers (装配器) 是Jena中用于描述将要构建的对象(通常是模型和数据集 models & datasets)的一种通用机制.例如, Fuseki ...