|
-
June 11th, 2002, 05:36 AM
#1
Exporting data from Grid Control to Excell
Hello Gurus,
I have a small problem.
I am using a grid control in my vb project. Which has 5 columns and
some rows. Now I would like to insert these values from the grid
into a new microsoft excell sheet from vb by clicking a button.
The columns and rows should come as it is there in the grid.
I would like to have the code for this problem.
Can anybody help me...?
Thank you
Regards
Benny
Benny C A
Al Ain, UAE
-
March 3rd, 2004, 05:00 AM
#2
Hi friends,
I've met the same situation. Has anyone got any suggestion for the problem?
Thanks a lot
Khoa
-
March 3rd, 2004, 10:51 AM
#3
Look here:
http://support.microsoft.com/default...b;EN-US;247412
and here:
http://support.microsoft.com/default...;EN-US;Q178510
I have also posted quite a few posts and responses regarding Excel and VB 6. Do a search for Excel or under my UserName to find them.
I'd rather be wakeboarding...
-
March 4th, 2004, 01:54 AM
#4
It helps a lot!
Thanks Malleyo!
Khoa
-
March 6th, 2004, 02:13 AM
#5
Its Simple !
'Add refrence File Scripting runtime,microsoft excel etc.
'Do minor correction as required!
Dim Fsys As New Scripting.FileSystemObject
Dim XlApp As excel.Application
c=5 'Column
r=5 'Row
Set OStream = Fsys.OpenTextFile("c:\Data.xls", ForWriting, True)
If Err Then
OStream.Close
Err.Clear
Exit Sub
End If
'Take data into array Grid() or directly maniuplate grid control
For r=1 to 5 ' Read rows
For c=i to 5 'read column
ostream.write grid(i,j)
next c
next r
ostream.close
Set Wb = XlApp.Workbooks.Open("C:\Data.txt")
XlApp.WindowState = xlNormal
XlApp.Application.Visible = True
XlApp.ScreenUpdating = True
'This will solve ur problem
Sunil
09823214545
-
March 8th, 2004, 12:23 PM
#6
What about just conversting to CSV or another text format and loading from there?
-
March 9th, 2004, 03:16 AM
#7
'Do slight modification in the program
Dim Fsys As New Scripting.FileSystemObject
Dim XlApp As excel.Application
c=5 'Column
r=5 'Row
Set OStream = Fsys.OpenTextFile("c:\Data.xls", ForWriting, True)
If Err Then
OStream.Close
Err.Clear
Exit Sub
End If
'Take data into array Grid() or directly maniuplate grid control
For r=1 to 5 ' Read rows
For c=i to 5 'read column
ostream.write grid(i,j)
ostream .write vbtab ' for Tab demilited txt file
ostream.write "," for CSV file
"You can insert any character to separate the data in the file 'using above statement like (tab,comma ,space or any other special character) and finally open this file using Excel"
next c
next r
ostream.close
Set Wb = XlApp.Workbooks.Open("C:\Data.xls")
XlApp.WindowState = xlNormal
XlApp.Application.Visible = True
XlApp.ScreenUpdating = True
I think this answers ur question
Regards,
Sunil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|