1

I have been using the method to import excel data to my WPF application as mentioned in

Import Excel file into Microsoft SQL Server using C# and Reading Excel files from C#

it works great on debug mode but on release mode it dies!

The problem is my client has moved to x64 based machines and the application works fine but just that this piece of code is not working on x64 just because there is no more "Microsoft .Jet.OLEDB.4.0" drivers made available for x64 machines any more.

I dont want to use office interop or provide any dependency for the user to have office installed on the machines.

So any suggestion to avoid this?

Community
  • 1
  • 1
aioracle
  • 371
  • 2
  • 7
  • 20

3 Answers3

2

Try using Microsoft.Ace.OLEDB.12.0 drivers instead

When we started upgrading all our machines, all my queries using Microsoft.Jet.OLEDB.4.0 stopped working and I had to upgrade them to use Microsoft.Ace.OLEDB.12.0. You shouldn't need to do anything other than change your connection string for it to work.

Rachel
  • 130,264
  • 66
  • 304
  • 490
  • Thank you Rachel! This solved my issues. Though I had some issue initially installing the OLEDB.12.0 on my machine but later complied my service and application to x86 and worked like a charm! – aioracle Dec 14 '12 at 08:11
0

You could also try using the OpenXML SDK 2.0!

Here's an article that explains reading an excel file using the SDK: http://debugmode.net/2011/10/08/reading-excel-file-in-a-collection-using-open-xml-sdk-2-0/

Getting started and best practices: http://blogs.msdn.com/b/erikaehrli/archive/2009/05/14/open-xml-format-sdk-2-0-getting-started-best-practices.aspx

Hope this helps! ;)

Abbas
  • 14,186
  • 6
  • 41
  • 72
0

I am using Aspose.cells library. It works pretty good and really easy to work. you can give it a try! http://www.aspose.com/.net/excel-component.aspx

Ehsan
  • 4,334
  • 7
  • 39
  • 59