2017-11-28 1 views
1

Excel에서 LinqToExcel Nuget 패키지를 사용하여 Excel 파일을 읽습니다."소스 유형 'ExcelQueryable '에 대한 쿼리 패턴 구현을 찾을 수 없습니다."오류

다음은 내 코드

  var excelFile = new ExcelQueryFactory("DeployQueues"); 

     var tableData = from z in excelFile.Worksheet<AllQueues>("Data") 
         select z; 

입니다하지만 컴파일러 오류가 아래 얻고있다.

Could not find an implementation of the query pattern for source type 
'ExcelQueryable<AllQueues> 

class for AllQueues 

public class AllQueues 
{ 
    [ExcelColumn("Company Title")] 
    public string Name { get; set; } 

    [ExcelColumn("Providence")] 
    public string State { get; set; } 

    [ExcelColumn("Employee Count")] 
    public string Employees { get; set; } 

} 

답변

0

추가 참조 Remotion.Data.Linq.dll. Nuget에서 찾을 수 있습니다.

https://staging.nuget.org/packages/Remotion.Data.Linq/

+0

이제 오류는 제거되었지만 다른 오류가 발생합니다. " 'QueryableBase <>'형식이 참조되지 않은 어셈블리에 정의되어 있습니다. 'Remotion.Data.Linq"어셈블리에 대한 참조를 추가해야합니다. 이 참조를 추가했지만 여전히이 오류가 발생했습니다. – ABB

+0

프로젝트의 목표 프레임 워크입니까? – lucky

+0

.Net framework 4.5.2 – ABB

0

나는 LINQToExcel을 사용하는 문서가 좋지 않다라고 생각합니다.

아래 코드를 사용했습니다.

 string fileName = @"YouPath"; 
     string conn = string.Empty; 
     DataTable dtexcel = new DataTable(); 
     conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName 
     + ";Extended Properties='Excel 12.0;HDR=NO';"; //for above excel 
     2007 

     using (OleDbConnection con = new OleDbConnection(conn)) 
     { 
      con.Open(); 
      DataTable Sheets = 
      con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); 

      try 
      { 
       OleDbDataAdapter oleAdpt = new OleDbDataAdapter("select * 
       from [WorksheetName$]", con); //here we read data from 
       sheet1 
       oleAdpt.Fill(dtexcel); //fill excel data into dataTable 
      } 
      catch (Exception ex) 
      { 
      } 
     } 
     return dtexcel; 
관련 문제