locked
How to open Excel workbook from a web application? RRS feed

  • Question

  • We have an Excel customization developed using VSTO and C# .net. My questions is how to open this Excel workbook from a web application and pass in some data into the workbook. The web application was developed using javascript for the client side. 

    can we use javascript to open our Excel application and push some data into the sheets. and can we open the application into a specific sheet?

    thanks, 

    Monday, August 31, 2015 5:44 PM

Answers

  • >>>additionally, how to check if the Excel.Application object is exist so we don't launch a new instance of the application every time we click on a button (for example). I tried to use GetObject but did not work.

    If you want to do like this " excelObj = GetObject(, "Excel.Application")", there is no way to do that; there’s no “code signing” mechanism for JavaScript.

    GetObject Function (Visual Basic) returns a reference to an object provided by a COM component.
    The following example uses the GetObject function to determine whether Excel is running.

    ' Test to see if a copy of Excel is already running. 
    Private Sub testExcelRunning()
        On Error Resume Next 
        ' GetObject called without the first argument returns a 
        ' reference to an instance of the application. If the 
        ' application is not already running, an error occurs. 
        Dim excelObj As Object = GetObject(, "Excel.Application")
        If Err.Number = 0 Then
            MsgBox("Excel is running")
        Else
            MsgBox("Excel is not running")
        End If
        Err.Clear()
        excelObj = Nothing 
    End Sub

    For more information, click here to refer about GetObject Function (Visual Basic)

    Friday, September 4, 2015 7:15 AM

All replies

  • >>>can we use javascript to open our Excel application and push some data into the sheets. and can we open the application into a specific sheet?

    ActiveXObject Object (JavaScript) enables and returns a reference to an Automation object.

    Note:This object is a Microsoft extension and is supported in Internet Explorer only, not in Windows 8.x Store apps.

    Automation servers provide at least one type of object. For example, a word-processing application may provide an application object, a document object, and a toolbar object.

    You may be able to identify servername.typename values on a host PC in the HKEY_CLASSES_ROOT registry key. For example, here are a few examples of values you may find there, depending on which programs are installed:

    •Excel.Application

    •Excel.Chart

    •Scripting.FileSystemObject

    •WScript.Shell

    •Word.Document

    For more information, click here to refer about ActiveXObject Object (JavaScript)

    Tuesday, September 1, 2015 7:51 AM
  • HI, 

    do you have examples for using Excel.Application and sending data to a sheet in the workbook. additionally, how to check if the Excel.Application object is exist so we don't launch a new instance of the application every time we click on a button (for example). I tried to use GetObject but did not work. 

    thanks

    Tuesday, September 1, 2015 4:08 PM
  • >>>additionally, how to check if the Excel.Application object is exist so we don't launch a new instance of the application every time we click on a button (for example). I tried to use GetObject but did not work.

    If you want to do like this " excelObj = GetObject(, "Excel.Application")", there is no way to do that; there’s no “code signing” mechanism for JavaScript.

    GetObject Function (Visual Basic) returns a reference to an object provided by a COM component.
    The following example uses the GetObject function to determine whether Excel is running.

    ' Test to see if a copy of Excel is already running. 
    Private Sub testExcelRunning()
        On Error Resume Next 
        ' GetObject called without the first argument returns a 
        ' reference to an instance of the application. If the 
        ' application is not already running, an error occurs. 
        Dim excelObj As Object = GetObject(, "Excel.Application")
        If Err.Number = 0 Then
            MsgBox("Excel is running")
        Else
            MsgBox("Excel is not running")
        End If
        Err.Clear()
        excelObj = Nothing 
    End Sub

    For more information, click here to refer about GetObject Function (Visual Basic)

    Friday, September 4, 2015 7:15 AM