16-05-23, 12:41 PM
استعملت هذا الكود لترحيل البيانات من داتا قرايد فيو الى اكسل والكود ناجح تماما في جميع الشاشات
الا انه عندما تم عرض اداة داتا قرايد فيو وبها عمودين يعرضان الوقت لم ينجح الامر
هذا هو الكود برجاء المساعده
Try
Dim MsExcel = CreateObject("Excel.Application")
MsExcel.Workbooks.Add()
For i As Integer = 0 To dgv_recieve.Columns.Count - 1
MsExcel.Cells(i + 1).Value = dgv_recieve.Columns(i).HeaderText
Next
For i As Integer = 0 To dgv_recieve.Columns.Count - 1
For j As Integer = 0 To dgv_recieve.Rows.Count - 1
MsExcel.Columns.HorizontalAlignment = 3
MsExcel.Columns.Font.Name = "Times New Roman"
MsExcel.Rows.Item(j + 1).Font.Bold = 1
MsExcel.Rows.Item(j + 1).Font.size = 14
MsExcel.Cells(j + 1).ColumnWidth = 14
MsExcel.Cells(j + 2, i + 1).Value = dgv_recieve.Rows(j).Cells(i).Value
Next
Next
MsExcel.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
الا انه عندما تم عرض اداة داتا قرايد فيو وبها عمودين يعرضان الوقت لم ينجح الامر
هذا هو الكود برجاء المساعده
Try
Dim MsExcel = CreateObject("Excel.Application")
MsExcel.Workbooks.Add()
For i As Integer = 0 To dgv_recieve.Columns.Count - 1
MsExcel.Cells(i + 1).Value = dgv_recieve.Columns(i).HeaderText
Next
For i As Integer = 0 To dgv_recieve.Columns.Count - 1
For j As Integer = 0 To dgv_recieve.Rows.Count - 1
MsExcel.Columns.HorizontalAlignment = 3
MsExcel.Columns.Font.Name = "Times New Roman"
MsExcel.Rows.Item(j + 1).Font.Bold = 1
MsExcel.Rows.Item(j + 1).Font.size = 14
MsExcel.Cells(j + 1).ColumnWidth = 14
MsExcel.Cells(j + 2, i + 1).Value = dgv_recieve.Rows(j).Cells(i).Value
Next
Next
MsExcel.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try