TechAid24

Your Technical Consultant

How to export image to Excel using the output HTML

Posted on by Anonymous Guest 1 minute read

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.

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

Tags:

Anonymous Guest

An anonymous author is a writer who conceals their true identity when publishing content, often for privacy, security, or confidentiality reasons. This approach is often used in technical articles to focus on the information being presented rather than the author's personal identity.

Leave a Reply

Your email address will not be published. Required fields are marked *