Asp.Net页面输出到EXCE

2016-01-29 13:35 7 1 收藏

Asp.Net页面输出到EXCE,Asp.Net页面输出到EXCE

【 tulaoshi.com - ASP.NET 】

利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM等类型的文档很容易的。主要分为三步来完成。 



一、定义文档类型、字符编码   



   Response.Clear(); 
   Response.Buffer= true; 
   Response.Charset="utf-8";  



   //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开 
   //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm   



   Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls"); 
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");   
   //Response.ContentType指定文件类型 可以为application/ms-excel    application/ms-word    application/ms-txt    application/ms-html    或其他浏览器可直接支持文档 
   Response.ContentType = "application/ms-excel"; 
   this.EnableViewState = false;   
利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM等类型的文档很容易的。主要分为三步来完成。 



一、定义文档类型、字符编码   



   Response.Clear(); 
   Response.Buffer= true; 
   Response.Charset="utf-8";  



   //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开 
   //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm   



   Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls"); 
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");   
   //Response.ContentType指定文件类型 可以为application/ms-excel    application/ms-word    application/ms-txt    application/ms-html    或其他浏览器可直接支持文档 
   Response.ContentType = "application/ms-excel"; 
   this.EnableViewState = false;   
利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM等类型的文档很容易的。主要分为三步来完成。 



一、定义文档类型、字符编码   



   Response.Clear(); 
   Response.Buffer= true; 
   Response.Charset="utf-8";  



   //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开 
   //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm   



   Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls"); 
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");   
   //Response.ContentType指定文件类型 可以为application/ms-excel    application/ms-word    application/ms-txt    application/ms-html    或其他浏览器可直接支持文档 
   Response.ContentType = "application/ms-excel"; 
   this.EnableViewState = false;   

来源:https://www.tulaoshi.com/n/20160129/1490756.html

延伸阅读
标签: ASP
  ASP.Net中状态保存 在ASP保存一些共享、个人状态,使用的是Application、Session、Cookie这三种。呵呵。在ASP.Net中M$除了继承Application等外,又给我们新的一种状态变量信息State,它是用来保存WEB控件的状态的变量,很新鲜吧,一定要快点知道啦:) 不好意思,飞刀还是从原始一步步来说吧。先从Application讲起。(台下一片吼声),...
标签: ASP
  接上一节,我们这一节主要计论如何使用DataSet,在数据库中增加、修改、删除一个数据。 首先我们需要打开一个联结,我们的数据库还是用上一节的吧:) string MyConnString = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:/test/test.mdb;"; string strComm = "select * from UserList"; ADOConnection MyC...
标签: ASP
  DataGrid的分页(2) 这里我紧接上一节,讲DataGrid的分页。在上例中,我们可以看到对于分页控制,本来已经足够了,呵呵,但是只是一个普通的分页,多没有意思,还是给它变些花样好。先讲讲上一节DataGrid控件所用的属性 <ASP:DataGrid id="DataGrid1" runat="server" AllowPaging="True" PageSize=...
标签: ASP
  我们这一节主要是要讲DataBind,这个在ASP.net中是很重要的东东,几乎所有的控件都需要它来控制数据的操作。也可以说是ASP.net的数据核心。 我们先来看一个简单的例子: <% @ Page Language="C#" % <% @ Import Namespace="System.Data" % <Script Language="C#" Runat="Server" pu...
标签: ASP
  Cookie Cookie的用法也和ASP中差不多。比如我们建立一个名为aspcn,值为飞刀的cookie HttpCookie cookie = new HttpCookie["aspcn"]; cookie.Value = "飞刀"; Response.AppendCookie(cookie); 我们取出Cookie值也很简单 HttpCookie cookie = Request.Cookies["aspcn"]; cookieValue = cookie.Value; ...

经验教程

356

收藏

24

精华推荐

亲密接触ASP.Net(7)

亲密接触ASP.Net(7)

三妹灰姑娘

亲密接触ASP.Net(3)

亲密接触ASP.Net(3)

sssssd518

亲密接触ASP.Net(13)

亲密接触ASP.Net(13)

冷艳天星

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部