Search code examples
asp.net.netexceloledb

Reading Excel: Column Names truncated to first 64 characters


I am trying to read an excel spreadsheet through .NET (C#)

Below is a Connection string I use:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Windows\TEMP\96e7a8b720b642388d9dbbca49537678.xls; Extended Properties="Excel 8.0;HDR=Yes;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text";

When I had a look at the schema using:

using (var conn = new OleDbConnection(connStr))
        {
            conn.Open();
            result[OleDbSchemaGuid.Tables] = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            result[OleDbSchemaGuid.Columns] = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null);
            result[OleDbSchemaGuid.Tables_Info] = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info, null);
            conn.Close();
        }

In result[OleDbSchemaGuid.Columns] - all column names are truncated to the first 64 characters.

I need full names of all columns.

Any idea to workaround / solve this issue ?

Much appreciated for viewing this question.


Solution

  • Tim is right, as per this discussion on MSDN. you need to use some third party data access provider as this is the limit for Jet.

    EDIT:

    It can be done without using any third party provider as well. I read this Today on Microsoft's Support Site. According to them its limitation of Jet 4.0LEDB Source.