27-10-17, 10:43 PM
PHP كود :
Dim MsExcel = CreateObject("Excel.Application")
MsExcel.Workbooks.Open("d:\book1.xlsx")
DGV1.Columns(0).HeaderText = MsExcel.Cells(0 + 1).Value
DGV1.Columns(1).HeaderText = MsExcel.Cells(1 + 1).Value
DGV1.Columns(2).HeaderText = MsExcel.Cells(2 + 1).Value
DGV1.Columns(3).HeaderText = MsExcel.Cells(3 + 1).Value
DGV1.Rows.Clear()
Dim I As Integer = 0
Do
If MsExcel.Cells(I + 2, 1).Value = "" Then Exit Do
DGV1.RowCount = DGV1.RowCount + 1
Dim value1 As Integer = Val(MsExcel.Cells(I + 2, 1).Value)
Dim value2 As String = MsExcel.Cells(I + 2, 2).Value.ToString.Trim
Dim value3 As String = MsExcel.Cells(I + 2, 3).Value.ToString.Trim
Dim value4 As Integer = Val(MsExcel.Cells(I + 2, 4).Value)
DGV1.Rows(I).Cells(0).Value = value1
DGV1.Rows(I).Cells(1).Value = value2
DGV1.Rows(I).Cells(2).Value = value3
DGV1.Rows(I).Cells(3).Value = value4
I = I + 1
Loop
MsExcel.Quit()
