23-08-15, 02:26 AM
السلام عليكم أخي العزيز ورحمة الله وبركاته
ضع الكود التالي بعد استدعاء مكتبة الإكسل
أتمنى لك التوفيق
ضع الكود التالي بعد استدعاء مكتبة الإكسل
PHP كود :
Dim ExcelApp As Object, ExcelBook As Object
Dim ExcelSheet As Object
Dim i As Integer
Dim j As Integer
'create object of excel
ExcelApp = CreateObject("Excel.Application")
ExcelBook = ExcelApp.WorkBooks.Add
ExcelSheet = ExcelBook.WorkSheets(1)
With ExcelSheet
For i = 1 To Me.DataGridView1.RowCount
.cells(i + 1, 1) = Me.DataGridView1.Rows(i - 1).Cells("id").Value
For j = 1 To DataGridView1.Columns.Count - 1
.cells(i + 1, j + 1) = DataGridView1.Rows(i - 1).Cells(j).Value
Next
Next
End With
ExcelApp.Visible = True
'
ExcelSheet = Nothing
ExcelBook = Nothing
ExcelApp = Nothing
أتمنى لك التوفيق
واعبد ربك حتى يأتيك اليقين

