I have the following code snippet that connects to excel, where it will exclude data from a tab in a spreadsheet.
private void AtualizarPerformanceEntrega()
{
try
{
string sFileXLSX = Server.MapPath("ExportPerformanceEntrega");
string strConnXLSX = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + sFileXLSX + "';Extended Properties=Excel 12.0;";
using (OleDbConnection connection = new OleDbConnection(strConnXLSX))
{
//SQL para fazer o INSERT
string strSQL = "DELETE FROM [Base Entregue$]";
//Criando o OleDbCommand com o SQL e a conexão
OleDbCommand cmd = new OleDbCommand(strSQL, connection);
//Abrindo a conexão
connection.Open();
//Executando o INSERT
cmd.ExecuteNonQuery();
//Fechando a conexão
connection.Close();
}
}
catch (Exception ex)
{
throw ex;
}
}
But I get the following error:
"The Microsoft Office Access database engine could not find the object 'Base Provided1 $'. Make sure the object exists and that you spell its name and the path name correctly. "
Parameters of web.config
<add key ="ExportPerformanceEntrega" value="C:\Entrega\Performance.xlsx"/>
Name of the tab I want to exclude:
Obs.¹ This worksheet is blocked and whenever it opens it has to enable editing
Obs.² Maybe it's the name of the flap, because it's separate?