c# - Excel: Values from Ranges With Multiple Areas -


i values of non contiguous, multi area range in excel using c#. have seen another question says can this:

obj[,] data = sheet.get_range("b4:k4,b5:k5").get_value(); 

however, when examine result see data first area: "b4:k4".

testing further, found if request data in following way:

obj[,] data = sheet.get_range( "b4:k4","b5:k5").get_value(); 

i data both areas...

so, question is, there way programmatically combine area addresses such "b4:k4,b5:k5" in order of data refer?

thanks

the solution came isn't elegant have liked trick nonetheless:

public list<list<object>>  getnoncontiguousrowvalue(excel.worksheet ws, string noncontiguous_address) {     var addresses = noncontiguous_address.split(','); // e.g. "a1:d1,a4:d4"     var row_data = new list<list<object>>();      // value of 1 row @ time:     foreach (var addr in addresses)     {         object[,] arr = ws.get_range(addr).value;         list<object> row = arr.cast<object>)                               .take(arr.getlength(dimension:1))                               .tolist<object>();         row_data.add(row);     }     return row_data; } 

hope helps else...


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -