0

I want to convert specific webpage to image and export image to Excel. Please Help me. Thanks In Advance.

This is my Code Behind

protected void ExportToExcel_Click(object sender, EventArgs e)
{
       string attachment = "attachment; filename=Export.xls";
       Response.Clear();
       Response.Buffer = true;
       Response.AddHeader("content-disposition", attachment);
       Response.ContentType = "application/vnd.ms-excel";
       Response.Charset = "";
       this.EnableViewState = false;

       StringWriter oStringWriter = new StringWriter();
       HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
       divExport.RenderControl(oHtmlTextWriter);

       Response.Write(oStringWriter.ToString());
       Response.End();
  }

This is my Asp.Net Code

<div id="content">
<div id="divExport" runat="server" style="height:500px;width:700px;overflow:auto;">
        <asp:literal ID="ltrlOrganization" runat="server"></asp:literal>
        <div id="chart" class="orgChart">
        </div>
    </div>
</div>
<asp:Button ID="ExportToExcel" runat="server" Text="ExportToExcel" onclick="ExportToExcel_Click"/>

I use external css file and javascript file from (http://jquer.in/jquery-navigation-and-menu-plugins-from-2012/jorgchart/)

This is my requirement

[Update]

https://www.dropbox.com/s/x48eknzxvia02zf/webpage.png

Min Min
  • 125
  • 1
  • 2
  • 10

2 Answers2

0

I can't see an actual question or problem in what you have posted. It appears you may be looking for ideas on how to 1) turn a web page into an image and 2) send the image to Excel.

I've turned up two links that you should explore in learning how to do this:

Convert Webpage to Image

Excel image in a cell

These may help you learn the processes you will need to accomplish your goal.

Community
  • 1
  • 1
Kevin
  • 4,798
  • 19
  • 73
  • 120
  • i already check above link but they don't have external css file or javascript file. My requirement is like this http://jquer.in/jquery-navigation-and-menu-plugins-from-2012/jorgchart/ – Min Min Aug 01 '14 at 16:57
  • I'm assuming that you'll be using the jquery plugins mentioned that you'll be taking the images and making an org chart? If that is the case, then I don't see a problem. You convert the page to an image, then use your plugin to create your chart of web page images. If this isn't the case, then you need to add more details to your question. – Kevin Aug 01 '14 at 17:05
0

You would best do a printscreen:

Image bit = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); 

Graphics gs = Graphics.FromImage(bit);

gs.CopyFromScreen(

new Point(0, 0), new Point(0, 0), bit.Size);

bit.Save(@"c:\temp.jpg"); // or stream to memory, whichever you prefer

Then you can add it to your spreadsheet

MikeV
  • 585
  • 3
  • 11
  • Hey, that's not bad. Only downside would be that it wouldn't catch anything outside the view (like lower half of page that user hasn't scrolled to). But, still, that's a really neat idea! – Kevin Aug 01 '14 at 17:02