www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > HTML

    HTML Discussion and technical support for building, using and deploying HTML sites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 04-04-2006, 07:40 AM
    klshivani klshivani is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 2
    html table to excel spreadsheet using javascript without php

    Hi can anyone help me with the script to convert a html table to excel spreadsheet using javascript without php
    MIME header has been included is ther anything to be included in the script
    Reply With Quote
      #2  
    Old 04-04-2006, 04:00 PM
    felgall's Avatar
    felgall felgall is offline
    Computer Consultant
     
    Join Date: Mar 2005
    Location: Sydney, Australia
    Posts: 7,979
    Javascript doesn't know what a file is. You could probably write a Javascript to convert the content (provided that you have the Excel file specification to know what to convert to what - Microsoft may sell you that for a few million dollars). Of course the Javascript will be so rediculously large as to make huge web pages look microscopic. There is of course then no way for you to save that content once you have let the Javascript finish creating it (possibly a wait of several months).

    To be able to do this at all you would need to use a server side language that understands what Excel is.
    Reply With Quote
      #3  
    Old 04-05-2006, 01:06 AM
    klshivani klshivani is offline
    Registered User
     
    Join Date: Apr 2006
    Posts: 2
    doesnt this work??It does ,anyways thank you

    <html>

    <head>
    <script type="text/javascript">

    function CreateExcelSheet()
    {


    var x=myTable.rows

    var xls = new ActiveXObject("Excel.Application")
    xls.visible = true
    xls.Workbooks.Add
    for (i = 0; i < x.length; i++)
    {
    var y = x[i].cells

    for (j = 0; j < y.length; j++)
    {
    xls.Cells( i+1, j+1).Value = y[j].innerText
    }
    }




    }
    </script>


    </head>

    <body marginheight="0" marginwidth="0">
    <form>
    <input type="button" onclick="CreateExcelSheet()" value="Create Excel Sheet">
    </form>
    <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>



    </body>

    </html>
    Reply With Quote
      #4  
    Old 07-05-2007, 05:27 PM
    neobrat neobrat is offline
    Registered User
     
    Join Date: Jul 2007
    Posts: 1
    Thanks

    Thanks for your info shivani.

    I tried to save a spreadsheet from javascript using the command xls.workbooks.save. If i try to close the spreadsheet, even then it asks whether to save the changes. how to prevent this from occuring?

    Thanks in advance!
    Reply With Quote
      #5  
    Old 07-05-2007, 11:08 PM
    ray326's Avatar
    ray326 ray326 is offline
    Got Link?
     
    Join Date: Nov 2003
    Location: Jerryville, Tejas
    Posts: 11,741
    Of course there are a lot of assumptions rolled into that Javascript function.
    __________________
    Help Save Ana

    Why use Web Standards: Zeldman
    How (new): Castro
    How (experienced): Cederholm
    If you can only get one book and you're already HTML savvy then this is it:
    stylin' with CSS: A Designer's Guide
    Charles Wyke-Smith
    New Riders


    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan
    Reply With Quote
      #6  
    Old 07-06-2007, 12:21 AM
    felgall's Avatar
    felgall felgall is offline
    Computer Consultant
     
    Join Date: Mar 2005
    Location: Sydney, Australia
    Posts: 7,979
    It is actually JScript/ActiveX rather than JavaScript and so the main assumptions to start with is that the browser is Internet Explorer and the Operating System is Windows since that combination is the only one to support those languages.
    Reply With Quote
      #7  
    Old 07-06-2007, 04:42 PM
    ray326's Avatar
    ray326 ray326 is offline
    Got Link?
     
    Join Date: Nov 2003
    Location: Jerryville, Tejas
    Posts: 11,741
    There may be an assumption that Excel is installed, too.
    __________________
    Help Save Ana

    Why use Web Standards: Zeldman
    How (new): Castro
    How (experienced): Cederholm
    If you can only get one book and you're already HTML savvy then this is it:
    stylin' with CSS: A Designer's Guide
    Charles Wyke-Smith
    New Riders


    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan
    Reply With Quote
      #8  
    Old 11-19-2007, 04:21 AM
    greettech greettech is offline
    Registered User
     
    Join Date: Nov 2007
    Posts: 2
    Thnak you all

    Quote:
    Originally Posted by klshivani
    <html>

    <head>
    <script type="text/javascript">

    function CreateExcelSheet()
    {


    var x=myTable.rows

    var xls = new ActiveXObject("Excel.Application")
    xls.visible = true
    xls.Workbooks.Add
    for (i = 0; i < x.length; i++)
    {
    var y = x[i].cells

    for (j = 0; j < y.length; j++)
    {
    xls.Cells( i+1, j+1).Value = y[j].innerText
    }
    }




    }
    </script>


    </head>

    <body marginheight="0" marginwidth="0">
    <form>
    <input type="button" onclick="CreateExcelSheet()" value="Create Excel Sheet">
    </form>
    <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>



    </body>

    </html>


    I am verry much thank full to all, this code has reduced my work a lot, thanks again.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 09:24 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.