Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello Sir,
I am trying to convert whole page into excel, I know how to convert Grid to excel, but this is bit unique for me please help me or confer some links so that I can do my work,I found in google but not able to understand the code they confered please help me

Whole Page to Excel Please help Sir's
Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 13-Dec-11 9:53am    
What exactly is difficult?
--SA

1 solution

First, you need to parse HTML to recognize relationships between the elements <table>, <tr> and <td> and extract the HTML content from <td>. If you can assume your HTML is a well-formed XML, this is easy; you can use one of available XML parsers.

Here is a short review of XML parsing capabilities you can use:

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].


If you cannot assume well-formed XML on input, this is of course more difficult. You can use some HTML parser which can handle such input. Try, for example, this one: http://www.majestic12.co.uk/projects/html_parser.php[^].

To create Excel document you need to use Microsoft Office interop. Start here:
http://msdn.microsoft.com/en-us/library/wss56bz7%28v=VS.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/dd264733.aspx[^].

—SA
 
Share this answer
 
v3
Comments
Prashant Srivastava LKO 16-Dec-11 6:37am    
Thanks to tell me, but I have solved it
[no name] 17-Dec-11 2:07am    
Great that you have solved it. Since you asked question he is answering. By the way you can also add your solution if you have different than mentioned.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900