I am getting a problem whilst inserting textbox data into an excel file... the error which keeps showing is given below. What changes should I make in order to successfully insert my data into the xls
file?
ERROR:
Property, indexer, or event 'Range' is not supported by the language; try directly calling accessor method 'Microsoft.Office.Interop.Excel._Worksheet.get_Range(object, object)'
private void btnAdd_Click(object sender, EventArgs e)
{
int _lastRow = xlWorkSheet.Range["A"+xlWorkSheet.Rows.Count].End[Excel.XlDirection.xlUp].Row + 1 ;
xlWorkSheet.Cells[_lastRow, 1] = textBox1.Text;
xlWorkSheet.Cells[_lastRow, 2] = textBox2.Text;
xlWorkSheet.Cells[_lastRow, 3] = textBox3.Text;
xlWorkSheet.Cells[_lastRow, 4] = textBox4.Text;
The error occurs on the following line:
int _lastRow = xlWorkSheet.Range["A"+xlWorkSheet.Rows.Count].End[Excel.XlDirection.xlUp].Row + 1 ;