www.webdeveloper.com
Results 1 to 5 of 5

Thread: scan EXCEL Using JavaScript

  1. #1
    Join Date
    Mar 2013
    Posts
    3

    scan EXCEL Using JavaScript

    Hi ALL,

    I am New to javascript, please help me.

    I got a situation in which I have to scan an excel file containing Three big columns as mentioned below.
    col1:First name
    col2:Last name
    col3:UID

    I have to get input from user which is FN,LN and I have to return corressponding UID as output.

    How to do this !!!!

    Please Help Me

    Thanks


  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,252
    Save your file as comma separated value (cvs or txt file) use a textarea to paste the file and work with javascript (use a split(/[\r\n]+/g) to get an array of lines and an other split in a loop for the three fields).

  3. #3
    Join Date
    Mar 2013
    Posts
    3
    Thanks for the reply

    I will try using split and update you

  4. #4
    Join Date
    Mar 2013
    Posts
    3
    I am able to search a single column using the below code.

    How to extend this as to search two columns and give the corresponding 3rd column as output


    function searchExcel()
    {
    var searchPhrase = document.getElementById('searchPhrase').value;
    var Worksheet = 'C:\\example.xls';
    var Excel = new ActiveXObject('Excel.Application');

    Excel.Visible = false;
    var Excel_file = Excel.Workbooks.Open(Worksheet, null, true, null,
    "abc", null, true, null, null, false, false, null, null, null);

    var range = Excel_file.ActiveSheet.Range('A:A');
    var jsRangeArray = new VBArray(range.Value).toArray();

    var found = false;
    for(cells in jsRangeArray)
    {
    if(jsRangeArray[cells] == searchPhrase)
    {
    document.getElementById("results").innerHTML = "Found";
    found = true;
    }
    }

    if(found == false)
    {
    document.getElementById("results").innerHTML = "Not Found";
    }

    Excel.ActiveWorkbook.Close(true);
    Excel.Application.Quit();
    Excel = null;
    }

    Works fine in IE

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by vinayreddy View Post
    I am able to search a single column using the below code.
    Works fine in IE
    that code will always only work in IE, and i doubt anyone will help you with it.

    if you could use a CSV file instead of a XLS file, i will be more than happy to help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
HTML5 Development Center



Recent Articles