connecting to excel on users pc from website

Posted on 2012-04-03
Medium Priority
Last Modified: 2012-06-21
Hello all,

I've built this website project locally in visual web developer express 2010 c#.  Using the microsoft.office.interop.excel 14.0 reference, I connect to the users excel object, open a specific excel file on the desktop, and manipulate it a bit.  All this worked locally, now however I put it up on a host.  And when I test it I get the following error message:

Could not load file or assembly 'office, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified

I've been searching the internet and some links lead me to believe that this microsoft.office.interop.excel can only be used on a desktop.  Not from the web.  Or have excel installed on my server, which I'm guessing is impossible for me since I'm using godaddy.com.    What I dont understand is, can't I just look for assembly or load files right from users pc since they have excel installed.

Anyone have any suggestions?

I'm hoping I make sense.
Question by:solarissf
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5

Expert Comment

ID: 37804436
Probably an obvious question. But have you checked that all the .dll files are present in the bin folder?

If I remember right you need the following:

Author Comment

ID: 37804477
I have the following in the bin folder


and here is the error message

Source Error:

Line 11:     <compilation debug="true" targetFramework="4.0">
Line 12:       <assemblies>
Line 13:         <add assembly="office, Version=, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 14:         <add assembly="Microsoft.Vbe.Interop, Version=, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 15:       </assemblies>

Source File: D:\Hosting\9179506\html\web.config    Line: 13

Assembly Load Trace: The following information can be helpful to determine why the assembly 'office, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature

Expert Comment

ID: 37804556
It's been a long time since I looked at this side of things. So just had a quick read up on it.

Your assumption about Office appears to be correct, Office PIAs are wrappers for COM based Office components. Without Office components (installed by Office), Office PIAs are useless. From what I understand MS doesn't recommend using server side automation in that way either, so even if you could install Office on the server it is not recommended to do so.

Without knowing exactly what you are doing it is hard to tell you what your best option is from here but I can I recommend you have a look at ADO.NET. The following link may be of use to you:

Read data from Microsoft Excel using Microsoft Visual C# .NET

How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET

How to transfer data to an Excel workbook by using Visual C# 2005 or Visual C# .NET

OLE DB Provider for Jet  

Hope this is helpful.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 37805370
basically this finds the path of the desktop of user, opens a known excel file from it.  Then writes to the excel file, performs some math, and saves as a pdf.

someone recommended created a activex object.  I am trying to understand what an activex object is but from what I'm reading so far, the user will hit allow when launched, then I can use files available on users pc. like microsoft.office.excel.interop....

do you know anything about this?  does this sound like a good direction to go in, and if so how do I go about getting started.    or do I head in the previous direction you recommended, ole.ado

thanks so much for the input and advice

Expert Comment

ID: 37806011
I can't say I know much about activex and considering how much of an issue it was getting that dll to show up properly for you in VS I wonder if thats really a dependance you want. It just sounds like trouble to me.

I would have thought it would be easier to have the user upload a file with an upload component and once uploaded process it using ado.net, extract data and perform maths etc, then generate a pdf and make it available/return it to the user. (obviously there is more to it than that)

Just my opinion, there are bound to be other ways to do what you are wanting, but after a quick read about access to excel documents server side that would be the direction I would go.

Hopefully that helps a bit, and doesn't confuse the issue even more! Good luck now.

Author Comment

ID: 37806046
I've been reading about this online for hours now.  I see other people are taking that approach, to upload file, and process it using ado.net.    Before I leap into this approach, I do not know what ADO is??   Will I be able to actually open the uploaded the excel file and use normal calculations on it.  For example... I have many formulas on the excel sheet that I rely on, am I still able to access this excel file as if its really open in front of me... or do is it something more like stripping the contents of the excel file into a database and manipulating from there?  because if thats the case then all my formulas I rely on will not be there

Expert Comment

ID: 37808651
It's more like using it as a data source. You should be able to pull the formulas from the cells in the sheet, but you won't be able to run them like they are in front of you.

I'm still not 100% sure about what you are trying to achieve. Is a web app definitely the right approach?

Author Comment

ID: 37808787
It looks like I am going about this the wrong way.  I guess I just have to read the data from excel... then perform all my statistical calculations another way.  But the goal is to show results on website.  If I skip doing the calcs in excel, how would you recommend I read excel sheet, and where would I perform my math?

Expert Comment

ID: 37808819
If you are just pulling data out then using ADO.NET to connect to excel would make sense. This is much the same as connecting to say an access database. You can pull data from your sheets.

Where you do calculations really depends on what you are doing with your data, if all you want to do is perform some calculation and then show the results then this should be fine to do the math in code. How difficult this will be depends on how much you manipulate the numbers etc.

Author Comment

ID: 37808850
sorry for the dumb question, but what different options do I have to perform calculations?  some of the things I need are pretty easy, like average performance.. standard deviations.  correlations.  some get a bit more complicated like calculating cumulative rate of returns and building portfolios.

Accepted Solution

shanejh earned 2000 total points
ID: 37808957
You can pull the data into memory and run maths functions on it. You could bind it into a datagrid type control and perform calculations on that. You could even perform calculation on the excel data and push the results back into the excel worksheet.

There are lots of ways to manipulate data.

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question