473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSFlexgrid in VB 6

1 New Member
Pls tell how i can create Excel sheet in MSFlexgrid & how i write data
Mar 8 '07 #1
2 5818
samycbe
83 New Member
Are you want to export the data from flexgrid to excel or edit data in flexgrid?

clarify that.......


samy
Mar 8 '07 #2
hariharanmca
1,977 Top Contributor
Pls tell how i can create Excel sheet in MSFlexgrid & how i write data
Expand|Select|Wrap|Line Numbers
  1. 'Pass Flx Grid as Perameter to this Method
  2. Public Sub create_csv(flx As MSHFlexGrid)
  3.     Dim str1 As String
  4.     Dim PrintFormat As String
  5.     'Opening a Csv file
  6.     Open App.Path & "\export.csv" For Output As #1      ' Open file for output.
  7.         'For loop to the count of Grid Rows
  8.         For i = 0 To flx.Rows - 1
  9.             str1 = ""
  10.             'For loop to the count of Grid Columns
  11.             For j = 0 To flx.Cols - 1
  12.                 'Passing Grid Col Value to Temp String Variable
  13.                str1 = str1 & flx.TextMatrix(i, j) & " "
  14.                If j <> flx.Cols - 1 Then str1 = str1 & ","
  15.             Next
  16.             'Printing Grid Row Value to the Opened Csv format File
  17.             Print #1, str1
  18.         Next
  19.     'Closing Csv File
  20.     Close #1
  21.     'Passint Grid cols to Format the csv file columns
  22.     openfile (flx.Cols)
  23. End Sub
  24.  
  25. Public Sub openfile(thecols As Integer)
  26.     'Decelar Excel Application
  27.     Dim objExcel As New Excel.Application
  28.     Dim objWorkBooks As Object
  29.     Dim objAsheet As Object
  30.     'If Error then Creating Latebinding Object
  31.     If Err.Number Then
  32.         Err.clear
  33.         Set objExcel = CreateObject("Excel.Application")
  34.     End If
  35.     Set objWorkBooks = objExcel.Workbooks
  36.     'Opening File
  37.     objWorkBooks.Open App.Path & "\export.csv", , , 2, , , , , ","
  38.     'Fit the Col Cells to the length of Data
  39.     For intCol = 1 To thecols
  40.         objExcel.Columns(intCol).AutoFormat (2)
  41.         objExcel.Range("a1", (objExcel.Columns(thecols).AddressLocal) & TheRows).AutoFormat (GridStyle)
  42.     Next
  43.     objExcel.Visible = True
  44. End Sub

think this will help u
Mar 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
13356
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the...
0
3098
by: Ed | last post by:
Hi, I am using an MSflexgrid in my c# code. I have a strange problem. My MSflexgrid has only 1 column. Now the data in that column can be long. WIth just 1 column the MSflexgrid does not show...
1
4944
by: PVS | last post by:
Hi, I am new to VC++ 7.0. I want to use MSFlexGrid in my dialog based MFC project in VC++ 7.0 (in VS ..NET IDE). I added the MSFlexGrid control into my resource editor toolbox and I dragged and...
0
1399
by: Martin K | last post by:
Hello all..thanks for everyone's advice regarding my SHBrowseForFolder API problem, I was able to put together a public class that runs great! But I have another migration headache regarding the...
1
4906
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
1
2647
by: schapopa | last post by:
Hi, I have a MSFlexGrid control on the SSTab and now I am trying to make it editable. I got some example on the net that explains how to achive that. So I have a text box that appears over the...
2
3308
by: Ben | last post by:
after I migrated to dotNet, migration wizard transferred over my vb6.0 Msflexgrid activex com as a dll, it putted it in my bin dir as AxInterop.MSFlexGridLib.dll. however, I can't use this control...
1
16684
by: zoneal | last post by:
Hi, I am involved in the process of migrating vb(6.0) application to vb.net. My application contains only vb controls namely MSFLEXGRID. I want to migrate my application to vb.net completely...
1
5085
by: Steven | last post by:
I develop the application which contains MSFlexGrid to display data. When I try to fill the grid with the text data, I want to adjust the column width so that the width is adjusted to the maximum...
5
8365
by: Ishmael | last post by:
Hi Is Been a 3 Yrs Now (I Still trying to do this) Please help me to do this with Visual Basic 6.0 using Msflexgrid Let say you are the Principal . You have 10 educators and 5 class (Grades)...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.