1 Replies - 2488 Views - Last Post: 11 January 2011 - 03:45 AM Rate Topic: -----

#1 Guest_mark*


Reputation:

Append an Image with HtmlTextWriter

Posted 10 January 2011 - 05:50 PM

Trying to insert an image at the beginning of my customized excel output:

BindResultsView(GetQueryResults()); 
            Response.AddHeader("content-disposition", "attachment;filename=Report.xls");
            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset = "";

            StringWriter stringWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

            stringWriter.GetStringBuilder().Append("<B>");
            stringWriter.WriteLine("Employee Report:  ");
            stringWriter.GetStringBuilder().Append("</B>");



Not sure if this can be done, by adding stringWriter.GetStringBuilder().Append("<div>") elements? How would it be done.

Is This A Good Question/Topic? 0

Replies To: Append an Image with HtmlTextWriter

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: Append an Image with HtmlTextWriter

Posted 11 January 2011 - 03:45 AM

I'm fairly sure this just isn't doable using this method. When you export the data to excel using the StringWriter it will create the img link but it won't have a local copy of the actual image to point to.

Might be doable using the excel interop library, but it's a little more complicated to use and I just don't have enough experience with it to be able to tell you that even that would for sure work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1