I need to give the value of Range into a multidimensional object but error occurs:
Cannot implicitly convert type object
to object[*,*]
. An explicit conversion exists (are you missing a cast?)
Here is the code:
Excel.Application oXL = new Excel.Application();
Excel.Workbook oWB = oXL.Workbooks.Open(rtbExcelPath.Text.Trim(), Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
Excel.Worksheet oWS = oWB.Worksheets[1] as Excel.Worksheet;
int countRows = oWS.UsedRange.Rows.Count;
int countColumns = oWS.UsedRange.Columns.Count;
object[,] data = oWS.Range[oWS.Cells[1, 1], oWS.Cells[countRows,
countColumns]].Cells.Value2;
Please help to check what is wrong... :(