在表和文字间加"<br>"和" "来调整位置导出Word的代码://将HTTP头添加到输出流
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.Datagrid2.Visible = true;
this.Label14.Visible =true;
this.lblTbr.Visible =true;
this.Panel1.Visible =true;
this.lblDw.Visible =true;
//将服务器控件中的内容输出到System.Web.UI.HtmlTextWriter对象中
this.lblDw.Text=" 单位:"+this.txtDw.Text;
this.lblTbr.Text="提报人:"+this.txtTbr.Text+" ";
DateTime CurrentDateTime=DateTime.Now;
this.Label22.Text =CurrentDateTime.Year.ToString()+"年"+CurrentDateTime.Month.ToString()+"月"+CurrentDateTime.Day.ToString()+"日"; this.Panel1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.Datagrid2.Visible = true;
this.Label14.Visible =true;
this.lblTbr.Visible =true;
this.Panel1.Visible =true;
this.lblDw.Visible =true;
//将服务器控件中的内容输出到System.Web.UI.HtmlTextWriter对象中
this.lblDw.Text=" 单位:"+this.txtDw.Text;
this.lblTbr.Text="提报人:"+this.txtTbr.Text+" ";
DateTime CurrentDateTime=DateTime.Now;
this.Label22.Text =CurrentDateTime.Year.ToString()+"年"+CurrentDateTime.Month.ToString()+"月"+CurrentDateTime.Day.ToString()+"日"; this.Panel1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
解决方案 »
- 如果使得textbox中按回车后,相当于点击“确定”按钮的事件,不是直接复制一遍按钮事件的代码,是绑定
- ODP.NET 存储过程解惑 关于关键字
- 怎样把 “二维”datatable 转化为dictionary
- 访问数据库的话:“WCF服务”和“WCF数据服务”有什么各自的利弊呢?
- 有用directshow控制过音量的吗?请教,急。。。
- 使用office的Microsoft Office Document Image Writer虚拟打印机遇到两个问题,请各位打下帮忙
- 怎么让显示<br>变为实现换行
- 请教各位:什么是隐藏基类方法,有什么优点?
- 一个简单的问题请教哈大家哦!在线等答案哦
- 求助,开发一个连接智能手机发送短的软件需要怎么做?
- 最近想学C# AD编程,请教各位大侠的心得,高分以表谢意
- button 怎样响应回车事件??
不好意思没说明白
我是在winform中把datagrid中的数据导入word
在生成的word文档中怎么控制表格和文字的关系
表格总是在最上面
我另外先加了一个表名但表名总是在表的下面