Results 1 to 10 of 10

Thread: Download html table content and save to excel

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Download html table content and save to excel

    Hi,


    <table id="myTable" border="1">
    <tr> <b><td>Name </td> <td>Age</td></b></tr>
    <tr> <td>Shivani </td> <td>25</td> </tr>
    <tr> <td>Naren </td> <td>28</td> </tr>
    <tr> <td>Logs</td> <td>57</td> </tr>
    <tr> <td>Kas</td> <td>54</td> </tr>
    <tr> <td>Sent </td> <td>26</td> </tr>
    <tr> <td>Bruce </td> <td>7</td> </tr>
    </table>


    The above table is in my aspx page. One button name is download. Once i click the download button it will be download and write and save into excel file?? Is it possible??


    Hope yours reply. Please make soon reply me. Its very urgent.


    Thanks
    Failing to plan is Planning to fail

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681

    Re: Download html table content and save to excel

    I haven't seen an html table to excel, but if you are loading the table from a dataset you can do that:

    http://www.developer.com/net/asp/art...a-to-Excel.htm

    Otherwise you may need to involve javascript to call a custom handler and pass it the html table values and the handler can do the work - just theory.

    Anyone else do an html table to excel?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: Download html table content and save to excel

    Hi,
    Its not a data table. It is an aspx page that is <html><head><form>--
    </form<</head></html>.table have an id. How can i import to excel. Not only data. Whatever it is in this table how write and save it to excel???
    Failing to plan is Planning to fail

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Download html table content and save to excel

    Hey,

    I think what VBCrazyCoder was getting at is, how is the table generated in the first place. Is it static, or is it populated from a database. If it is populated from a database, then the fact that the information in the table doesn't matter, you can just execute the same query again, and write directly into excel.

    If it is static, then you are going to have to navigate the DOM in JavaScript, and then write it out to Excel. Here is an example of doing this:

    http://www.devx.com/tips/Tip/14235

    Also, please don't create multiple threads that are asking the same question:

    http://www.vbforums.com/showthread.php?t=585881

    One topic, one thread.

    Gary

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: Download html table content and save to excel

    Hi gep,

    Thanks for your reply. I am not using database for this one. I have an aspx page. In this page inside of <HTML></HTML> i put table and give id. Its k if possible to save as text file for this options???

    Thanks
    Failing to plan is Planning to fail

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Download html table content and save to excel

    Hey,

    Sure it is, but are you wanting to do this on the server, or on the client?

    Gary

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: Download html table content and save to excel

    Hi gep,

    Thanks for your reply dude. I want both. I dont have an idea that what problem will come in client side and server side. So i need both client and server.
    Failing to plan is Planning to fail

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Download html table content and save to excel

    Hey,

    I am not sure that I follow what I was asking.

    Are you trying to parse the table on the client using JavaScript?

    Or, are you trying to parse the table on the server side using either C# or VB.Net. I am assuming that you are going to do this on the server, since you need to do a Response.Write of the file, but I am just wanting to clarify what you are doing, and whether you understand it.

    Gary

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up Re: Download html table content and save to excel

    Hi gep,

    I need this one in client side using script. Because i have a table id. So its easy to implement in client side better than server. Could you plz give a solution to me??
    Failing to plan is Planning to fail

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Download html table content and save to excel

    Hey,

    You can easily navigate through the table by inspecting the DOM:

    http://www.howtocreate.co.uk/tutoria...ript/dombasics

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width