CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110

    Question Getting the shett list of excel file

    Hi All,
    How can I get the list of sheets of a given excel file

  2. #2
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: Getting the shett list of excel file

    using ADO..
    Code:
      Set cn = New ADODB.Connection
      cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=<XLS filename>;" & _
              "Extended Properties=""Excel 8.0; HDR=Yes"";"
              
      Set rs = cn.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "table"))
      
      Do Until rs.EOF
        MsgBox rs.Collect("TABLE_NAME")
        rs.MoveNext
      Loop
      
      Set rs = Nothing
      
      cn.Close
      Set cn = Nothing
    Busy

  3. #3
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110

    Re: Getting the shett list of excel file

    thanks it works
    is this working in ASP??

  4. #4
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: Getting the shett list of excel file

    yes, i think it will work as long as you have the permission to access the xls file.
    Busy

  5. #5
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110

    Re: Getting the shett list of excel file

    I am getting an error for adSchemaTables

  6. #6
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Re: Getting the shett list of excel file

    hmmm.. i think you must define adSchemaTables in your include file. or you could just replace it with 20.
    Busy

  7. #7
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110

    Re: Getting the shett list of excel file

    Yes it works thanks

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

Featured