I am getting this error Exception from HRESULT: 0x800A03EC
in excel.range.
Here is my following code
Private Sub excelInsertData(rowIndex As Integer, ColIndex As Integer, EDT As DataTable)
Try
Dim arr As Object(,) = New Object(EDT.Rows.Count - 1, EDT.Columns.Count - 1) {}
For r As Integer = 0 To EDT.Rows.Count - 1
Dim dr As DataRow = EDT.Rows(r)
For c As Integer = 0 To EDT.Columns.Count - 1
arr(r, c) = dr(c)
Next
Next
Dim c1 As Excel.Range = CType(xlWorkSheet.Cells(rowIndex, ColIndex), Excel.Range)
Dim c2 As Excel.Range = CType(xlWorkSheet.Cells(rowIndex + EDT.Rows.Count - 1, EDT.Columns.Count + ColIndex - 1), Excel.Range)
Dim range As Excel.Range = xlWorkSheet.Range(c1, c2)
range.Value = arr '---------ERROR THROWN HERE
Catch ex As Exception
MsgBox(ex.toString)
Finally
EDT.Rows.Clear() : EDT.Columns.Clear()
End Try
End Sub
I am trying to do is transferring data from a Datatable (EDT in this case) to an Excel Template.
Following are the values range, arr and EDT.
Also, I can attach a template of my 3b.xlsm file if required.
Please ask if I am missing any information which needed to be provided.