Microsoft.Office.Interop - c#

I am using Microsoft.Office.Interop.Word.dll to create docx file. It works on my local machine, but can you tell me how to use it on server without installing MS-Office or any third party packages? Please suggest to me some third party tool.

Unfortunately, You have to have MS Office on machine that should run application. Other solution for example via XML:
Link

Its much better to use xml access to word documents, especilly on servers. When using iterop services, it creates mess on server - need to install office, then the COM objects are not disposing themselves...
check this: Open XML SDK, use DocumentFormat.OpenXml.dll

Related

How to print DOCX/PDF documents unattended?

I am trying to replace an outdated solution which uses Office Interop to create and print Word documents, and export them to PDF. It needs to run unattended on a server, so we want to get rid of our dependency on Interop. I can create the files fine with Open XML SDK but cannot print or export. Is there some way to do this with libraries (free or paid) that does not require having Adobe/MS Office products installed in a server environment? The limits we have to work within will allow me to either use a .NET console application or a PowerShell script.

Netoffice progid not found

I've done find and replace solution in Micorsoft.Office.Interop.Word in asp.net I would like to move this solution on NetOffice in my asp.net server where there is no Microsoft Word. I got error
progid not found
. What I do wrong because on my computer where I have Microsoft Word this code work fine in NetOffice?
Word.Application wordApp = new Word.Application(); <-- here is this error
NetOffice is just a COM Wrapper to the office applications, therefore it requires that you have the office app installed on the machine where your application is running.
i.e. You need to have Microsoft Word installed on any machine that you intend to run an app that uses NetOffice.Word.
If this was a desktop app, all you would have to do, would be to install Word on the machine, but given you want to use office automation from a server, and Microsoft does not recommend it, you should look into other options of interfacing with Word documents directly via OpenXML without having to install Word on the machine.
I'd recommend taking a look at the DocX library:
https://github.com/WordDocX/DocX
As well as the articles below:
How to: Create a word processing document by providing a file name (Open XML SDK)
Edit Word Documents using OpenXML and C# Without Automation/Interop
Your code should work with NetOffice, but you need to add a using statement:
using Word = NetOffice.WordApi;
You also need to disable the setting Embed Interop types for all NetOffice DLL's.

Update an excel sheet on Windows server 2012 with C#

I am writing an application where we need to update an existing Excel sheet through our system. I was able to do so on my local machine with OleDbConnection but when i deploy the application on server it gives me "operation must use an updateable query"
error on Windows server 2012.
I know its not recommended to install MS Office on Server and thats why its causing the issue. Any one has an idea whast the work around for this problem.
Do i have to give permission to my .net application so it can update the excel file or its something else?
Thanks in Advance.
I know its not recommended to install MS Office on Server
Last I checked, it is also a violation of the license terms (though that may have changed)
As you note, there are many reasons it is unwise to deploy Office to a server environment.
If you are using the newer (2007+) .xlsx file format exclusively, you can use the open source EPPlus library for most common Excel tasks. It is free, straightforward to use, and is designed to work on a server.
EPPlus is a .net library that reads and writes Excel 2007/2010 files using the Open Office Xml format (xlsx).

Will I require MS Excel installed on the server if I am generating Excel file using NetOffice?

I am trying out both NetOffice and NPOI for to use in an ASP.NET project.
I am making an ASP.NET web site where on click of a button, I want to generate an Excel file in a password protected state and send it to the client to download it.
But I want to know whether, will I require MS Excel installed on the server?
OR Is there a way where I can make this work on a server where MS Excel is NOT installed?
Also what are other pre-requisites for both these APIS?
I basically have to identify which of these APIs will work for me in a server without Microsoft Excel installed in it.
Please check documentation: http://netoffice.codeplex.com/documentation at question
What do I have to do to deliver my application with NetOffice?
Nothing except copying the needed assemblies to the target system. You don't need a registration or something like that with the exception of COMAddIns. Managed COMAddins generally have to be registered via the .Net Utility RegAsm.exe or the Windows Installer do that or you.

Alternative solutions to Microsoft.ACE.OLEDB.12.0 provider

I'm getting the "Microsoft.ACE.OLEDB.12.0 provider is not registered" error on my asp.net application while I try to read an Excel file and after an exhaustive research on the web I just found myself in a dead-end. The only available solutions is to install the MS Component to achieve the objective. But there is a little inconvenient (as always), because of our costumer politics we can not install nothing but the application. And that's the real problem here. So I'm wondering if there is a way (an alternative way) to avoid the component installment. If not well I think we will have a little issue with the client but nothing that we can not solve. But lets try to avoid that uncomfortable part.
you do not need to install excel you should just be able to install the drivers.
2007 Office System Driver: Data Connectivity Components
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23734
Take a look at EPPlus.
I've used it for writing Excel files but it is also capable of reading Excel files too. It uses Open XML and it's easy to work with. Also, you do not need to install an OLEDB engine on the client machine.
You havn't specified which version of the Excel format you want to read. You can use the OpenXML SDK to read (and write) the newer formats. This SDK does not require that Excel is installed. Actually you don't need to install anything besides the assemblies you reference in your project.
The SDK is much more powerful than the OLEDB provider but it probably also requires more effort to use.

Categories