Sending flexgrid data to Excel

Sending flexgrid data to Excel

Page 1 of 1

1 Replies - 4811 Views - Last Post: 23 October 2010 - 12:14 PM Rate Topic: -----

#1 Sagar.Dudhawade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-October 10

Sending flexgrid data to Excel

Posted 23 October 2010 - 03:43 AM

Hi,
I have vb6.0 code. When I click on run button the code pull data from database and show it in flexgrid. Here is the code
Private Sub run_Click()

Dim con As New ADODB.Connection
Dim msgr As msflexgrid

Set con = New ADODB.Connection

con.ConnectionString = "Provider=MSDAORA.1;User ID=SYSTEM;password=ora123;Persist Security Info=False"
con.Open

Set rs = con.Execute("select * from sample where " & _
" date_time = to_date('" & Format(dtpicker.Value, "dd/MMM/yy") & "','dd-mon-yy')")

Dim r As Integer
With msflexgrid
    .TextMatrix(0, 0) = rs.Fields(0).Name
    .TextMatrix(0, 1) = rs.Fields(1).Name
    .TextMatrix(0, 2) = rs.Fields(2).Name
r = 1
Do Until rs.EOF

   .TextMatrix(r, 0) = rs.Fields(0)
   .TextMatrix(r, 1) = rs.Fields(1)
   .TextMatrix(r, 2) = rs.Fields(2)
r = r + 1
.Rows = .Rows + 1

rs.MoveNext
Loop
End With
End Sub


I wanted to export these flexgrid data into excel. I created some code to open excel application Below is the code.
Private Sub cmd1_Click()
Dim exl As Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet

Dim i As Integer 'Counter
Dim j As Integer 'Counter

Set exl = New Excel.Application
Set wkb = exl.Workbooks.Add
Set wks = wkb.Sheets(1)
    
	
   exl.Visible = True
End Sub



Edited by macosxnerd101: Please, :code:.

Is This A Good Question/Topic? 0
  • +

Replies To: Sending flexgrid data to Excel

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Sending flexgrid data to Excel

Posted 23 October 2010 - 12:14 PM

check the tutorial section about this:
Sending Data From MSFlexGrid To Excel in VB6
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1