我完全按照Microsoft客户帮助和支持主页的程序例子做的,
http://support.microsoft.com/kb/178749/#top
我改成操作EXCEL2003,
第9步的时候选择Office 2003 中的 Excel.exe 文件的默认位置为 C:/Program Files/Microsoft Office/Office11/Excel.exe
头文件为:
#include "excel.h "// excel.h in the case of Excel 2002 and Excel 2003.
编译的时候,下面的代码,出现问题:
//Fill cells A1, B1, C1, and D1 one cell at a time with "headers ".
range = sheet.GetRange(COleVariant( "A1 "),COleVariant( "A1 "));
range.SetValue(COleVariant( "First Name "));
range = sheet.GetRange(COleVariant( "B1 "),COleVariant( "B1 "));
range.SetValue(COleVariant( "Last Name "));
range = sheet.GetRange(COleVariant( "C1 "),COleVariant( "C1 "));
range.SetValue(COleVariant( "Full Name "));
range = sheet.GetRange(COleVariant( "D1 "),COleVariant( "D1 "));
range.SetValue(COleVariant( "Salary "));
编译信息:
Compiling...
AutoProjectDlg.cpp
C:/Documents and Settings/naga610/桌面/AutoProject/AutoProjectDlg.cpp(248) : error C2660: 'SetValue ' : function does not take 1 parameters
C:/Documents and Settings/naga610/桌面/AutoProject/AutoProjectDlg.cpp(250) : error C2660: 'SetValue ' : function does not take 1 parameters
C:/Documents and Settings/naga610/桌面/AutoProject/AutoProjectDlg.cpp(252) : error C2660: 'SetValue ' : function does not take 1 parameters
C:/Documents and Settings/naga610/桌面/AutoProject/AutoProjectDlg.cpp(254) : error C2660: 'SetValue ' : function does not take 1 parameters
Error executing cl.exe.
Creating browse info file...
AutoProject.exe - 4 error(s), 0 warning(s)
原因是:excel2003的函数变了,将SetValue函数改成SetValue2可以了.