I am new to C# and I wanted to ask a question: I have an Excel file in which the first column is number of row second column is variable x(number) and third column is variable y(number) and I want to show variable x and y in textbooks, The rest of code that opens Excel is OK because it's working in another form, I use this code for it:
for (int i = 1; i <= 11; i++) //rowCount
{
if (xlRange.Cells[i, 1] != null && xlRange.Cells[i, 2].Value2 != null)
{
int x = xlRange.Rows[i - 1].Cells[1].Value = xlRange.Cells[1].Value2;
int y = xlRange.Rows[i - 1].Cells[2].Value = xlRange.Cells[2].Value2;
hodnotax.Text = x.ToString();
hodnotay.Text = y.ToString();
}
}
but in the final step, I get this error:
System.Runtime.InteropServices.COMException: 'Value-based exception HRESULT: 0x800A03EC'
and I don't know what to do with that code to make it work, thanks for every answer