|
Read Excel file in Visual Stdio 2008
|
|
Current Rating:
0%
Total Members Rated:
0 |
 |
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'); - With Microsoft Developer Studio, start a new "MFC AppWizard (exe)" project named "AutoProject."
- 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. - Click ClassWizard on the View menu (or press CTRL+W).
- 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. - Click ClassWizard on the View menu (or press CTRL+W).
- 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.
- Click OK to close the MFC ClassWizard dialog box.
- 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(); . . .
} - Add the following line to the #include statements at the top of the AutoProject.cpp program file:
- 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.
|
|
|
Author is Offline
|