Link to home
Start Free TrialLog in
Avatar of Stephen Forero
Stephen ForeroFlag for United States of America

asked on

connecting to excel on users pc from website

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.
Avatar of shanejh
shanejh
Flag of New Zealand image

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
Avatar of Stephen Forero

ASKER

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
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.
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
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.
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
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?
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?
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of shanejh
shanejh
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial