last day (15 days later) » 

14:07
1
Q: How to read key value pairs from excel sheet using c#?

user3879057I'm new to C#. I have used the code below to read data from Excel, but I need help modifying it to read key-value pairs. public String getData(int row, int col, String var) { Excel.Application excelApp = new Excel.Application(); if (excelApp != null) { List<string> prop = new...

TaW
TaW
How do they look in the excel sheet?
First coulmn with all thekeys and 2nd column with relevant values
TaW
TaW
So, what is the issue: Reading a cell, reading two cells or reading a range of pairs of cells? It really shouldn't be different from reading any other data as in many examples out there..
rather then passing row and column i want to read the value when key is passed as a parameter
TaW
TaW
Ah, ok. I wouldn't do the lookup in excel but pull all into one dictionary, but it really depends on how many data there are and how often you need to access them. For direct access this or this may help..
14:07
Is there any way to return row and column of a specific value?
TaW
TaW
Hi. I postend an example. Does it help?
I would assume you know the colum, no?
we don't know column index or row index
TaW
TaW
Huh? didn't you write that the keys are in the 1st and the values in the 2nd column??
14:32
sorry we know the column but not the row
TaW
TaW
Well, if you know the range where the keys are, my post should help you find the row. If you don't know the keys' range you could search the whole column, I belive by creating the range just from the column like so: Excel.Range range1 = ws.Range["C:C"];
it seem you are correct. i'm checking it and let u know
thanks for your help
It worked. Thank you so much
TaW
TaW
14:52
Glad to be of help.. Bye!

last day (15 days later) »