Results 1 to 3 of 3

Thread: Export to excel

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Answers
    1

    Export to excel

    Hi,
    i am designing the webpage, where i have a page with search results that are dynamic (based on some input from the user, search is performed) ..
    i want to export these results to Excel..
    can any body help me..
    i tried the following code:


    var oXL = new ActiveXObject("Excel.Application");

    oXL.Visible = true;

    // Get a new workbook.
    var oWB = oXL.Workbooks.Add();
    var oSheet = oWB.ActiveSheet;


    the code is working on my local machine..
    but when i tried to load the webpage on server and then tried to run from my local machine...its giving error::

    Automation Server can not create object..

    Please let me know...if there is any other way to export to Excel...using java script...

    Last edited by paritosh.garg; 12-27-2007 at 01:28 AM.

  2. #2
    Junior Member
    Join Date
    Feb 2009
    Answers
    2

    Re: Export to excel

    Hi

    I tried using your Javascript; but it did not run on local machine except opening the excel file.

    I tried two scripts:





    Is there any error in the script?

    regards / Prafulla


  3. #3
    Junior Member
    Join Date
    Feb 2009
    Answers
    2

    Re: Export to excel

    Script 1

    Function ExportToExcel()

    Var sHTML = document.all.item("table1").outerhtml;
    Var oExcel = new ActiveXObject("Excel.Application");
    Var oBook = oExcel.Workbooks.Add;
    sHTML = oBook.HTMLProject.HTMLProjectItems("Sheet1").Text;
    oBook.HTMLProject.RefreshDocument;
    oExcel.Visible = true;
    oExcel.UserControl = true;
    End Function


    Script 2

    function Export() {
    window.clipboardData.setData(”Text”,document.all(’table2').outerHTML);
    try{
    var ExApp = new ActiveXObject(”Excel.Application”);

    var ExWBk = ExApp.workbooks.add();
    var ExWSh = ExWBk.worksheets(1);
    ExApp.visible = true;
    ExApp.DisplayAlerts = true;

    }catch(e){
    alert(”your computer don’t install Microsoft Excel!”)
    return false
    }
    ExWBk.worksheets(1).Paste;
    }
    oExcel.Visible = true;
    oExcel.UserControl = true;


    Sorry for reposting, as the script tag perhaps disallowed on the forum.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact