I am exporting data with images to Excel
by using the following code.
Code
protected void ExportToExcel(object sender, EventArgs e) { //Get the data from database into datatable string strQuery = "select CustomerID, ContactName, City, PostalCode, display_picture" + " from customers"; SqlCommand cmd = new SqlCommand(strQuery); DataTable dt = GetData(cmd); //Create a dummy GridView GridView GridView1 = new GridView(); GridView1.AllowPaging = false; GridView1.DataSource = dt; GridView1.DataBind(); Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=DataTable.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); for (int i = 0; i .textmode { mso-number-format:\@; } "; Response.Write(style); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
The Excel
is downloading properly. But the problem is when I am filtering the data in the Excel
. The images in the Excel
are in Move but don't size with cells
property. How to make the images with the property, Move and size with cells
?