2017-11-28 20 views
1

私はLinqToExcel Nugetパッケージを使用してExcelファイルを読み込んでいます。「ソースタイプ「ExcelQueryable <T>」のクエリパターンの実装が見つかりませんでした。」エラー

以下は私のコード

  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」 私はこのrefernceを追加したが、それでも私は、このエラーに – 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; 
関連する問題