Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. mfc class

mfc class

Scheduled Pinned Locked Moved C / C++ / MFC
c++
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T trioum

    is there any microsoft provided mfc class to fetch data from xls file

    Trioum

    A Offline
    A Offline
    Adam Roderick J
    wrote on last edited by
    #2

    nope :) But this link will help you achieve your task [^]

    Величие не Бога может быть недооценена.

    G 1 Reply Last reply
    0
    • A Adam Roderick J

      nope :) But this link will help you achieve your task [^]

      Величие не Бога может быть недооценена.

      G Offline
      G Offline
      Game point
      wrote on last edited by
      #3

      try . odbc

      :~ Failure is Success If we learn from it!!:~

      1 Reply Last reply
      0
      • T trioum

        is there any microsoft provided mfc class to fetch data from xls file

        Trioum

        C Offline
        C Offline
        Cool_Dev
        wrote on last edited by
        #4

        Genarate wrapper classes for Excel type library. Select 'MFC class from TypeLib' option while adding a class. Select 'From file' radio btn and browse for excel type library. For MsOffice 2003 & 2007 type library is in Excel.Exe itself, for older versions it may vary. see how to use the generated classes http://support.microsoft.com/kb/186122[^]

        T 1 Reply Last reply
        0
        • C Cool_Dev

          Genarate wrapper classes for Excel type library. Select 'MFC class from TypeLib' option while adding a class. Select 'From file' radio btn and browse for excel type library. For MsOffice 2003 & 2007 type library is in Excel.Exe itself, for older versions it may vary. see how to use the generated classes http://support.microsoft.com/kb/186122[^]

          T Offline
          T Offline
          trioum
          wrote on last edited by
          #5

          but problem is that it always open new file I want to read data from a excel which is already open

          Trioum

          C 1 Reply Last reply
          0
          • T trioum

            but problem is that it always open new file I want to read data from a excel which is already open

            Trioum

            C Offline
            C Offline
            Cool_Dev
            wrote on last edited by
            #6

            don't worry as long as there is GetActiveObject() API, u can get the running instance of excel and handle the sheets already opened in it :) . Have a look at http://support.microsoft.com/kb/238975 and http://support.microsoft.com/kb/196776

            modified on Wednesday, March 17, 2010 10:54 AM

            T 1 Reply Last reply
            0
            • C Cool_Dev

              don't worry as long as there is GetActiveObject() API, u can get the running instance of excel and handle the sheets already opened in it :) . Have a look at http://support.microsoft.com/kb/238975 and http://support.microsoft.com/kb/196776

              modified on Wednesday, March 17, 2010 10:54 AM

              T Offline
              T Offline
              trioum
              wrote on last edited by
              #7

              Still doing lot of r&d I am not able to get that excel object to read values of cells

              Trioum

              C 1 Reply Last reply
              0
              • T trioum

                Still doing lot of r&d I am not able to get that excel object to read values of cells

                Trioum

                C Offline
                C Offline
                Cool_Dev
                wrote on last edited by
                #8

                whats the problem now?

                T 1 Reply Last reply
                0
                • C Cool_Dev

                  whats the problem now?

                  T Offline
                  T Offline
                  trioum
                  wrote on last edited by
                  #9

                  I could not get the alrady worksheet object using IDispatch

                  Trioum

                  M C 2 Replies Last reply
                  0
                  • T trioum

                    I could not get the alrady worksheet object using IDispatch

                    Trioum

                    M Offline
                    M Offline
                    mesajflaviu
                    wrote on last edited by
                    #10

                    Try this one , is very good class ( created with MFC )

                    1 Reply Last reply
                    0
                    • T trioum

                      I could not get the alrady worksheet object using IDispatch

                      Trioum

                      C Offline
                      C Offline
                      Cool_Dev
                      wrote on last edited by
                      #11

                      CoInitialize(NULL); HRESULT hr; CLSID clsidExcelApp; // get CLSID of Excel Application hr = CLSIDFromProgID(L"Excel.Application", &clsidExcelApp); IUnknown *pUnk = 0; // get running object that has been registered with OLE. hr = GetActiveObject(clsidExcelApp, NULL, &pUnk); if(SUCCEEDED(hr)) { IDispatch *pDisp = 0; hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDisp); //use class wizard generated excel type lib classes.. CApplication oApp(pDisp); CWorkbooks oBooks = oApp.get_Workbooks(); CWorkbook oBook = oBooks.get_Item(COleVariant((short)1)); //First workbook CWorksheets oSheets = oBook.get_Worksheets(); CWorksheet oSheet = oSheets.get_Item(COleVariant((short)1)); //First work sheet oSheet.Activate(); CRange oRange = oSheet.get_Range(COleVariant(CString(L"A1")), COleVariant(CString(L"A1"))); //cell A1 COleVariant var = oRange.get_Text(); MessageBox(var.bstrVal, L"Text in cell A1"); } doesn't work? :doh:

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups