C# Oledb截断excel列

C# Oledb截断excel列,c#,excel,oledb,C#,Excel,Oledb,我在excel文件中有一个select,其中有一个名为ObservationOpenText的列。问题是,在某些行中,它构建了专栏的内容,只为我带来了部分内容 try { conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Downloads")

我在excel文件中有一个select,其中有一个名为ObservationOpenText的列。问题是,在某些行中,它构建了专栏的内容,只为我带来了部分内容

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();
        }
    }
}
文本示例:

卓越:

作为一种永久性的自由。正如2012年《圣约全书》中的《圣约全书》所述,该书中的《圣约全书》中的《圣约全书》中的《圣约全书》中的《圣约全书》中的《圣约全书》中的《圣约全书》中的《圣约全书》和《圣约全书》中的《圣约全书》中的《圣约全书》中的《圣约全书》一样

进出口贸易公司

富拉诺助教

Pendència:Enviar autorizaèo da maioria do capital social

出口和进口公司

助理:贝尔特拉诺

Pendència:Enviar autorizaèo de 3/4做社会资本。霍尔蒂夫鲁蒂格兰杰罗斯酒店

助理:西克拉诺

Pendència:Enviar ata de autorizaèo da maioria do capital social EMPRESA PROD.E Distributièo AGRICOLA LTDA

助理:富拉诺·德·贝尔特拉诺

潘登西亚:环境与社会活力的对立,这是一种形式上的对立。赞成的话,这是一份社会文件

C:


作为一种永久性的自由。作为2012年圣安东尼奥·文瑟拉姆·埃斯特朗·德·阿科多公司的自动包装,OleDB驱动程序根据前8行数据确定列的字段类型。如果观察列没有任何长度大于255的单元格,则它将确定这是一个字符串列,并忽略该列中较长的文本。尝试添加一个包含255个字符以上文本的虚拟第一行,以欺骗驱动程序确定此列包含长文本。