简单的方法是通过ODBC来实现:具体实现一、 包含Excel文件操作类头文件#include "CSpreadSheet.h"二、 新建Excel文件,并写入默认数据// 新建Excel文件名及路径,TestSheet为内部表名CSpreadSheet SS("c:\\Test.xls", "TestSheet");CStringArray sampleArray, testRow;SS.BeginTransaction();// 加入标题sampleArray.RemoveAll();sampleArray.Add("姓名");sampleArray.Add("年龄");SS.AddHeaders(sampleArray);// 加入数据CString strName[] = {"徐景周","徐志慧","郭徽","牛英俊","朱小鹏"};CString strAge[] = {"27","23","28","27","26"};for(int i = 0; i < sizeof(strName)/sizeof(CString); i++){sampleArray.RemoveAll();sampleArray.Add(strName[i]);sampleArray.Add(strAge[i]);SS.AddRow(sampleArray);}SS.Commit();三、 读取Excel文件数据CSpreadSheet SS("c:\\Test.xls", "TestSheet");CStringArray Rows, Column;//清空列表框m_AccessList.ResetContent();for (int i = 1; i <= SS.GetTotalRows(); i++){// 读取一行SS.ReadRow(Rows, i);CString strContents = "";for (int j = 1; j <= Rows.GetSize(); j++){if(j == 1)strContents = Rows.GetAt(j-1);elsestrContents = strContents + " --> " + Rows.GetAt(j-1);}m_AccessList.AddString(strContents);}