0
以前我的C#應用程序使用此命令創建一個Excel文件:如何在C#中創建Excel文件; Office 2007; Win 7 64bit?
try
{
//SELECT INTO command
string cnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AccfilePath +
";Persist Security Info=False";
ConnOpen(cnStr);
using (connectionToDatabase)
{
//Give the Export Table (destination) a Name
//baseTblName = dt.TableName;
//Generate the SQL string to SELECT * INTO the NEW table in destination
string selectcmd = "SELECT * INTO [Excel 12.0;Database=c:\\"+ExfilePath+"]." + tblName + " FROM " + tblName;
using (OleDbCommand createCmd = new OleDbCommand(selectcmd, connectionToDatabase))
{
createCmd.ExecuteNonQuery();
}
ConnClose();
}
}
我已經轉移到Win 7的64位和OleDbCommand的,現在給了我一個「失敗創建文件」。我甚至已經讓用戶成爲管理員,因爲我認爲這是一個安全問題。