Results 1 to 27 of 27

Thread: [RESOLVED] Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED

  1. #1

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Resolved [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.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  6. #6

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  8. #8
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    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.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  12. #12

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  13. #13

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED

    Quote 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.

    Quote 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.

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolve

    I think he may be out of luck.

  15. #15

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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:
    1. Private Sub Command1_Click()
    2.     '
    3.     Dim db As ADODB.Connection
    4.     Set db = New ADODB.Connection
    5.     '
    6.     db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
    7.     '
    8.     db.Execute ("SELECT * FROM Sheet1")
    9.     '
    10. 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.

  16. #16

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolved]

    This seems to work for an existing file:

    VB Code:
    1. Private Sub Command1_Click()
    2.     '
    3.     Dim db As ADODB.Connection
    4.     Set db = New ADODB.Connection
    5.     '
    6.     db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
    7.     '
    8.     Set rs = db.Execute("SELECT * FROM [sheet1$A1:B3]")
    9.     '
    10. 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.

  17. #17

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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:
    1. Private Sub Command1_Click()
    2.     '
    3.     Dim db As ADODB.Connection
    4.     Set db = New ADODB.Connection
    5.     '
    6.     db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
    7.     '
    8.     db.Execute ("CREATE TABLE demo (Name TEXT,Age NUMBER)")
    9.     '
    10. 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.

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Export data (dbGrid or Flexgrid) to .xls format - NO EXCEL INSTALLED [Not Resolve

    Doesn't that require Office? Can you distribute the files?

  19. #19

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  20. #20

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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:
    1. Private Sub Command1_Click()
    2.     '
    3.     Dim db As ADODB.Connection
    4.     Dim rs As ADODB.Recordset
    5.     '
    6.     Set db = New ADODB.Connection
    7.     '
    8.     db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
    9.     '
    10.     db.Execute ("INSERT INTO demo (Name,Age) VALUES ('Dave Sell',35)")
    11.     '
    12.     '
    13. 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.

  21. #21

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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:
    1. Private Sub Command1_Click()
    2.     '
    3.     Dim db As ADODB.Connection
    4.     Dim rs As ADODB.Recordset
    5.     '
    6.     Set db = New ADODB.Connection
    7.     '
    8.     db.Open "DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""c:\Temp\Book1.xls"";DBQ=c:\Temp\Book1.xls"
    9.     '
    10.     db.Execute ("CREATE TABLE demo (Name TEXT,Age NUMBER)")
    11.     db.Execute ("INSERT INTO demo (Name,Age) VALUES ('Dave Sell',35)")
    12.     '
    13.     'Set rs = db.Execute("SELECT * FROM [sheet1$A1:B3]")
    14.     '
    15. 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.

  22. #22

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  23. #23

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  24. #24
    New Member
    Join Date
    Apr 2002
    Posts
    9

    Thumbs up 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!

  25. #25

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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.

  26. #26
    New Member
    Join Date
    Apr 2002
    Posts
    9

    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.

  27. #27

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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
  •  



Click Here to Expand Forum to Full Width