Strange error on line XLWorkbook

-1

Follow the code:

protected void importar_Click(object sender, EventArgs e)
{
    if (selecionarArquivo.HasFile)
    {
        if (Path.GetExtension(selecionarArquivo.FileName) != ".xlsx" && Path.GetExtension(selecionarArquivo.FileName) != ".xls")
            ClientScript.RegisterStartupScript(typeof(string), "Erro", "<script>alert('Somente arquivos em excel')</script>");
        else
        {
            if (selecionarArquivo.FileContent != null)
            {

                var wb = new XLWorkbook(selecionarArquivo.FileContent);
                var planilha = wb.Worksheet(1);

                var linha = 1;
                while (true)
                {
                    //aqui vc vai pegar os campos que deseja atrave da especificação da Coluna e da Linha
                    var nome = planilha.Cell("A" + 6.ToString()).Value.ToString();
                    break;
                }

                var cont = 1;
                //var ListaAplImportProcesso = new List<AplImportProcesso>();
                foreach (var x in planilha.RowsUsed())
                {
                    ListaAplImportProcesso.Add(new AplImportProcesso
                    {
                        dataDeRequisicaoPgto = Convert.ToDateTime.Cell(cont),
                        NumeroProcessoAnterior = x.Cell(cont + 1).GetString()
                    });
                    cont++;
                }
            }
        }
    }
}

    
asked by anonymous 28.02.2018 / 13:04

1 answer

0

As you did not install the package then you do not have the appropriate DLLs. By not having these DLLs you will get the specified error

  

Type or namespace 'XLWorkbook' could not be found.

In Solution Explorer > References > Right-click mouse > Add Reference > COM Menu > Look for Microsoft Excel 16.0 Object Library (or less depending on your Excel).

    
28.02.2018 / 17:32