Emailid
Password
         
  
    Forgot password

New user Sign Up


Read Excel file in Visual Stdio 2008

       Current Rating:  0%                                                     Total Members Rated:  0
                                                                     Send To Friend

I did the following steps in Visual Stdio 2006 and was successfull to read the excel, but now I am trying to do the same in Visual Stdio 2008 but not achiving it.In VC6, by just following the steps below, I got excel.h and excel.cpp in my project, but not geeting these files in VC9(VS 2008).Please help me.

 

The example automates Microsoft Excel.

Create an automation project

loadTOCNode(2, 'moreinformation');
  1. With Microsoft Developer Studio, start a new "MFC AppWizard (exe)" project named "AutoProject."
  2. In step 1 of the MFC AppWizard, choose "Dialog Based" for the application type and then click Finish.

    The New Project Information dialog box appears and indicates that the Classes to be created include:
          Application: CAutoProjectApp in AutoProject.h and AutoProject.cpp
    Dialog: CAutoProjectDlg in AutoProject.h and AutoProjectDlg.cpp
    Click OK to create the project.
  3. Click ClassWizard on the View menu (or press CTRL+W).
  4. Select the Message Maps tab. Select IDRUN in the Object Ids list box and select "BN_CLICKED" in the Messages list box. Click Add Function and accept the function name "OnRun". Click OK to close the ClassWizard.

    NOTE: This step adds a declaration for the function member "OnRun();" to the header file named AutoProjectDLG.h. This step also adds an empty skeleton message handler function named CAutoProjectDlg::OnRun() to the file named AutoProjectDLG.cpp.
  5. Click ClassWizard on the View menu (or press CTRL+W).
  6. Select the Automation tab. Click Add Class and choose "From a type library." Navigate to select the object library for the application you wish to automate .The default location for Excel.exe in Office 2003 is C:\program Files\Microsoft Office\Office11\Excel.exe. Once you have selected the appropriate object library, click Open. Select all classes in the Confirm Classes list, and then click OK.

  7. Click OK to close the MFC ClassWizard dialog box.
  8. Add the following code to the CAutoProjectApp::InitInstance() function, which loads and enables the COM services library:
          BOOL CAutoProjectApp::InitInstance()
    {
    if(!AfxOleInit()) // Your addition starts here
    {
    AfxMessageBox("Could not initialize COM dll");
    return FALSE;
    } // End of your addition

    AfxEnableControlContainer();
    .
    .
    .

    }
  9. Add the following line to the #include statements at the top of the AutoProject.cpp program file:
          #include <afxdisp.h>
  10. Add the include statement for excel8.h after the include statement for stdafx.h at the top of the AutoProjectDlg.cpp program file:
          #include "stdafx.h"
    #include "excel.h" // excel.h in the case of Excel 2002 and Excel 2003.


                           Rate This Article:   

Author is Offline
  Author: amit gupta
       


Comments Posted
Label
Subject Author Status Date

 

Post Comment

Related Articles
N-Tier in ASP.NET or other .NET apps
Software Development Outsourcing (Offshore ) to India
Make your web site ‘perfect and Search Engine Friendly for Google and Yahoo
Color combination of your Web site
An appealing design for your Web site



Home | About Us | Site Map | Privacy Policy