Is MS office required on server to use Microsoft.Excel.interop - c#

I have created a merge excel program in my application using Microsoft.Office.Interop.Excel. But when deployed on IIS server I am getting error. Regarding that error I searched many articles and tried but got no successfs. So please can you verify this?

It is required.
But, you should not use Office interop on a server. The problem is that Office apps require a graphical user session to work properly. On the other hand, Windows service apps and IIS run without one. This is officially not supported and not recommended. If you do, you will encounter random crashes and resource leaks.
If you want to generate or modify Excel files, use OpenXML SDK.
EDIT: You may want to use Spreadsheet Gear. I can recommend it from personal experience in a web-app that manipulated existing Excel sheets with complex formulas.

Related

Deploy Windows Form

I have a windows form that works fine on my machine, I have a reference to the Microsoft.Interop Assembly for Excel 2007. Certain machines will have both Excel 2000 and Excel 2007 installed, and if Excel 2007 is not set as the "Default" version of Excel the windows form will throw an error and not work. Is their a way I can "package" my windows form to allow it to run error free on a machine with both 2000 and 2007 installed?
You're currently using Early Binding to access Excel. This is where you embed your reference to the interop in the project before compiling.
Advantages
Version of Excel is known to the compiler
Faster execution as we know that the methods exist and where they are
Allows us to use intellisense to check arguments are correct and that return types are correct
Disadvantages
Supports only the embedded versions of Excel
You need to take a look at Late Binding. This is where the interop is not included in the project at all and instead is bound later through reflection. You basically trade off all the advantages above for being able to support multiple versions of Excel.
There's lots of guides online that talk about how to do it.
How to use use late binding to get excel instance?
C# : Late Binding Excel Interop Tutorial
Word Automation using Late binding - Usage of dynamic Keyword
My two cents
I must echo Hans comment, this is a bad idea. Trying to support a 15 year old version of Excel is a recipe for massive headaches and I think you'll quickly look to avoid doing this.
Unless you're absolutely set on doing it this way, maybe you can look at a third party library like EPPlus. Or if you only need to read the sheet, do it some alternate way like ODBC and avoid this altogether.

Office 2013 Web Apps - Standalone redistributable document

Please consider a case as show in the image below...
I have two different apps (content + navigation) in a same excel sheet that are able to communicate with each other,
Based on this scenario, following are some questions...
1- Is it possible to deliver an excel document (standalone) which contains both of these apps, so that the end user doesn't need to insert these apps from the ribbon toolbar and user could be able to use this document on any machine (without any configurations and involving the app store/network)?
2- Is it possible to automate the process of generating excel documents that contains both of these apps? My purpose of doing this automation is to change the data contained in excel sheets, and user can perform analysis with his data.
Thanks!
Asif
I asked the same question on msdn forums and got some feedback by them, you may follow the link below for details...
http://social.msdn.microsoft.com/Forums/office/en-US/057723f1-cfe5-4f41-9d7a-430cb2f0c4c6/create-a-distributable-excel-document-with-web-apps?forum=appsforoffice&prof=required
Based on these details, my understanding is that Office 2013 web apps don't currently support standalone deployments packaged with local html files. But in future they might think of providing support for disconnected mode web apps in Office 2013.
Your comments are welcome!
Thanks,
Asif

Web service Excel conversion

I have ASP.NET web service, which is creating file in XML table format.
I need to convert this file into Excel 2003 format.
What can I use instead of Microsoft.Interop library?
UPDATE: I also need to copy format from the original file.
you can read the data from xml using linq and then insert it on the run using linq to excel with the dll provided in the post above.
also take a look at this article i hope it helps
http://blogs.msdn.com/b/bethmassi/archive/2007/10/30/quickly-import-and-export-excel-data-with-linq-to-xml.aspx
Have you tried OpenXML? Here is an example
With Office 2007
Look here for Cell Formatting
I use ExcelLibrary
I think it's a very easy to use tool.
you can transform an XML string to an excel file in one method.
I also heared about NPOI, maybe give it a look also.
I've found the answer by myself.
I could not use different libraries, because I had to open file in XML Table format and resave it to Excel 2003 format.
Maybe my experience in this question will help someone. I used Windows Server 2008 with IIS 7.0 and Excel Library Microsoft.Office.Interop.Excel version 12.
Microsoft says, that using Interop DLL may cause unpredictable result, but it's NOT impossible.
The main problem of using Interop classes lies into access to launch DCOM applications by user, that starts web-service.
To make web-service works correct in my way I did next:
I opened "dcomcnfg" and disable authorization for all DCOM
components.
Another way is to find exactly your DCOM objects and give
permissions to local launch to the user, that starts the service.
Gave permissions to registry branch
HKEY_CLASSES_ROOT\CLSID\ID_OF_MICROSOFT_APPLICATION_CLASS
ID_OF_MICROSOFT_APPLICATION_CLASS = class, which contained in
web-server error while accessing to Interop DLL
It's very strange, but important: I created folder
for 86x: C:\Windows\System32\config\systemprofile\Desktop
for 64x: C:\Windows\SysWOW64\config\systemprofile\Desktop
Gave write permission to web-service user to all folders, which my
web-service use, including folder from item (3).
If your web-service works under NETWORK SERVICE try to change it to some local user, maybe it may help you.

Excel Com Interop ASP.Net Cannot write file to disk. Permissions?

I've got a pretty simple web form which lets users pick reports, one specific report they want in xls with pretty formatting instead of CSV. I've whipped up the report using COM INTEROP with excel 2007. It works on my local machine and can write the file, but on the web server it fails with this error:
Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space.
• To make more memory available, close workbooks or programs you no longer need.
• To free disk space, delete files you no longer need from the disk you are saving to.
There is plenty of disk space on the server, so I don't think it's that - could this be a permissions issue? I've escalated ASPNET and NETWORK SERVICE accounts to have write and modify access to the folder we're saving reports to - but still no joy. Any ideas?
Do I need to invoke the com object with a specific user account, or maybe elevate the interop calls to administrator account? Any idea how to do this?
Sorry guys, sorted it.
Serge you are halfway there. I ended up running Excel as administrator:
in component services, select excel application and choose admin as the user that runs it. Seems to work okay for the week of use it'll get :)
Thanks all!
SpreadsheetGear for .NET will let you save xls and xlsx workbooks directly to a response stream with IWorkbook.SaveToStream. It is all safe managed C# code so there is no need to run anything as admin and you will not run into the problems that Excel COM Interop bring on an ASP.NET server.
You can see some simple ASP.NET Excel Reporting samples (C# and VB) using SpreadsheetGear here and download the free trial here.
Disclaimer: I own SpreadsheetGear LLC
you might want to use impersonation for your ASPNET process; here's some info and example on how to do this: killing a win process from a C# console application: How do I set permissions? more info on impersonation How to implement impersonation in an ASP.NET application

Display Excel 2007 Document in Browser using COM

I want to display and edit MS Excel File from client side using ActiveX COM object. The user would be allowed to edit the file and save it to local PC. Then It can be uploaded to remote server.
So, can you give me some example of displaying Word, Excel, Powerpoint etc document in Internet Explorer 8.0 using COM. I could not find such ocx files for that purpose . Can you help me finding it.
Thanks
Maksud
I think those controls would violate the MS Office distribution or EULA licensing agreements with Microsoft. Since an ActiveX control that emulates Word, Excel, PowerPoint would potentially give unlimited and anonymous users access to the software without paying for it. There's other Microsoft technologies that allow you to leverage the end-user's MS Offices licenses that allow them to save back to the web server. I think WebDAV used to be used (http://technet.microsoft.com/en-us/library/cc781730%28WS.10%29.aspx), I don't know what's out there now, but I'm sure there's a solution.
I wonder if the use of Google Docs would solve these issues. I'm pretty sure there's a way to leverage some sort of mix of Google Docs and the associated APIs to do something akin to what you are trying to do. I admit this isn't quite a perfect match for your goals.
This sounds like a use case that Office Live Workspace was created for. It's free, it's collaborative, and it allows you to determine sharing permissions.

Categories