![](/img/trans.png)
[英]How do you select rows from an excel spreadsheet based off of a column value and insert it into dataGridViews?
[英]Select certain columns programmatically from Excel spreadsheet based on a common identifier
通过数据网格视图将Excel工作表导入Windows窗体后。 我需要选择各种列并将其发送到数据库。 如何基于公共标识符选择各种列?
Excel表格
如您在图像中看到的,我想根据标识符选择名称。 有什么办法可以解决这个问题?
这将根据标识符给出名称列表
var mainDict = new Dictionary<string, Dictionary<string, List<string>>>()
{
{"Group1", new Dictionary<string, List<string>>{{"A", new List<string> {"bob", "steve", "greg"}}}},
{"Group2", new Dictionary<string, List<string>>{{"B", new List<string> {"tom", "thomas", "justin", "lee"}}}},
{"Group3", new Dictionary<string, List<string>>{{"C", new List<string> { "dustin", "rick" }}}}
};
var namesA = from m in mainDict where m.Value.ContainsKey("A") select m.Value.Values.First();
var namesB = from m in mainDict where m.Value.ContainsKey("B") select m.Value.Values.First();
var namesC = from m in mainDict where m.Value.ContainsKey("C") select m.Value.Values.First();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.