|
-
Jun 19th, 2006, 03:16 PM
#1
Thread Starter
Lively Member
[RESOLVED] Populate a spreadsheet
I'm trying to write a VS2002 VB procedure that will read in the contents of a recordset and then output it to Excel, without having to actually go through the hassle of coding each individual cell movement. I've done something similar in CSV format, using the Write and Writeline commands to place the information. However, what I can't replicate in Excel is the movement from one cell to another - if I try to insert a tab between each cell, it simply concatenates the data into one cell, with tabs in between them.
I'm going home now, but if someone knows what the solution is, I'm all ears
Wise man once said: "Don't ever get married, just find a woman you don't like and buy her a house".
According to ancient Chinese proverb, "Man with hole in pocket feels cocky all day". 
-
Jun 19th, 2006, 03:22 PM
#2
Re: Populate a spreadsheet
look into
CopyFromRecordset it will be your saviour
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 11:00 PM
#3
Re: Populate a spreadsheet
Watch this Static 
Since classic ADO is a secondary technology in .NET you should be using either ADO.NET or automating Access and Excel to get your results.
Here is some code I wrote to output a new Excel workbook from an Access table/query.
http://vbforums.com/showpost.php?p=2514577&postcount=8
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 20th, 2006, 03:34 AM
#4
Thread Starter
Lively Member
Re: Populate a spreadsheet
 Originally Posted by Static
look into
CopyFromRecordset  it will be your saviour
Hi Static
I've got a few questions for you:
1. Will CopyFromRecordset work when using VB.NET 2002 to empty the contents of a recordset into an Excel spreadsheet;
2. Will I be able to control the names of the columns that appear in the output? I can't just have it dumping out the table column names as column headers, since the output is going to a Client;
If it comes to it, I've got the ability to use Automation to populate the spreadsheet, but that's a bit of faffage that I could really live without at the moment.
Thanks
Wise man once said: "Don't ever get married, just find a woman you don't like and buy her a house".
According to ancient Chinese proverb, "Man with hole in pocket feels cocky all day". 
-
Jun 20th, 2006, 11:13 AM
#5
Re: Populate a spreadsheet
Not much control over the columns copied using the CopyFromRecordset method. You would have to adjust your query that populates your recordset.
No field names will be populated. You have to code it by looping theough the fields collection of your recordset.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|