When you use OLE DB to manipulate Excel, you are prompted for this error when you delete a table in Excel. Very strange (just as well, Microsoft's things like to give some inexplicable error hints), yesterday can be deleted, today will not delete (just yesterday to today there is really a big deal.) The system Ghost to the SSD, but the operation of the Excel file path has not changed.
specific error message:
{System.Data.OleDb.OleDbException (0x80004005): The cell of the spreadsheet cannot be deleted.
At System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling (Oledbhresult hr)
In System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult (Tagdbparams dbparams, object& executeresult )
In System.Data.OleDb.OleDbCommand.ExecuteCommandText (object& executeresult)
In System.Data.OleDb.OleDbCommand.ExecuteCommand (CommandBehavior behavior, object& executeresult)
In System.Data.OleDb.OleDbCommand.ExecuteReaderInternal (CommandBehavior behavior, String method)
In System.Data.OleDb.OleDbCommand.ExecuteNonQuery ()
In Roadmap_Excel.Form1.button2_Click (Object sender, EventArgs e)
Related code:
Connection string:
//定义OleDB连接字符串 string"Provider=Microsoft.Ace.OleDb.12.0;Persist Security Info=False;""data source="@excelPath";Extended Properties=‘Excel 12.0; HDR=yes; IMEX=10‘"; new OleDbConnection(); conn.ConnectionString = strConn;
To run the deleted code:
Try{cmd =NewOleDbCommand ("Drop Table ["+ Roadmaptablename +"]", conn); Cmd. ExecuteNonQuery (); }Catch(System.ExceptionEx) {TextBox1.Text + = ("Delete data table failed:"+ ex. Message); TextBox1.Text + = ("\ r \ n");//The ISAM does not support the deletion of data in linked tables. cmd =NewOleDbCommand ("Delete from ["+ Roadmaptablename +"]", conn); Cmd. ExecuteNonQuery (); }
Really can't find the reason, then delete it manually.
No solution has been found at the moment, and there are no web searches on the Internet.
You cannot delete cells from a spreadsheet