Oledb does not work on other machines

Asked

Viewed 17 times

1

I made a WPF application and at some point it should read an Excel file. I did this through Oledb. The file is in the same application folder.
The application works perfectly with me but does not connect to Excel when run by another user.
The application is in a folder on the server.
At first I thought it might be something related to the office version (I saw many cases on the internet), but the version is the same for everyone, 32 bits. Detail: gives no error message, just nothing happens.

string arquivo = "Indices.xlsx";
string stringConnection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + arquivo + ";Extended Properties='Excel 12.0 Macro;HDR=YES'";
OleDbConnection conexao = new OleDbConnection(stringConnection);
                OleDbDataAdapter adapter = new OleDbDataAdapter("select * from [Planilha1$]", conexao);
AbrirArquivoIndices(arquivo, conexao, adapter, tabelaIndices);
adapter.Dispose();
conexao.Dispose();

private void AbrirArquivoIndices(string arquivo, OleDbConnection conexao, OleDbDataAdapter adapter, DataTable tabelaIndices)
{
    
    try {
        
        conexao.Open();
        adapter.Fill(tabelaIndices);
    
    } catch (Exception) {
        
        throw new Exception("Não foi possível obter os índices para atualização.");
    
    } finally {
        
        conexao.Close();
    }
}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.