3 Replies - 1284 Views - Last Post: 02 September 2015 - 12:12 PM Rate Topic: -----

#1 RaeYoung   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 13-January 11

Late Binding to read EXCEL file

Posted 02 September 2015 - 07:59 AM

This may be a dumb question but here it goes:
When using late binding to read an EXCEL file, does EXCEL have to be installed on the computer running the code?

Background:
I run VB.Net code on a couple of different servers. The version of EXCEL (MS Office) is different on Server A than on my development PC so I use late binding instead of adding Microsoft.Office.Interop as a reference on my source. Works great on Server A.

As far as I can tell, Server B does not have any MS Office installed. When I run code that uses late binding to read the EXCEL file, I get the error "Cannot create ActiveX component" when I try to assign a value to my workbook.

Here is the CODE:
           Dim oXL As Object = CreateObject("Excel.Application")
            Dim oWBK As Object = oXL.Workbooks
            Dim oWS As Object = CreateObject("Excel.Sheet")


fails at Dim oWBK As Object = oXL.Workbooks with the error "Cannot create ActiveX component"

I've search for vb.net excel late binding Cannot create ActiveX component but so far haven't found anything that might resolve the issue.

Is This A Good Question/Topic? 0
  • +

Replies To: Late Binding to read EXCEL file

#2 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1515
  • View blog
  • Posts: 3,832
  • Joined: 01-February 13

Re: Late Binding to read EXCEL file

Posted 02 September 2015 - 11:28 AM

Yes Excel would need to be installed in order to create an Excel Application. I am sure if you debuged the code, you would find that oXL is Nothing.

This post has been edited by IronRazer: 02 September 2015 - 11:30 AM

Was This Post Helpful? 1
  • +
  • -

#3 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6623
  • View blog
  • Posts: 27,053
  • Joined: 12-December 12

Re: Late Binding to read EXCEL file

Posted 02 September 2015 - 11:54 AM

There are libraries based on Open XML that enable reading and writing of Excel files without Excel installed.

EPPlus-Create advanced Excel spreadsheets on the server
NPOI
Open XML SDK 2.0

I've never dug deeply into these myself, but my impression is that working with Open XML is non-trivial compared to Interop.

This post has been edited by andrewsw: 02 September 2015 - 11:56 AM

Was This Post Helpful? 0
  • +
  • -

#4 RaeYoung   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 13-January 11

Re: Late Binding to read EXCEL file

Posted 02 September 2015 - 12:12 PM

Thanks for the information. I have passed on the options to my supervisor.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1