|
-
Aug 12th, 2005, 06:55 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
All,
Is there some tool out there with which to export a dbGrid or an ADO recordset to .xls format? An .OCX will be fine, but there is no MS Excel installed on the client's machine.
Thanks!
Dave
Last edited by Dave Sell; Aug 13th, 2005 at 02:40 AM.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 12th, 2005, 08:10 PM
#2
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
I doubt it. Can't you export to text, and then import into Excel?
-
Aug 12th, 2005, 08:15 PM
#3
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Do you have Crystal Reports available?
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 
-
Aug 12th, 2005, 08:38 PM
#4
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Yes, I could do text but the client is specifically asking for my OPC utility to export logs and import projects as .xls (Excel) spreadsheets. No special software is installed, its straight WinXP Pro and my utilities.
Any .DLL or .OCX or .BAS or whatever will do, I just wanna output some stuff as .xls format. Gotta love those "client requests"...
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 12th, 2005, 08:42 PM
#5
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Write a macro to import the data, and he'll have an Excel file.
-
Aug 12th, 2005, 08:53 PM
#6
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Tis not enough as I also need to import .xls into the app. How do you save an Excel macro in a csv file such that Excel will execute it? Or is the macro saved into his Excel app?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 12th, 2005, 09:04 PM
#7
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Give him an Excel workbook that has an autoexec macro that imports a file and saves it in XLS format. That would be simple. You could either use the txt file, or the saved workbook to input into your app. Why bother, though. You'd still have to load it twice, and convert it twice. Just read it once, and save the xls file, and then use the array in your app.
-
Aug 12th, 2005, 09:09 PM
#8
Fanatic Member
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Can you use OpenOffice or StarOffice? They can save as .xls. Just throwing it out there in case it might spur and idea.
-
Aug 12th, 2005, 11:51 PM
#9
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Two possibilities:
1.) Use a CR report hidden that when they want to save to an xls file it will actually be Exporting using CR's Export feature to actual xls format. Only the dependent dlls from certain CR files are necessary on the client system.
2.) Export out in a textfile format but as a comma sepparated values format and file extension. Then when the user opens the csv by double-clicking the file it will open correctly formatted in Excel. Then they can save as xls if they choose to. At least the file will be compatible with Excel without having Excel on the system.
HTH
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 
-
Aug 12th, 2005, 11:57 PM
#10
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Why would a client want an XLS format if he doesn't have Excel?
-
Aug 13th, 2005, 12:15 AM
#11
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Well thats what Dave is asking for on behalf of his client. Maybe the client wants to email the workbooks to someone that has Excel.
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 
-
Aug 13th, 2005, 12:38 AM
#12
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
My app is server-side.
He wants to upload data as .XLS and download output from the server-side utility as .XLS format.
The server has no Office software, his laptop does.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 12:43 AM
#13
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
 Originally Posted by RobDog888
Two possibilities:
1.) Use a CR report hidden that when they want to save to an xls file it will actually be Exporting using CR's Export feature to actual xls format. Only the dependent dlls from certain CR files are necessary on the client system.
That software is not available to me.
 Originally Posted by RobDog888
2.) Export out in a textfile format but as a comma sepparated values format and file extension. Then when the user opens the csv by double-clicking the file it will open correctly formatted in Excel. Then they can save as xls if they choose to. At least the file will be compatible with Excel without having Excel on the system.
HTH
No good. Again, this has to be .xls in, and .xls out. I cannot use regular csv or t-n-t text files. Is there no such exporting utility out there?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 12:49 AM
#14
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolve
I think he may be out of luck.
-
Aug 13th, 2005, 02:01 AM
#15
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]
What about hooking ADO up to an ODBC Excel driver? I worked up a little code for a start, but my SELECTs and INSERTs dont work cause theres no table name to reference in an Excel file.
VB Code:
Private Sub Command1_Click()
'
Dim db As ADODB.Connection
Set db = New ADODB.Connection
'
db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
'
db.Execute ("SELECT * FROM Sheet1")
'
End Sub
Any new ideas?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:12 AM
#16
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]
This seems to work for an existing file:
VB Code:
Private Sub Command1_Click()
'
Dim db As ADODB.Connection
Set db = New ADODB.Connection
'
db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
'
Set rs = db.Execute("SELECT * FROM [sheet1$A1:B3]")
'
End Sub
Now I need to get an INSERT INTO to work...
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:17 AM
#17
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]
This creates a new worksheet in an existing file:
VB Code:
Private Sub Command1_Click()
'
Dim db As ADODB.Connection
Set db = New ADODB.Connection
'
db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
'
db.Execute ("CREATE TABLE demo (Name TEXT,Age NUMBER)")
'
End Sub
On to INSERT INTO...
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:20 AM
#18
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolve
Doesn't that require Office? Can you distribute the files?
-
Aug 13th, 2005, 02:21 AM
#19
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]
I *think* this is built into any XP machine as a default ODBC driver. I am using my laptop right now which has Excel, but I have seen the .XLS ODBC driver on new machines with no software.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:24 AM
#20
Thread Starter
PowerPoster
Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]
This is the INSERT INTO on an existing file:
VB Code:
Private Sub Command1_Click()
'
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
'
Set db = New ADODB.Connection
'
db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
'
db.Execute ("INSERT INTO demo (Name,Age) VALUES ('Dave Sell',35)")
'
'
End Sub
On to non-existant files...
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:42 AM
#21
Thread Starter
PowerPoster
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Well, I compiled the simple EXE and executed it on a machine with Vis Stud 6 but not Excel of any kind (Windows 200 Term Server).
It created the .XLS from scratch and made my sheet and inserted data. I think I can manage the rest from here. It pays to refuse to give up.
VB Code:
Private Sub Command1_Click()
'
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
'
Set db = New ADODB.Connection
'
db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
'
db.Execute ("CREATE TABLE demo (Name TEXT,Age NUMBER)")
db.Execute ("INSERT INTO demo (Name,Age) VALUES ('Dave Sell',35)")
'
'Set rs = db.Execute("SELECT * FROM [sheet1$A1:B3]")
'
End Sub
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Aug 13th, 2005, 02:48 AM
#22
Thread Starter
PowerPoster
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
P.S. I just tried it on a clean Windows 2000 Workstation, no special software installed and it worked. I was surprised to see the ADO stuff work... whew!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Oct 16th, 2007, 03:54 PM
#23
Thread Starter
PowerPoster
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
I just came across this link on MSDN describing more of the above. The DELETE statement is not supported for Excel Files.
http://support.microsoft.com/kb/257819
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Jul 27th, 2010, 01:46 PM
#24
New Member
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Hi Dave, if you're still around thanks for the above, really helped me out!
-
Jul 27th, 2010, 01:48 PM
#25
Thread Starter
PowerPoster
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
Ya, still around. Rate the post if it helped you. Did you notice the CREATE TABLE actually creates a new .XLS file on disk from scratch? I always that that was cool.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Jul 27th, 2010, 02:02 PM
#26
New Member
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
I haven't needed to create a file from scratch (yet), but being able to insert into an existing file without having Excel installed is very useful. Previously I've only been able to read data from Excel via ODBC as the .additem method of a recordset throws an error.
-
Jul 27th, 2010, 02:15 PM
#27
Thread Starter
PowerPoster
Re: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED
BTW I have used the above technique on CSV and Access Database files (MDB files) and they all work. The only notable exception is the driver won't CREATE a new .MDB file from scratch. You have to make one in MS Access first. Glad this helped you out!
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
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
|