input值到特定位置的Excel工作表通过linq excel在c#

我的Excel表格如下:

Id Name Status 1 XYZ 2 ABC 3 BB 1 Yz 

我想要做的是写我的C#应用​​程序中的状态列,其中Id是1。

我想通过Linq到Excel来做到这一点。 但是在这方面我没有得到任何积极的东西。

任何人都可以正确引导我。

谢谢。

因为Linq-To-Excel不写入电子表格( 参考 ),所以你在这里运气不好。 您唯一的select是强制input您的查询,修改内存中的结果并将其保存为.csv到您的硬盘 – 或者使用其他第三方库将更改写回到excel文件。

 public class Demo { public int ID { get; set; } public string Name { get; set; } public string Status { get; set; } } string pathToExcelFile = @"path\to\file.xslx"; string sheetName = "Tabelle1"; var excelFile = new ExcelQueryFactory(pathToExcelFile); //strongly type the result Demo rowToUpdate = (from xc in excelFile.Worksheet<Demo>(sheetName) where xc.ID == 1 select xc).FirstOrDefault(); //update retrieved record rowToUpdate.Status = "Active"; //output in linqpad rowToUpdate.Dump(); //no submitchanges or save method available :(