Solved

connecting to excel on users pc from website

Posted on 2012-04-03
11
482 Views
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=14.0.0.0, 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.
0
Comment
Question by:solarissf
  • 6
  • 5
11 Comments
 
LVL 2

Expert Comment

by:shanejh
Comment Utility
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:
Microsoft.Office.Interop.Excel.dll
Microsoft.Office.Interop.Excel.xml
Microsoft.Vbe.Interop.dll
office.dll
office.xml
0
 

Author Comment

by:solarissf
Comment Utility
I have the following in the bin folder

interop.microsoft.office.core.dll
interop.microsoft.office.interop.excel.dll

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=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
Line 14:         <add assembly="Microsoft.Vbe.Interop, Version=14.0.0.0, 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=14.0.0.0, 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
0
 
LVL 2

Expert Comment

by:shanejh
Comment Utility
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.
0
 

Author Comment

by:solarissf
Comment Utility
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
0
 
LVL 2

Expert Comment

by:shanejh
Comment Utility
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.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:solarissf
Comment Utility
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
0
 
LVL 2

Expert Comment

by:shanejh
Comment Utility
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?
0
 

Author Comment

by:solarissf
Comment Utility
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?
0
 
LVL 2

Expert Comment

by:shanejh
Comment Utility
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.
0
 

Author Comment

by:solarissf
Comment Utility
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.
0
 
LVL 2

Accepted Solution

by:
shanejh earned 500 total points
Comment Utility
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.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now