|
I imported the data from excel into the MSHFlexGrid1.TextMatrix (i, 1) control! For the reference of the landlord
Private Sub MnuInput_Click ()
Rem saves the data in the table
Dim FileName As String '' '' '' '' '' 'Save data to Excel table
Dim i As Integer
CommonDialog1.FileName = ""
CommonDialog1.Filter = "Excel table | * .xls"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
If FileName = "" Then
Exit Sub
End If
Set xlApp = CreateObject ("Excel.Application")
`` Set xlBook = xlApp.Workbooks '' .Add ''
Set xlBook = xlApp.Workbooks.Open (FileName)
‘’ ’Set xlBook = xlApp.Workbooks.Open (" c:\lizi.xls ")‘ ’’
Set xlSheet = xlBook.Worksheets (1) '' '' '' Open Excel sheet
xlSheet.Activate '' activate sheet
For i = 0 To 27
'' For Alfi = 0 To 90 Step 18
MSHFlexGrid1.TextMatrix (i, 1) = xlSheet.Cells (i + 1, 1) '' '' 'Import MSFlexGrid data into Excel
MSHFlexGrid1.TextMatrix (i, 2) = xlSheet.Cells (i + 1, 2)
'' Next Alfi
Next i
'' 'xlBook.SaveAs FileName
xlBook.RunAutoMacros (xlAutoClose) '' 'Execute Excel close macro
xlBook.Close (True) '' '' 'Close Excel worksheet
xlApp.Quit '' '' '' '' 'Close Excel Workbook
Set xlApp = Nothing
End Sub |
|