In this post, we want to discuss the way to export image to excel using c# html output. Before we get started, if you want to know about Software Development Life Cycle, please go through the following article: What is SDLC? What is SDLC model overview?
Export data from an asp.net page to an Excel file and I’m basically just outputting HTML to the XLS file where I want to embed an image. The image file has to be in binary form in the content.
IÂ have to get images in StringWriter and use System.Text.Encoding.ASCII.GetBytes(stringwriter string) in an array of bytes. then write these as outputStream.Write(byte_array, 0, byte_array.Length); where outputstream is HttpContext Response outputstream.
1 2 3 4 5 6 7 8 | string filePath = Server.MapPath(lblReportLogo.Text); System.Drawing.Image imgPhoto = System.Drawing.Image.FromFile(filePath); string imagepath = string.Format("<img src='{0}' width='{1}' height='{2}'/>", filePath, 100, 40); String headerTable = @"<div style='text-align:center'>"+ imagepath +"</div>"; Response.Write(headerTable); imgPhoto.Dispose(); |
How to export image to Excel using the output HTML
The article was published on October 22, 2019 @ 2:27 AM
Leave a Comment