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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    22
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Shared network folder help needed

    Hello everyone I am new to JS and it has been years since I worked with JAVA or HTML but I'm getting back into it for a pet project of mine and could really use some help getting past this small problem in front of me.

    ok so here is my issue:
    I have an HTML page that will read information from Cells in an MS Excel spreadsheet then will write them to the screen.

    This works if I run it localy and use the direct path like C:\MyFolder\ExcelFile.xls

    BUT if I try and access the MS Excel spreadsheet from a shared network drive like \\TheComputerName\MyFolder\ExcelFile.xls the JS will not read the file.

    SO... I tried to leave the HTML file and the Excel file localy and then tried to open teh HTML file from a shared computer like \\TheComputerName\MyFolder\MyWebFile.html but that wouldn't work ether.


    NOW my question to you guys is how can I get my HTML file to read the Excel file from a Network Shared location...
    ....AND....
    ....How do open the HTML file from a Shared computer (while still correctly reading the Excel Spreadsheet)

    Please help (and use small words and code for my little brain) and thank you.

    PS I was wondering if this could even be done in JS, I was wondering if I need to do this in PHP instead which I have NO idea at all.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Quote Originally Posted by Muzz666 View Post
    then tried to open teh HTML file from a shared computer like \\TheComputerName\MyFolder\MyWebFile.html but that wouldn't work ether.
    Define "didn't work." Do you mean the page didn't appear at all or the page appeared but couldn't read the Excel?

    And I do hope you realize that almost surely you won't be able to work with Excel in any browser except MSIE. It might help if you showed some of the code you are using in your attempts.

    Are you treating the Excel as if it were a database, using a JET connection? Or are you opening the Excel directly as an ActiveXObject? Or???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    22
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank you for the quick replay.

    I guess I should have been more detailed in my explantion. so i'll give it another try.

    Here is the code that I am useing and it works localy.

    Code:
    <html>
    <body>
    
    <BR />
    <BR />
    Hello World
    <BR />
    <BR />
    
    <script type='text/javascript'>
    <!--
    var excel=new ActiveXObject("Excel.Application");
    var start_path1="\\TheComputerName";
    var start_path2="C:";
    var end_path="\\MyFolder\\ExcelFile.xls";
    var path=start_path2+end_path;
    var book=excel.Workbooks.Open(path);
    var sheet=book.Sheets.Item(1);
    
    var col_value="A";
    var row_value=2;
    var value=sheet.Range(col_value+row_value);
    
    document.write("Cell "+col_value+row_value+" says "+value+"<BR />");
    book.Close();
    -->
    </script>
    </body>
    </html>

    IF I use the start_path1 then then I still get the Active X like normal but I get no print to the screen but if I use the start_path2 then I get the correct print out to the screen.

    Now I know that this code is very simplefied that is cause I need to use this to test then I can move on to making things more complicated.

    NOTE:
    The fourm will not allow me to upload the Excel file.
    So to test ityourself you will need to creat the MS Excel file and just type someing into Cell A1 or A2.

  • #4
    New Coder
    Join Date
    Jan 2012
    Posts
    22
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Exclamation My Total plan

    Hello All I created a new post so that I could explain just what it is my great plan is.
    in MS Excel I have created a list of help documents for my team here at work.
    In this spreadsheet I have a col for document name then a col for file name with a link to it on my system as well as other col with detailed info about the documents and what group it applies to and so and so forth.... the end result is I have this spreadsheet with about a dozen col and well over 1,000 rows.

    In the past my team has simpely opened the Excel file that was saved on my system through a shared network folder.
    So in their run line or Address bar they would enter something like this
    \\TheComputerName\MyFolder\ExcelDocumentFile.xls
    But I am unhappy with the look and feel of MS Excel and would like to create an HTML document that would have all of this information imported into an Array that can be manipulated in a simaler manner to the way it is in Excel.

    I am very aware that I might be in over my head but I am willing to work and learn JS but I have to take baby steps to sunderatnd what function does what and then I can put it togeather to make it work once I have all the parts workine like I need them to.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Ahh... You need this:
    Code:
    var start_path1="\\\\TheComputerName";
    Remember, in javascript it takes a pair of \\ to make a single \ in the resulting literal string!

    When you use "\\TheComputerName", your network reference became \TheComputerName and so of course didn't work.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Muzz666 (01-31-2012)

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    You can use the JET OLEDB driver to treat Excel as a database (looks like an Access database) and do ADODB operations on it. So you could pull all the excel data into JS easy enough.

    But you can't write it back to Excel that way. It becomes a read only system.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Jan 2012
    Posts
    22
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thanks for the info on the slashes figured it was something simple.

    Sadly Other people are still unable to get the page to display the data from the Spreadsheet from their computer but I think I am on the right track.


    As for the other database types you mentioned I have never heard of them and I am not using JS to write anything to the Excel file so that will not be a problem. I will start looking for tutor videos for the ones you mentioned.


    NOW do you have any idea why other people wouldn't be able to run this from their computer?

    I know I know i'm asking alot but if I don't ask then I can't learn.


    Thanks again for the help


    _____________________

    Update:
    If I send them the HTML file and ran from their computer then it will work but if they brows my computer and click the HTML file it will not run the Script.
    But hey atleast it's a start
    Last edited by Muzz666; 01-31-2012 at 06:18 PM.


  •  

    Tags for this Thread

    Posting Permissions

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