Alternative solutions to Microsoft.ACE.OLEDB.12.0 provider - c#

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.

Related

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).

Is there a way to avoid installing VS extensions like "SQLite for WinRT" for each teammember?

We are developing a Windows Store C#/XAML application that has to (among other things) interact with SQLite database and display Bing maps for specific GPS coordinates.
"Official" way to do this seems to be to install two Visual Studio extensions - SQLite for Windows Runtime and Bing Maps SDK. I have two problems with this approach:
It is necessary to install them separately on machine of each and every team member. With new PCs, VS reinstallations and people coming and leaving the project, this can get tedious really quickly.
Updates. Let's say I install a specific version of an extension and commit the project referencing that specific version. Then, a new team member comes in and I need to install the extension to his PC as well. However, in the meantime, Microsoft has released a newer version of the extension and I am unable to download the older one - and now, because of one new person, everyone has to update their extensions, too.
Ideally, what I'd like to do is to somehow put these extensions to SVN. That way, they are stored in one place only and there is no hassle with constant installations and updates. I was able to extract .dll files from SQLite extension, but with the Bing Maps, there is a .winmd file as well as a native .dll. I am unable to reference .winmd directly, and loading it dynamically is, as I've come to understand, not possible.
Is there some way to achieve what I want and avoid all outlined problems? I hope I am overlooking something, because I can't believe Microsoft would decide on something so stupid...
Yes, there is a way.
You will find the explanation and an example in this blog post by Oren Novotny: http://novotny.org/blog/how-to-use-extension-sdks-per-project
Kudos to the writer of this post, it saved me tons of work.
I had the same problem when trying to do CI with TFSBuild service in Visual Studio Online in a project that had Bing Maps. We can't install anything in the integration server because is cloud based, so I had to do a very long search to find the solution. It involves modifying the .sln file and putting the files in source control maintaining a precise folder structure, but when you do all this correctly it works like a charm.

Checking for Excel dll and loading dynamically

I am using Microsoft.Office.Interop.Excel for writing data to an Excel file, I have Excel 2010 installed on my machine. But I need the program to run on older versions of Excel..
The program should check the version installed in the particular machine and load the dll dynamically so as not to get a Missing Reference error..
If Excel 2003 is available, use it.
Else If a higher Excel version is available, use it
Else show an error message since this means that Excel is not installed in the machine
Is there a way to do this?
I am really having a hard time looking for a solution. Any help would be appreciated.
Thanks in advance..
Use NetOffice (http://msdn.microsoft.com/en-us/library/bb417255%28WinEmbedded.5%29.aspx), it really provides a nice abstraction to all Office Versions.

C# - Add reference for both MS Excel 12.0 object library and MS Excel 14.0 object library?

I have recently developed a small tool that uses Microsoft.Office.Excel.Interop, and according to my References folder I have added the reference to the Microsoft Excel 14.0 Object Library. I should also mention that I have MS Office 2010 on my machine, so the tool works just fine there.
However I have a client user that is trying to install the tool on his machine (apparently he has MS Office 2003 installed) and is getting an error message.
I was wondering, would there be any issues if I download the Microsoft Excel 12.0 Object Library and also add its Reference into my tool so that I have references to both, MS Excel 14 and MS Excel 12? ... would doing that even make sense?
Again, I'm fairly new to .NET and my programming experience is purely empirical, as in no school. Just a heads up in case this is a stupid question.
EDIT:
I found something that seems to solve this problem. I had my client download the file from this link: http://www.microsoft.com/en-us/download/details.aspx?id=3508
Then just follow the instructions at the bottom, and this apparently solved the problem. He was able to install the tool and run it without issues.
The best solution I have found is to use a virtual machine as a build machine that has the oldest version of the office Interop libraries installed that I care to support. I did run into a number of issues trying to develop with multiple interop versions on my development machine.
Microsoft does provide guidance on building clients for multiple office versions but I found that too cumbersome for my particular use case.
http://support.microsoft.com/default.aspx?kbid=244167
You also might consider skipping Interop entirely by using an alternative library, such as the open source EP Plus. I have not personally tried that one yet, but it looks promising.
http://epplus.codeplex.com/
There are some differences between the versions of the Interops. If you will use some members that were added in the newer version then the older versions won't work. For example here is a list of what all was added in Interop version 14:
http://msdn.microsoft.com/en-us/library/office/ff194938(v=office.14).aspx
If you use any of those your application won't work in older versions since these members were not available in older versions.

Microsoft.Office.Interop

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

Categories