开发者

Querying Excel Worksheets using LinQ - LinQToExcel

开发者 https://www.devze.com 2023-01-07 18:02 出处:网络
I\'m using LinQToExcel to read my excel worksheets.ExcelQueryFactory has amethod that 开发者_运维技巧returns a worksheet based on worksheet name(Only one value(Name) is allowed).There is also a method

I'm using LinQToExcel to read my excel worksheets.ExcelQueryFactory has a method that 开发者_运维技巧returns a worksheet based on worksheet name(Only one value(Name) is allowed).There is also a method that returns WorkSheet names. Is there a way to use LinQ to select multiple worksheet collection based on names.

ExcelQueryFactory test = new ExcelQueryFactory(FilePath); List names = targetExcelFactory.GetWorksheetNames().ToList(); var sheet = test.Worksheet("sheet1");


Enumerable.Select lets you turn the result from one set into a completely other set aka projection.

var result = targetExcelFactory.GetWorksheetNames()
  .Select(name => test.Worksheet(name))
  .ToList();
0

精彩评论

暂无评论...
验证码 换一张
取 消