出错 - 使用C#linqtoexcel [英] Error with - linqtoexcel with C#

查看:155
本文介绍了出错 - 使用C#linqtoexcel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi All,

I have just started learning c# with VS2013.
I am  a tester and learning CodedUI.
I am also learning linqtoexcel to read/write values from XLS.

My objective is to read rows based on some criteria. As a beginning step, I have written the code below to read values from two cells with headers- ID and Name:

However, I am getting an error in 'foreach':
SystemArgumentExcpetion: {"Format of the initialization string does not conform to specification starting at index 54."}





public void da(){

var excel = new ExcelQueryFactory(D:\\b.xlsx);

var largeCompanies = from excel.Worksheet()中的c

其中c [ID]。Cast< int>()> 1

选择c;



foreach(var c in largeCompanies)

{

string artistInfo =ID:{0};名称:{1};

Console.WriteLine(string.Format(artistInfo,c [ID]。Cast< int>() ,c [名称]));

}}



public void da() {
var excel = new ExcelQueryFactory("D:\\b.xlsx");
var largeCompanies = from c in excel.Worksheet()
where c["ID"].Cast<int>() > 1
select c;

foreach (var c in largeCompanies)
{
string artistInfo = "ID: {0}; Name: {1}";
Console.WriteLine(string.Format(artistInfo, c["ID"].Cast<int>(), c["Name"]));
} }

推荐答案

谢谢,这是纯语法问题,甚至没有连接到xls。
Thanks, it is pure syntax issue, and not even connecting to the xls.


我认为它甚至无法连接到Excel工作表并选择数据源。需要内部异常和堆栈跟踪细节。
I think its not even able to connect to the excel sheet and select the data source. Need inner exception and stack trace details.


这篇关于出错 - 使用C#linqtoexcel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆