It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

How to import data from MSEcxel Sheet to MshFlex grid in VB?

Moderator: dafunkymunky

How to import data from MSEcxel Sheet to MshFlex grid in VB?

Postby shishta on Fri Dec 23, 2005 7:22 am

Kindly Help me out as soon as possible to write the code for importing the file from excel format to mshflex grid.
thank you
shishta
 
Posts: 4
Joined: Fri Dec 23, 2005 7:10 am
Location: ghaziabad

Postby shishta on Thu Dec 29, 2005 11:54 am

Code: Select all

[b]Private Sub cmdimport_Click()[/b]
lblimport.Visible = True
Dim mshrow As Integer
mshrow = 1
Dim r_count As Integer
Dim msh_ro As Integer
msh_ro = 1
Dim str As String

Dim CurrentDate As Date
CurrentDate = FlServerDate

CommonDialog1.ShowOpen
str = CommonDialog1.FileName
If UCase(Right(str, 3)) <> "XLS" Then
    MsgBox "Invalid File. Please select Excel File!", vbInformation
    Exit Sub
End If
msh.Rows = 2
Call clear_grid(msh)
Dim wb As Workbook
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim x1 As Object

Set wb = GetObject(str)
Set ws = wb.Sheets(1)

DoEvents
Dim i As Integer
i = 3
Do While Trim(ws.Cells(i, 1)) <> ""
    i = i + 1
    lblimport.Caption = "Collecting Data...."
    lblimport.Refresh
Loop

msh.AllowUserResizing = flexResizeColumns

mshrow = 1
Do While mshrow < i - 2
    If msh.Rows <= mshrow Then
        msh.Rows = msh.Rows + 1
    End If
    MousePointer = vbHourglass
    msh.TextMatrix(mshrow, 1) = ws.Cells(mshrow + 1, 1)
    msh.TextMatrix(mshrow, 2) = ws.Cells(mshrow + 1, 2)
    msh.TextMatrix(mshrow, 3) = ws.Cells(mshrow + 1, 3)
    msh.TextMatrix(mshrow, 4) = ws.Cells(mshrow + 1, 4)
    msh.TextMatrix(mshrow, 5) = ws.Cells(mshrow + 1, 5)
    msh.TextMatrix(mshrow, 6) = ws.Cells(mshrow + 1, 6)
    msh.TextMatrix(mshrow, 7) = ws.Cells(mshrow + 1, 7)
    msh.TextMatrix(mshrow, 8) = ws.Cells(mshrow + 1, 8)
    msh.TextMatrix(mshrow, 9) = ws.Cells(mshrow + 1, 9)
    msh.TextMatrix(mshrow, 10) = ws.Cells(mshrow + 1, 10)
    msh.TextMatrix(mshrow, 11) = ws.Cells(mshrow + 1, 11)
    msh.TextMatrix(mshrow, 12) = ws.Cells(mshrow + 1, 12)
    msh.TextMatrix(mshrow, 13) = ws.Cells(mshrow + 1, 13)
    msh.TextMatrix(mshrow, 14) = ws.Cells(mshrow + 1, 14)
    msh.TextMatrix(mshrow, 15) = ws.Cells(mshrow + 2, 15)
    msh.TextMatrix(mshrow, 16) = ws.Cells(mshrow + 2, 16)
    mshrow = mshrow + 1
    DoEvents
    lblimport.Refresh
    lblimport.Caption = mshrow & " Rows Imported...."

Loop

lblimport.Refresh
lblimport.Caption = " Data Imported...."
MousePointer = vbNormal

[b]End Sub[/b]
shishta
 
Posts: 4
Joined: Fri Dec 23, 2005 7:10 am
Location: ghaziabad

Postby shishta on Thu Dec 29, 2005 11:55 am

Thank you
shishta
 
Posts: 4
Joined: Fri Dec 23, 2005 7:10 am
Location: ghaziabad


Who is online

Users browsing this forum: No registered users and 6 guests