简体   繁体   English

使用LinqToExcel读取另存为xls的xlsx

[英]Reading xlsx saved as xls with LinqToExcel

Look at this post: Excel "External table is not in the expected format." 看一下这篇文章: Excel“外部表不是预期的格式。”

I have the same problem depicted in that post but I'm using LinqtoExcel to read the file instead of plain queries. 我在那篇文章中描述了同样的问题,但是我正在使用LinqtoExcel读取文件,而不是简单的查询。

What would be the LinqToExcel equivalent for setting the connection string as the answer to that post suggests? 设置连接字符串作为该帖子的答案所暗示的LinqToExcel等效项是什么?

Here is the code I'm using: 这是我正在使用的代码:

var excelOM = new ExcelQueryFactory(pPathArchivoOM);
var despachosClient = from c in excelOM.Worksheet<RegistroDespachoOM>("Tabla_1")
                         where c.DESTINAT.Contains("SOMETEXT")
                         select c;
//Identificar los despachos asociados a números de documento sin datos aún.
foreach (RegistroDespachoOM despacho in despachosClient)
{ ...

And my problem is: "External table is not in the expected format" in the foreach start. 我的问题是:foreach开始时“外部表未采用预期的格式”。

EDIT (my problem is solved but the question remains unanswered): I'm using EPPlus instead of LinqToExcel for this task and all is working OK now. 编辑(我的问题已解决,但问题仍未得到解决):我正在使用EPPlus而不是LinqToExcel来完成此任务,现在一切正常。

You will need to use the ACE database engine instead of the JET database engine. 您将需要使用ACE数据库引擎而不是JET数据库引擎。

You can do this with LinqToExcel by setting the DatabaseEngine property. 您可以通过设置DatabaseEngine属性使用LinqToExcel进行此操作。 Here's an example 这是一个例子

var excelOM = new ExcelQueryFactory(pPathArchivoOM);
excelOM.DatabaseEngine = DatabaseEngine.Ace;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM