asp.net中操作word excel等
2004-06-27 09:36
183 查看
byte[] filedata = (byte[])ds.Tables[0].Rows[0]["filedata"];
然后用下面的语句显示
Response.ContentType="application/msword";
Response.AddHeader("Content-Disposition", "inline;filename=" + Server.UrlEncode(filename).Replace("+"," "));
Response.BinaryWrite(filedata);
Response.End();
if(dr["doctype"].ToString()=="application/msword")
{
Response.ContentType = "application/msword";
}
else
{
Response.ContentType = "application/vnd.ms-excel";
}
Response.AddHeader("Content-Disposition", dr["doctitle"].ToString());
Response.Flush();
Response.BinaryWrite((byte[])dr["doctext"]);
Response.End();
public void ToWord(System.Web.UI.Control ctl)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=1.doc");
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/msword";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
Response.Clear();
Response.ContentType = "application/msword";
Response.AddHeader("Content-Disposition", "attachment; filename=xxx.doc") ;
Response.Flush();
Response.Write( test );
Response.End();
然后用下面的语句显示
Response.ContentType="application/msword";
Response.AddHeader("Content-Disposition", "inline;filename=" + Server.UrlEncode(filename).Replace("+"," "));
Response.BinaryWrite(filedata);
Response.End();
if(dr["doctype"].ToString()=="application/msword")
{
Response.ContentType = "application/msword";
}
else
{
Response.ContentType = "application/vnd.ms-excel";
}
Response.AddHeader("Content-Disposition", dr["doctitle"].ToString());
Response.Flush();
Response.BinaryWrite((byte[])dr["doctext"]);
Response.End();
public void ToWord(System.Web.UI.Control ctl)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=1.doc");
HttpContext.Current.Response.Charset ="UTF-8";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType ="application/msword";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
Response.Clear();
Response.ContentType = "application/msword";
Response.AddHeader("Content-Disposition", "attachment; filename=xxx.doc") ;
Response.Flush();
Response.Write( test );
Response.End();
相关文章推荐
- asp.net中操作word excel等
- asp.net中操作word excel等
- ASP.NET 异步操作详解和邮箱的验证
- 在ASP.NET Atlas中调用Web Service——处理错误,超时以及响应用户的取消操作
- ASP.NET 操作session详解 增加,修改,删除
- asp.net中窗口相关操作总结(javascript)
- ASP.Net操作Access数据库总结
- asp.net mvc webconfig配置文件操作
- ASP.NET-AuthorizeAttribute做身份验证操作
- 用asp.net 2.0在oracle中存取图片(文件)的操作
- 用ASP.NET对IIS中的虚拟目录进行操作(转)
- ASP.NET日期操作常用代码
- ASP.NET中操作SQL数据库(连接字符串的配置及获取)
- 【转】使用iTextSharp在Asp.Net中操作PDF
- asp.net5 操作Cookie
- asp.net操作Excel总结 (转帖)
- ASP.NET 存储过程操作
- asp.net对于图像文件的操作--存储、读取访问
- ASP.NET 2.0中执行数据库操作命令之二
- asp.net MVC + linq to Entity linq to Entity的基本操作