Wednesday, 8 August 2012

RUNTIME ERROR : "object does not contain a definition for get_Range" in MS Excel

 Microsoft.Office.Interop.Excel.Range myrange = excelsheet.get_Range(excelsheet.Cells[1, 1], excelsheet.Cells[this.dataGridView1.RowCount + 1, this.dataGridView1.Columns.Count]);


 Solution:

Include (object) as shown in the below line....................



 Microsoft.Office.Interop.Excel.Range myrange = excelsheet.get_Range((object)excelsheet.Cells[1, 1], (object)excelsheet.Cells[this.dataGridView1.RowCount + 1, this.dataGridView1.Columns.Count]);


No comments:

Post a Comment

back to top