导出Gridview以使图像更好

在我的网页,我有一个GridView的数据和一些图像,在这里我想导出GridView与图像优秀,我试着用下面的代码,只导出数据,在这里我怎样才能出口到图像优秀?

Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); GridView1.HeaderRow.Style.Add("background-color", "Red"); for (int i = 0; i < GridView1.Columns.Count - 2; i++) { GridView1.HeaderRow.Cells[i].Style.Add("background-color", "Red"); } GridView1.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); 

这里我使用Openoffice calc来读取excel文件

用这个replacefunction代码

 private void Excel_Export() { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView1.AllowPaging = false; GridView1.DataBind(); for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; //Apply text style to each Row row.Attributes.Add("class", "textmode"); } GridView1.RenderControl(hw); //style to format numbers to string string style = @"<style> .textmode { mso-number-format:\@; } </style>"; Response.Write(style); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } 

请参阅此链接了解更多详情