I have been trying to figure this out for a while now. But solutions like this and this are not solving my problem.
I'm adding data from Database to Excel with the following code :-
//Adding Table values in Excel
            int sum = 0;
            object[,] arr = new object[result.Rows.Count, result.Columns.Count];
            for (int r = 0; r < result.Rows.Count; r++)
            {
                DataRow dr = result.Rows[r];
                for (int c = 0; c < result.Columns.Count; c++)
                {
                    arr[r, c] = dr[c];
                }
                    sum = sum + Convert.ToInt32(dr[5]);
            }
            Microsoft.Office.Interop.Excel.Range c3 = (Microsoft.Office.Interop.Excel.Range)ws.Cells[20, 1];
            Microsoft.Office.Interop.Excel.Range c4 = (Microsoft.Office.Interop.Excel.Range)ws.Cells[result.Rows.Count + 20, result.Columns.Count];
            Microsoft.Office.Interop.Excel.Range range1 = ws.get_Range(c3, c4);
            range1.Value = arr;
Now on the line range1.Value = arr; it is adding another row with all columns value as #N/A when I debug the code the value shown there is -2146826246.
First, I don't understand why is it adding a row of it's own at the end? Second, why the values are coming as #N/A and how to resolve this?
 
    
