Results 1 to 5 of 5

Thread: [RESOLVED] Query a spreadsheet?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    112

    Resolved [RESOLVED] Query a spreadsheet?

    I put together a reporting app in Excel similar to some you may have seen before. You define criteria for different rows and columns and the intersection of these rows and columns are populated with summary data from an outside database at runtime. You can drill down to the detailed data as you would with a pivot table.

    The database is completely out of my control and the connection to it is less than reliable.

    As a workaround to getting the detail from the DB I am replicating the relevant tables into worksheets. Size isn't an issue since the tables are never more than a few thousand lines or so. Instead or requerying the db when more detail is needed, I'd like the program to query this backup sheet. I know there are about 100 different ways to pull filtered data from a spreadsheet, but other than this piece, I'm done with the app and I'd rather not recreate the wheel.

    Is there a way I can query a spreadsheet with standard SQL? The backup data will be in the open workbook calling the query. Is it necessary to create an ODBC connection to the workbook? If so, are there access issues involved since the user will always be in the workbook being queried?

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

    Re: Query a spreadsheet?

    Yes, you can use ADO and query the Excel sheet the same as a database table. I have some code on the forums already so a search should bring them up. You can also check http://www.connectionstrings.com for the conn string needed.
    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    112

    Re: Query a spreadsheet?

    Wow.. this forum is littered with answers. I guess searching for ADO instead of DAO would have helped. Thanks.

    For anyone waiting with baited breath...
    http://www.vbforums.com/showthread.p...DO+excel+sheet

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Query a spreadsheet?

    CS

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

    Re: [RESOLVED] Query a spreadsheet?

    "Littered" lol I would say "populated with valuable information".
    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

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