C # Oledb truncating column excel

1

I'm doing a select in an excel where I have an observation column (open text). The problem is that on some lines it truncates the contents of that column by bringing only one part.

try
{
    conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Downloads") + @"\RelPosicaoGeralPendencias.xls;Extended Properties='Excel 8.0;HDR=Yes;'");
    conn.Open();

    cmd = new OleDbCommand("SELECT * FROM [RelPosicaoGeralPendencias$]", conn);

    reader = cmd.ExecuteReader();

    listaPendenciaNassau = new List<Pendencia>();

    while (reader.Read())
    {
        if (!(reader[6] is DBNull))
        {
            Pendencia pendencia = new Pendencia();

            pendencia.Contrato = reader[2] is DBNull ? null : reader[2].ToString().Replace("'", "").Trim();
            pendencia.Tipo = reader[3] is DBNull ? null : reader[3].ToString().Trim();
            pendencia.PendenciaNivel = reader[5] is DBNull ? null : reader[5].ToString().Trim();
            pendencia.PendenciaId = reader[6] is DBNull ? 0 : Convert.ToInt32(reader[6]);
            pendencia.PendenciaTipo = reader[8] is DBNull ? null : reader[8].ToString().Trim();
            pendencia.GarantiaDescricao = reader[9] is DBNull ? null : reader[9].ToString().Trim();
            pendencia.Observacao = reader[10] is DBNull ? null : reader[10].ToString().Replace("'", "").Trim();
        }
    }
}

Example text:

No excel:

Pending remains. The committed referrals are 2012 expired and are not in accordance with current rules so we can abide by.

COMPANY IMPORT AND EXPORT LTDA.

Signature So-and-so.

Pending: Send authorization from the majority of the share capital.

COMPANY EXPORTS AND IMPORTS LTD.

Signature: Beltran.

Pending: Send authorization of 3/4 of the share capital. COMPANY OF HORTIFRUTIGRANJEIROS LTDA

Signature: Cicrano.

Pending: Send authorization of the majority of the share capital COMPANY PRODUCTS AND DISTRIBUTION AGRICULTURAL LTD

Signature: So-and-so of Beltran.

Pending: Submit the current social contract and power of attorney granting power to provide support to third parties in isolation. Please forward the corporate documentation to the area of powers.

No c #:

Pending remains. The forwarded authorizations are 2012 expired and are not in accordance with the current rules so that we can comply. \ N \ n \ nEUROPE IMPORTACAO E EXPORTACAO LTDA. \ N \ nFullano. \ N \ nPendência: Send aut

    
asked by anonymous 10.04.2017 / 22:40

1 answer

1

Based on the information in the link below, which says that the ODBC driver performs an analysis through the first 9 rows of each column to define the data type of the column, thus defining with the Text instead of Memo, I created a mechanism for insert 320 headstones in front of the text of the observation column and after doing the select in excel remove the headers.

link

    
11.04.2017 / 19:35