04-06-18, 10:43 PM
(آخر تعديل لهذه المشاركة : 04-06-18, 10:45 PM {2} بواسطة mrnooo2000.)
جرب هذا الكود
كود :
convert your datatable to 2D array '
Dim arr(dt.Rows.Count - 1, dt.Columns.Count - 1) As Object
For r As Integer = 0 To dt.Rows.Count - 1
Dim dr As DataRow = dt.Rows(r)
For c As Integer = 0 To dt.Columns.Count - 1
arr(r, c) = dr(c)
Next c
Next r
'write array data to excel
Dim c1 As Excel.Range = CType(wsh.Cells(topRow, 1), Excel.Range)
Dim c2 As Excel.Range = CType(wsh.Cells(topRow + dt.Rows.Count - 1, dt.Columns.Count), Excel.Range)
Dim range As Excel.Range = wsh.get_Range(c1, c2)
range.Value = arr