Tag: linq to excel

获取“找不到源types为”ExcelQueryable <T>“的查询模式的实现。 “错误

我正在使用LinqToExcel Nuget包来读取excel文件。 以下是我的代码 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; } […]

LinqToExcel有时导致IErrorInfo.GetDescription失败,并且E_FAIL(0x80004005)

有时,在运行下面的代码时,会导致IErrorInfo.GetDescription failed with E_FAIL(0x80004005)在调用excelFile.WorksheetNoHeader(0) IErrorInfo.GetDescription failed with E_FAIL(0x80004005)的错误。 它似乎不依赖于excel文件,一个文件可以一次读取,下一次不可读取。 任何想法可能是什么原因? Public Overrides Function GetImportDataAsDataTable() As DataTable Dim dataTable = New DataTable dataTable.BeginLoadData() Try Dim excelFile = New ExcelQueryFactory(FileFullPath) For Each importDataRow In excelFile.WorksheetNoHeader(0) If dataTable.Columns.Count = 0 Then For i = 1 To importDataRow.Count dataTable.Columns.Add(New DataColumn()) Next End If Dim dataRow = dataTable.NewRow dataRow.ItemArray = […]

如何通过LinqToExcel查询单元格格式

我使用LinqPad与Linq2Excel一起在Excel电子表格(由他人编写和拥有)上进行我自己的数据分析。 这些其他人使用大量的单元格格式来表示数据。 例如,灰色背景单元表示“不适用”; 文本格式==删除线意味着“取代”。 有没有办法在LinqToExcel获得这些格式的值,所以我可以过滤它们?

ExcelQueryFactory读取密码保护的Excel

如何使用ExcelQueryFactory读取密码保护的Excel工作簿? 使用下面的代码,我可以在不使用密码保护的情况下阅读excel。 var excel = new ExcelQueryFactory(); excel.FileName = "path of excel file"; 但是当excel被密码保护时,上面的代码就失败了。

LinqToExcel重复列名称

我有一台机器生成的Excel文件,有几个同名的列。 例如: ABCD Group 1 Group 2 Period | Name Period | Name 我有这样一个DTO: [ExcelColumn("Period")] public string FirstPeriod { get; set; } [ExcelColumn("Name")] public string FirstName { get; set; } [ExcelColumn("Period")] public string SecondPeriod { get; set; } [ExcelColumn("Name")] public string SecondName { get; set; } 我使用以下命令来读取行: var excel = new ExcelQueryFactory(filePath); excel.WorksheetRange<T>(beginCell, endColl + […]

LinqToExcel获取超链接值

我正在使用LinqToExcel来读取一个Excel文件。 一切工作正常,但它的单元格的内容是一个超链接,我只得到超链接文本。 我想获得它的url/电子邮件。 try { // Connection to the DB iRentDB db = new iRentDB(); // Get excel file and work sheet string pathToExcelFile = @"Members_Export_1500068180.xls"; string sheetName = "Members_Export_1500068180"; var excelFile = new LinqToExcel.ExcelQueryFactory(pathToExcelFile); // Select all rows from Excel var rows = from c in excelFile.WorksheetNoHeader(sheetName) select c; foreach (var row in rows) […]

Linq to Excel – 仅接收来自sheet1中最后一行的数据

在尝试使用ADO.NET查询Excel电子表格之后,我决定在我的项目中尝试使用Linq到Excel 。 我创build了一个方法,它应该返回列B的值,当我提供相应的列A(两个在同一行)的值。 Sheet1有一个标题行或至less一行,指示列A和B是什么。 当我将我的代码与一个基本的linq查询结合起来检索数据时,我只能从最后一行获取数据,而不pipe列AI中的值是什么。 它总是最后一排。 在我的工作表中有1159行。 电子表格是Excel 2010,所以数据引擎应该是我所设想的ACE。 这是我的代码… public static string ReturnDefinition(string remCode) { string strReturnMessage = ""; string pathToExcelFile = @"MEDICARE.xlsx"; string sheetName = "sheet1"; var excelFile = new ExcelQueryFactory(pathToExcelFile); var codeDescriptions = from a in excelFile.Worksheet(sheetName) select a; try { foreach (var a in codeDescriptions) { if (a["Code"].ToString().Contains(remCode)) { strReturnMessage = […]

通过Linq更改Excel工作表的列名或属性

我想知道如何将工作表的列名或属性提高到大写字母而不知道有多less内容或内容是什么? 我目前的代码如下: var excel = new ExcelQueryFactory(fileLocation); var dataSheet = from c in excel.Worksheet(0) select c;

LinqToExcel C# – 如何不读空行

我想从一个看起来像这样的Excel表中读取数据: 工作表名称是"Data" 。 我将数据存储到List<ExcelData> 。 然后我做一个List.Count , 即使我只有11个非空行 , 它是超过11。 public class ExcelData { public string Id { get; set; } public string FgCmd { get; set; } public string SwCmd { get; set; } } public void PrintExcelTable() { var excelFile = new ExcelQueryFactory(@"C:\sample.xlsx"); var tableData = from z in excelFile.Worksheet<ExcelData>("Data") select z; var […]

使用linqtoexcel获取excel文件中的所有值

我在我的asp.net mvc 4项目中使用linqtoexcel来读取一个excel文件,并从那里获取所有的值。 但是我只得到最后一行的值。 这是我的代码, 调节器 public ActionResult ExcelRead() { string pathToExcelFile = "" + @"C:\MyFolder\ProjectFolder\sample.xlsx"; string sheetName = "Sheet1"; var excelFile = new ExcelQueryFactory(pathToExcelFile); var getData = from a in excelFile.Worksheet(sheetName) select a; foreach (var a in getData) { string getInfo = "Name: "+ a["Name"] +"; Amount: "+ a["Amount"] +">> "; ViewBag.excelRead = getInfo; […]