Linq to Excel问题

我映射出我的Excel中的所有列,然后我尝试使用此读取工作表

var file = theFile.Worksheet<myClass>("worksheetTitle").OrderBy(p => p.columnHeader).ToList(); 

这是我得到的错误:

  System.Data.OleDb.OleDbException (0x80040E57): The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. at LinqToExcel.Query.ExcelQueryExecutor.GetDataResults(SqlParts sql, QueryModel queryModel) at LinqToExcel.Query.ExcelQueryExecutor.ExecuteCollection[T](QueryModel queryModel) at Remotion.Data.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteCollectionQueryModel[T](QueryModel queryModel, IQueryExecutor executor) at Remotion.Data.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteQueryModel(QueryModel queryModel, IQueryExecutor executor) at Remotion.Data.Linq.QueryModel.Execute(IQueryExecutor executor) at Remotion.Data.Linq.QueryProviderBase.Execute[TResult](Expression expression) at Remotion.Data.Linq.QueryableBase`1.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 

这是Excel ODBC驱动程序的问题,通常可以通过重新sorting电子表格中的logging来解决。Excel ODBC驱动程序必须对给定列的数据types作出假设。 司机通过提前阅读8条logging并查看find的数据来做到这一点。 然后根据读取的内容决定数据types。 当关于数据types的假设被随后的loggingcertificate是错误的时候会出现问题。 Excel电子表格中的列中包含一个包含string数据的列。 前8个logging包含短string。 Excel ODBC驱动程序读取此数据,并假定短string数据types适合此列。 如果后续logging包含更长的string。 数据types可能被certificate是不合适的,无法存储较长的string,Excel ODBC驱动程序会提示错误。 用长string将logging移动到数据集的开头将允许Excel ODBC为该列select更适合的数据types,该数据types将应用于电子表格中的所有logging。

在所有情况下,该技术都是安排logging的顺序,以使Excel ODBC驱动程序可以正确select数据types。