参考:
http://blog.csdn.net/wxfy1977/article/details/3847450(另外一种实现方式,数据库方式)
http://blog.csdn.net/evkj2013/article/details/10186199
http://www.cnblogs.com/xianyunhe/archive/2011/09/25/2190485.html
http://blog.csdn.net/chumoyangguang/article/details/8872944
http://retype.wenku.baidu.com/view/e9b4e3edb8f67c1cfad6b860.html
http://blog.csdn.net/fullsail/article/details/4067416
http://wenku.baidu.com/view/f233445dbe23482fb4da4cf7.html
http://www.cnblogs.com/tgyf/p/3735001.html
http://www.cnblogs.com/fullsail/archive/2012/12/28/2837952.html
http://blog.csdn.net/gyssoft/article/details/1592104
---------------------------------------------------------------------------------------------
1.导入Excel接口类
Project->Class Wizard->Add Class->MFC Class From TypeLib
导入后文件结构:
此时,直接编译会报错。
2.修改编译错误
①将文件中CApplication.h
#import "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE" no_namespace
替换为
#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE14\MSO.DLL"
rename("RGB", "MSORGB")
rename("DocumentProperties", "MSODocumentProperties")
using namespace Office;
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
using namespace VBIDE;
#import "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE"
rename("DialogBox", "ExcelDialogBox")
rename("RGB", "ExcelRGB")
rename("CopyFile", "ExcelCopyFile")
rename("ReplaceText", "ExcelReplaceText")
no_auto_exclude
using namespace Excel;
②删除CRange.h,CWorkbook.h,CWorkbooks.h,CWorksheet.h,CWorksheets.h中下面内容:
#import "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE" no_namespace
3.Excel操作