如何实现c#打开一text文件,修改后用.xls保存(需保存图片)? 先创建MS Excel对象,建立新的Sheet,然后用System.IO来逐行读取txt中的内容,并写入Excel Sheet对应的cell即可,记得用循环哦! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Response.Clear(); Response.Buffer= true; Response.Charset="GB2312"; Response.AppendHeader("Content-Disposition","attachment;filename=指定Excel文件名"); Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。(此项可改,如要输出WORD格式,则最后为ms-word) this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);this.DataGrid1.RenderControl(oHtmlTextWriter); //此处为输出DataGrid控件的值,其他控件应该也可以.而且BUTTUN和模板列不能输出,超链列可输出.如果有这些列,必须在之前把该列VISABLE属性定义为FALSE;意思是改变样式,最后再绑定一下,就能按你的样式导出了。Response.Write(oStringWriter.ToString());Response.End(); 把图象文件转换成XML格式文件 http://dotnet.aspx.cc/ShowDetail.aspx?id=EBD43E74-1BDE-43AA-DEAF-211FA24A7BC2 没关系的 图象也能一并导出,比如this.Image.RenderControl(oHtmlTextWriter); 之不过导出的图片原来多大就多大,并不是页面中显示的尺寸 类型转换问题,急救 如何去除所有符号? 连续计算方法怎么写? richtextbox 拖放文件 请教 log4net 谁能帮我编这个代码,急急急 怎么学习C#控减呀~~~UP有分! 急呀,一个关于窗体继承的问题 在线等待 怎样控制登录系统的IP范围? Main()和Main(string[] args)有什么不同 怀疑listview的问题,请高手帮忙 往DataGrid里面放数据,100000条数据怎么就死了呢??
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=指定Excel文件名");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。(此项可改,如要输出WORD格式,则最后为ms-word)
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.DataGrid1.RenderControl(oHtmlTextWriter); //此处为输出DataGrid控件的值,其他控件应该也可以.而且BUTTUN和模板列不能输出,超链列可输出.如果有这些列,必须在之前把该列VISABLE属性定义为FALSE;意思是改变样式,最后再绑定一下,就能按你的样式导出了。
Response.Write(oStringWriter.ToString());
Response.End();