如下所示代码仅演示大体流程 不够完整 不可直接使用
另:新建的sheet只能置于当前工作sheet前面,博主不知道怎样才能添加在后面……
//选择文件保存位置
CFileDialog FileDlg(FALSE, NULL, NULL, OFN_HIDEREADONLY, "xls 文件(*.xls)|*.xls");
if (FileDlg.DoModal() == IDCANCEL)
return;
CString str = FileDlg.GetPathName();
if (str.Right(4) != ".xls" && str.Right(4) != ".XLS")
str += ".xls";
CString szDesPath = str;
CFileFind ff;
if (ff.FindFile(szDesPath))
{
if (AfxMessageBox("有重名文件,删除?", MB_OKCANCEL) == IDCANCEL)
return;
DeleteFile(szDesPath);
}
_Application app;
Workbooks books;
_Workbook book;
Sheets sheets;
_W