from HTML to Excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • v_verno

    from HTML to Excel

    Good day,
    I have a web page that shows info retrieved from a MySQL db and I
    would like to convert all these data into an .XLS file.
    Have searched the net high and low but seems that I'm unable to find a
    free tool that can do the above and therefore I'm forced to do
    everything from scratch.
    Till now have developed two different versions of the programs and
    both somehow work but still have a small problem that I can't
    understand.

    The first version uses the header
    Content-Type:applicatio n/vnd.ms-excel and create a simple table in
    HTML. For instance :

    <table cellspacing=0 cellpadding=0 border=0 bgcolor=#BBDDFF >
    <tr><td>AAA</td><td>BBB</td><td>CCC</td></tr>
    ...

    It works (also with big files, have created an .XLS file that was
    22000 rows x 12 cols) but I cannot access all Excel options /
    functions (for instance : I cannot add a filter)



    The second version uses JS and ActiveX :

    <script language="VBScr ipt"></script>
    <script language="javas cript">
    function ExcelShow()
    {
    var oXL = new ActiveXObject(" Excel.Applicati on");
    var oWB = oXL.Workbooks.A dd();
    var oS = oWB.ActiveSheet ;

    oS.Name="test";
    oS.Cells(5, 1) = "AAA";
    oS.Cells(5, 2) = "BBB";
    oS.Cells(5, 3) = "CCC";

    This work fine, it is fast and I can access Excel functions but have
    noted that when number of rows is high the program dies without any
    warning / error message. It simply dies and in the HTML page I see
    only :


    <html><head><ti tle></title></head>
    <script language="VBScr ipt">
    </script>

    Any idea about what can cause the problem and how to solve it ?
    Tks, regards
    Valerio
  • Grant Wagner

    #2
    Re: from HTML to Excel

    v_verno wrote:
    [color=blue]
    > Good day,
    > I have a web page that shows info retrieved from a MySQL db and I
    > would like to convert all these data into an .XLS file.
    > Have searched the net high and low but seems that I'm unable to find a
    > free tool that can do the above and therefore I'm forced to do
    > everything from scratch.
    > Till now have developed two different versions of the programs and
    > both somehow work but still have a small problem that I can't
    > understand.
    >
    > The first version uses the header
    > Content-Type:applicatio n/vnd.ms-excel and create a simple table in
    > HTML. For instance :
    >
    > <table cellspacing=0 cellpadding=0 border=0 bgcolor=#BBDDFF >
    > <tr><td>AAA</td><td>BBB</td><td>CCC</td></tr>
    > ...
    >
    > It works (also with big files, have created an .XLS file that was
    > 22000 rows x 12 cols) but I cannot access all Excel options /
    > functions (for instance : I cannot add a filter)
    >
    > The second version uses JS and ActiveX :
    >
    > <script language="VBScr ipt"></script>
    > <script language="javas cript">
    > function ExcelShow()
    > {
    > var oXL = new ActiveXObject(" Excel.Applicati on");
    > var oWB = oXL.Workbooks.A dd();
    > var oS = oWB.ActiveSheet ;
    >
    > oS.Name="test";
    > oS.Cells(5, 1) = "AAA";
    > oS.Cells(5, 2) = "BBB";
    > oS.Cells(5, 3) = "CCC";
    >
    > This work fine, it is fast and I can access Excel functions but have
    > noted that when number of rows is high the program dies without any
    > warning / error message. It simply dies and in the HTML page I see
    > only :
    >
    > <html><head><ti tle></title></head>
    > <script language="VBScr ipt">
    > </script>
    >
    > Any idea about what can cause the problem and how to solve it ?
    > Tks, regards
    > Valerio[/color]

    I'm going to take a wild guess and say it's a bug. In which case there is
    going to be little you can do to resolve the issue.

    However, as far as adding a filter is concerned, you can do that with HTML
    data saved as a .XLS file using the following:

    <td filter="all">Co lumn Name</td>

    As for formatting content, you can do that one of two ways:

    <table>
    <col span="2" width="140"
    style="vnd.ms-excel.numberfor mat:#,###,###,# #0.000" valign="top"
    id="Quantity">
    <tr> ...
    ....
    </table>

    or

    <td style="vnd.ms-excel.numberfor mat:#,###,###,# #0.000">

    on individual cells. Also note:

    style="vnd.ms-excel.numberfor mat:[<=999][dquote][dquote][semicolon][<=9999999]###-####[semicolon](###)
    ###-####"

    works just as:

    [<=999]"";[<=9999999]###-####;(###) ###-#### works in Excel

    Although doing Excel spreadsheets as HTML _is_ more limited then the way
    you are attempting to do it, it tends to work reliably across all browsers
    regardless of client-side Javascript support. What specific functionality
    do you require that you aren't able to obtain using HTML?

    --
    | Grant Wagner <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-deve...upgrade_2.html


    Comment

    Working...