Range rgRge;
CString str;
if (!ExcelApp.CreateDispatch("Excel.Application",NULL))
{
AfxMessageBox("创建Excel服务失败!");
exit(1);
}
UpdateData();
CString str_dating_time;
str_dating_time=m_dating_time.Format("%Y-%m-%d");
CString str_send_time;
str_send_time=m_send_time.Format("%Y-%m-%d");
ExcelApp.SetUserControl(FALSE);
CString path;
path=AfxGetApp()->m_pszHelpFilePath;
path=path.Left(path.ReverseFind('\\')+1);
path +="\\repairser.dll";
//利用模板文件建立新文档
wbsBooks.AttachDispatch(ExcelApp.GetWorkbooks(),true);
wbBook.AttachDispatch(wbsBooks.Add(_variant_t(path)));
//得到Worksheets
wsssheets.AttachDispatch(wbBook.GetWorksheets(),true);
//得到sheet1
wssheet.AttachDispatch(wsssheets.GetItem(_variant_t("sheet1")),true);
//得到全部Cells,此时,rgRge是cells的集合
rgRge.AttachDispatch(wssheet.GetCells(),true);
//设置1行1列的单元的值
rgRge.SetItem(_variant_t((long)1),_variant_t((long)2),_variant_t(m_id));
rgRge.SetItem(_variant_t((long)2),_variant_t((long)2),_variant_t(m_accept_time));
rgRge.SetItem(_variant_t((long)2),_variant_t((long)4),_variant_t(m_operator_man));
rgRge.SetItem(_variant_t((long)2),_variant_t((long)6),_variant_t(m_information_source));
|