oledb连接字符串为excel 2016在c# [英] oledb connection string for excel 2016 in c#
问题描述
我一直在试图访问2016年ms Excel文件使用c#,但连接字符串只工作到2013年ms excel。
我当前的连接字符串:
Provider = Microsoft.ACE.OLEDB.12.0;数据源= c:\myFolder\myExcel2007file.xlsx;
扩展属性=Excel 12.0 Xml; HDR = YES;
ms excel 2016有任何修改的oledb连接字符串吗?
任何帮助将是明显的,提前感谢。
这是通过Office 365程序从本地安装Office 13升级到Office 16后发生的。我得到这个异常:'Microsoft.ACE.OLEDB.12.0'提供程序没有在本地机器上注册。
我无法找到一种安装方式该驱动程序通过Office 365安装过程。
我不得不安装 https://www.microsoft.com/en-us/download/details.aspx?id=13255 - x64版本没有解决问题,
我在App.config中的连接字符串
< add key =Excel07ConnectionStringvalue =Provider = Microsoft.ACE.OLEDB.12.0;数据源= {0};扩展属性='Excel 8.0; HDR = YES'/>
使用它的代码:
var excelConnectionString = ConfigurationSettings.GetExcelConnection(fileLocation);
var dataTable = new DataTable();
使用(var excelConnection = new OleDbConnection(excelConnectionString))
{
excelConnection.Open();
var dataAdapter = new OleDbDataAdapter(SELECT * FROM [Users $],excelConnection);
dataAdapter.Fill(dataTable);
excelConnection.Close();
}
Console.WriteLine(OpenExcelFile:文件成功打开:+ fileLocation);
return dataTable;
I have been trying to access 2016 ms Excel file using c#, but connection string is working only till 2013 ms excel.
my current connection string: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx; Extended Properties="Excel 12.0 Xml;HDR=YES";
is there any modified oledb connection string for ms excel 2016?
any help would be appreciable, thanks in advance.
This occurred for me after upgrading from a local install of Office 13 to Office 16 through the Office 365 program. I was getting this exception: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
I was not able to find a way to install the driver through the office 365 install process.
I had to install https://www.microsoft.com/en-us/download/details.aspx?id=13255 - the x64 version did not solve the issue, had to use the 32bit version.
My connection string in App.config
<add key="Excel07ConnectionString" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"/>
Code using it:
var excelConnectionString = ConfigurationSettings.GetExcelConnection(fileLocation);
var dataTable = new DataTable();
using (var excelConnection = new OleDbConnection(excelConnectionString))
{
excelConnection.Open();
var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Users$]", excelConnection);
dataAdapter.Fill(dataTable);
excelConnection.Close();
}
Console.WriteLine("OpenExcelFile: File successfully opened:" + fileLocation);
return dataTable;
这篇关于oledb连接字符串为excel 2016在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!