我在导出GridView中的数据时用的是如下方法,但如果有图片时,却打印不出来,求高手解决一下,
怎么才能解决这个问题。我想了一下可能要把输出流转换成二进制流才可以。
protected void Button_print_Click(object sender, EventArgs e) { System.Web.HttpContext HC = System.Web.HttpContext.Current; HC.Response.Clear(); HC.Response.Charset = "GB2312"; HC.Response.Buffer = true; HC.Response.ContentEncoding = System.Text.Encoding.UTF7; HC.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("查询结果打印", System.Text.Encoding.UTF8) + ".doc"); HC.Response.ContentType = "application/ms-word";//如果要打印为excel格式,则换为"application/excel" this.EnableViewState = false; System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); this.GV_result.RenderControl(htw); HC.Response.Write(sw.ToString()); HC.Response.End(); }//打印输出按钮
1 回答
- 1 回答
- 0 关注
- 312 浏览
添加回答
举报
0/150
提交
取消