开发者

OleDbConnection to an Excel stylesheet : what's the component behind the scene?

开发者 https://www.devze.com 2023-03-14 17:26 出处:网络
In my source code I need to read the content of an Excel 2007 stylesheet. So, I first set up an OleDbConnection to it :

In my source code I need to read the content of an Excel 2007 stylesheet. So, I first set up an OleDbConnection to it :

OleDbConnection conn = new OleDbConnection(String.Format(@"Provider = Microsoft.ACE.OLEDB.12.0;Data Source = {0};Extended Properties =""Excel 12.0 Xml;HDR=YES;IMEX=1"";", xlsFilePath));

This works perfectly on my computer, but not on the server once deployed : Microsoft.ACE.OLEDB.12.0 is not an available provider there. That's probably because I have Office 2007 on 开发者_开发问答my computer. Unfortunately, I'm not allowed to install it on the server.

Yet I could probably install only the dll containing the provider on the server and that would be ok... as long as I'd be able to know what that damned dll is !

That's where I tear my hair out : I can't find my way in the debug window's members tree to find out the actual component which is dynamically loaded to deal with the Excel 12.0 connection : which class ? Which assembly ? No idea, I'm lost.

Your help will be greatly appreciated ! :-)


I eventually fixed my problem by installing the drivers for Office 2007 on the server (the Office 2007 drivers don't involve the same problems as the Office 2007 applications in terms of licenses).

Here is the link : http://www.microsoft.com/download/en/confirmation.aspx?id=23734

Then I modified my connectionstring to

@"Provider = Microsoft.ACE.OLEDB.12.0;Data Source = {0};Extended Properties =""Excel 12.0 Xml;HDR=YES;IMEX=1"";"

Hope this will help someone facing the same questions. :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消