I study about Excel Read in C# but I can't Casting object[,] to double[,]
double[,] array;
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object[,] temp;
private void button1_Click(object sender, EventArgs e)
{
String path = "C:\\Users\\Bob\\Desktop\\abcd.xlsx";
//Excel.Range range;
ReadExcelData(path);
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(path, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
GetTotalValue(xlWorkSheet);
}
in this Code GetTotalValue(xlWorksheet) is getExcelValue
private object[,] GetTotalValue(Worksheet sheet)
{
Range usedRange = sheet.UsedRange;
Range lastCell = usedRange.SpecialCells(XlCellType.xlCellTypeLastCell);
MessageBox.Show(lastCell.Cells.Row.ToString());
MessageBox.Show(lastCell.Cells.Column.ToString());
Range totalRange = sheet.get_Range(sheet.get_Range("A1"), lastCell);
return (object[,])totalRange.get_Value();
}//end
I try Array.Copy but this method is Copy Only Array[] so I Can't Solve the this problem