请问如何设置导出Excel的格式?急啊,请高手们帮帮忙,急!!!
我用这种方式导出Excel ,但没办法设置Excel 的格式
protected void Button1_Click( object sender, System.EventArgs e )
...{
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=FileName.xls ");
// 如果设置为 GetEncoding( "GB2312 ");导出的文件将会出现乱码!!!
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/ms-excel ";//设置输出文件类型为excel文件。
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.GridView1.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();
}
public override void VerifyRenderingInServerForm( Control control )
...{ }
比如我要导出一个条数据是这样
1.00 2.00 3.00 4.00
也就是我要导出像货币的类型,后面有加小数,可是导出的结果却是:
1 2 3 4
请问要怎样设置导出Excel的格式
------解决方案--------------------应该是e.Row.Cells
------解决方案--------------------http://dotnet.aspx.cc/Exam/OutPutExcel.aspx
例子执行结果,你可以拿他的导一下试试,你要求的都作到了