Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    5
    Thanked 1 Time in 1 Post

    Question Accessing Local Data using JS

    Hello,

    I am working on a project using HTML and javascript to allow the user to choose a vehicle from a drop down menu, then load a new page showing some information about this vehicle. The information is stored in an Excel file. I posted regarding this issue a while back and got an excellent response from Old Pedant (thanks again!) about using ActiveX - which has thus far worked perfectly. My initial condition was that I would only be using IE7+. However, my next idea was to be able to use it on an IPad (which I unfortunately do not own yet, making any kind of testing difficult) which I am fairly certain ActiveX won't work on. So, I was looking for any other method which would be similar.

    Important note: this will not use the internet at all, all of these files will be available locally. There is a lot of material on running queries to servers, but I didn't think that would really apply here. It seems pretty clear that JS has difficulty accessing files client side (which I understand why completely), but I was hoping to find something that worked for the gray zone I'm currently working in since I'm not using servers at all.

    I know that this is not really the intended use of HTML/JS, but I was hoping that by writing it as an HTML file, it'd be accessible to anyone with a browser. Some of my target computers have odd limitations (such as not being to download .exe files).

    The code I based my original off of is shown below:

    Code:
    <script type="text/javascript">
    
    var conn = new ActiveXObject("ADODB.Connection")
    conn.Open ( 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\full\path\to\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";)';
    
    var sql = "SELECT * FROM [nameOfSheet$]";
    var rs = conn.execute( sql )
    while ( ! rs.eof ) 
    {
        // just an example of dumping everything from the sheet out to the browser:
        for ( var f = 0; f < rs.fields.count; ++f )
        {
            document.write( rs.fields(f).value + "," );
        }
        document.write("<br>\n");
        rs.moveNext();
    }
    
    rs.close();
    conn.close();
    </script><script type="text/javascript">
    
    var conn = new ActiveXObject("ADODB.Connection")
    conn.Open ( 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\full\path\to\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";)';
    
    var sql = "SELECT * FROM [nameOfSheet$]";
    var rs = conn.execute( sql )
    while ( ! rs.eof ) 
    {
        // just an example of dumping everything from the sheet out to the browser:
        for ( var f = 0; f < rs.fields.count; ++f )
        {
            document.write( rs.fields(f).value + "," );
        }
        document.write("<br>\n");
        rs.moveNext();
    }
    
    rs.close();
    conn.close();
    </script>
    Thank you,
    klarosa
    Last edited by klarosa; 07-19-2011 at 04:52 PM.

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,444
    Thanks
    11
    Thanked 598 Times in 578 Posts
    since the ipad has no file system and no file upload input, you'll have to use a server.
    you can get a close idea of what the ipad will display by running safari full-screen at 1024X768
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%

  • Users who have thanked rnd me for this post:

    klarosa (07-19-2011)


  •  

    Posting Permissions

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