ActiveX/Office

자동화 - MFC

jjryu 2009. 8. 8. 22:30
* 엑셀
// to automate Microsoft Excel 97, Excel 2000, or Excel 2002
1. 새로운 MFC 어플리케이션 프로젝트를 생성한다.

2. 자동화 서버의 타입 라이브러리로 부터 래퍼 클래스(IDispatch)를 생성한다.
Microsoft Excel 97
    Microsoft Excel 8.0 Object Library // Excel8.olb, excel8.h
Microsoft Excel 2000
    Microsoft Excel 9.0 Type Library
        C:\Program Files\Microsoft Office\Office\Excel9.olb // excel9.h
Microsoft Excel 2002 // OfficeXP
    Microsoft Excel 10.0 Type Library
        C:\program Files\Microsoft Office\Office10\Excel.exe // excel.h
Microsoft Excel 2003 // Office 2003
    Microsoft Excel 11.0 Object Library
        C:\program Files\Microsoft Office\Office11\Excel.exe

_Application, _Workbook, _Worksheet, Workbooks, Worksheets, Range

COleDispatchDriver
.AttachDispatch()
.ReleaseDispatch()
_Application -> COleDispatchDriver
.CreateDispatch()
.Quit()
.SetVisible()
.GetWorkbooks()
Workbooks -> COleDispatchDriver
.Open() // _Workbook
_Workbook -> COleDispatchDriver
.GetSheets() // Worksheets
.GetWorksheets() // Worksheets
.SetSaved()
.Close()
Worksheets -> COleDispatchDriver
.GetCount()
.GetItem() // _Worksheet
_Worksheet -> COleDispatchDriver
.Activate()
.GetRange() // Range
Range -> COleDispatchDriver
.Clear()
.SetValue2()
.GetValue2()


참조 사이트:

CXLAutomation

CXLEzAutomation