Dictionary<string,string> items = new Dictionary<string,string>();
IEnumerable<string> textvalues = from c in......//using linQ to query
string s = textvalues[items["book"]];
在这种情况下,textvalues阵列将接受一个整数值返回字符串我value.How可以得到项目编号,说:“项目”有5个itemNames中和“书”是在第一个位置的话,我必须得0 。所以textvalues [项目[“书”]]将被翻译为textvalues [项目[0]]有没有办法获得字典项目的订单号?
好吧,我想使用OpenXML 2.0来读取Excel.The点这里是没有办法,我可以指定一个字段名称并获取值。 所以我试图迭代工作表的第一行,将值添加到字典Dictionary fieldItems,以便当我说fieldItems [“状态”]它会检索我基于列号的单元格值,在我的情况下列标题name.ok这里是它的代码。
Dictionary<string, int> headers = new Dictionary<string, int>();
IEnumerable<string> ColumnHeaders = from cell in (from row in worksheet.Descendants<Row>()
where row.RowIndex == 1
select row).First().Descendants<Cell>()
where cell.CellValue != null
select
(cell.DataType != null
&& cell.DataType.HasValue
&& cell.DataType == CellValues.SharedString
? sharedString.ChildElements[
int.Parse(cell.CellValue.InnerText)].InnerText
: cell.CellValue.InnerText);
int i=0;
Parallel.ForEach(ColumnHeaders, x => { headers.Add(x,i++); });
order.Number = textValues[headers["Number"]];
IEnumerable是否有索引存取?您可能需要以某种方式使用IList 。 –
2010-07-22 10:06:52
IEnumerable没有索引存取器。 –
TheFogger
2010-07-22 10:28:03
目前还不清楚什么是文字值,但我已经编辑了我的答案*可能*帮助你... – 2010-07-22 10:31:11