OleDB与Excel的连接问题 [英] Issue with OleDB connection with Excel
本文介绍了OleDB与Excel的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我需要将数据写入excel文件.我创建了一个小型控制台应用程序以测试功能.我只是从教程中复制了连接代码.
So I need to write data to an excel file. I created a small console application to test out the functionality. I just copied the connection code from a tutorial.
excelConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + file + "';Extended Properties=Excel 8.0;");
excelCommand = new System.Data.OleDb.OleDbCommand();
excelConnection.Open();
excelCommand.Connection = excelConnection;
推荐答案
我认为问题出在您的连接字符串上.尝试使用ACE OLEDB提供程序代替Jet OLEDB提供商.像下面一样,
I think problem is with your connection string. Try Using ACE OLEDB provider instead of Jet OLEDB provider. Like below,
string connestionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties=Excel 12.0"
这篇关于OleDB与Excel的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文