I have looked everywhere and I can't figure out how to export an image to excel. I have know how to export a datagrid to excel but I'm trying to export an image as well. I would appreciate any help.
do you want to display the image in excel, or the bytes? to add the bytes convert the byte array to a string and insert into a cell. you would also need to include the content type so you can convert it back to an image.
to insert an image you will need to add an object (not sure what type) to hold the image and then stream the bytes into this object.
I haven't done this before, but I would assume its the same as inserting an image into a Word Document. I would research dynamically adding an image to a Word Doc in VB/C#.
this shouldn't be an issue. an image is just a byte array. I would assume you could read the array into a Stream object. then embed the stream into the document.
If the examples require a file you could write the stream to a file, embed the file into the documet, and finally, delete the file as it's not longer needed.
ASP.net programming is new to me do you think you could provide sample code. This is what I am using now but I don't get an image:
[VB]
Private Sub ExportToExcel1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Clear()
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition","attachment;filename=ImageChart.xls")
EnableViewState = False
Controls.Add(frm)
frm.Controls.Add(WebChartViewer1)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub
[/VB]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.