I'm stuck in an easy task: convert an multidimensional Array (Object[,]) in a monodimensional string[].
Long story short: I'm reading an excel file using a com library which returns a dynamic type casted to Object[,] at runtime.
SortedSet<string> rows = new SortedSet<string>();
for (int i = 3; i <= 5; i++)
{
Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A"+i, "J"+i);
Array cells = (Array) range.Cells.Value; // value return dynamic [,] -> Object[,] -> cast to Array[,]
string[] rowCells = ConvertArrayToStringArray(cells); //
rows.Add(string.Join("\t", rowCells));
}
return string.Join("\r\n", rows);
Since Array[,] always have 1 row (I read the excel file row by row) I'd like to cast it to a simple string[] (or List) without using another loop in ConvertArrayToStringArray function.
I could read all cells in an action (not row by row like in code above), but I've no idea of how many rows are in excel file.
I appreciate any help