??????????????·????????壬?????????excel??

 

<span style="white-space:pre">    </span>wchar_t   path[MAX_PATH];
GetCurrentDirectory(MAX_PATH?? path);
CString strPath = path;
strPath   +=   "\template";<span style="white-space:pre">    </span>//??????·??
m_ExlBooks.AttachDispatch(m_ExlApp.GetWorkbooks()?? TRUE);
m_ExlBook.AttachDispatch(m_ExlBooks.Add((_variant_t)strPath)?? TRUE);    //????EXCEL???
m_ExlSheets.AttachDispatch(m_ExlBook.GetSheets()?? TRUE);    //????Sheet???
m_ExlSheets.Add(vtMissing?? vtMissing?? _variant_t((long)1)?? vtMissing);  //????μ?Sheet???
m_ExlSheet.AttachDispatch(m_ExlSheets.GetItem(_variant_t((long)2))?? TRUE);  //????????Sheet???
m_ExlSheet.Delete();
m_ExlSheet.AttachDispatch(m_ExlSheets.GetItem(_variant_t((long)1))?? TRUE);  //??????Sheet??????????TestSheet
m_ExlSheet.SetName(L"TestSheet");
///???????е????A1??D1///
m_ExlRge.AttachDispatch(m_ExlSheet.GetRange(_variant_t("A1")?? _variant_t("D1"))?? TRUE); //??????????????
m_ExlRge.Merge(_variant_t((long)0));
///??????????///
m_ExlRge.AttachDispatch(m_ExlSheet.GetCells()?? TRUE);   //???????е????
m_ExlRge.SetItem(_variant_t((long)1)?? _variant_t((long)1)?? _variant_t("??????????γ?"));
m_ExlRge.SetItem(_variant_t((long)2)?? _variant_t((long)1)?? _variant_t("?γ???"));
m_ExlRge.SetItem(_variant_t((long)2)?? _variant_t((long)2)?? _variant_t("???"));
m_ExlRge.SetItem(_variant_t((long)2)?? _variant_t((long)3)?? _variant_t("???"));
m_ExlRge.SetItem(_variant_t((long)2)?? _variant_t((long)4)?? _variant_t("??????"));
m_ExlRge.SetItem(_variant_t((long)3)?? _variant_t((long)1)?? _variant_t("c????"));
m_ExlRge.SetItem(_variant_t((long)3)?? _variant_t((long)2)?? _variant_t("60"));
m_ExlRge.SetItem(_variant_t((long)3)?? _variant_t((long)3)?? _variant_t("???"));
m_ExlRge.SetItem(_variant_t((long)3)?? _variant_t((long)4)?? _variant_t("???????"));
m_ExlRge.SetItem(_variant_t((long)4)?? _variant_t((long)1)?? _variant_t("c????γ????"));
m_ExlRge.SetItem(_variant_t((long)4)?? _variant_t((long)2)?? _variant_t("10"));
m_ExlRge.SetItem(_variant_t((long)4)?? _variant_t((long)3)?? _variant_t("??"));
m_ExlRge.SetItem(_variant_t((long)4)?? _variant_t((long)4)?? _variant_t("???"));
m_ExlRge.SetItem(_variant_t((long)5)?? _variant_t((long)1)?? _variant_t("??????"));
m_ExlRge.SetItem(_variant_t((long)5)?? _variant_t((long)2)?? _variant_t("60"));
m_ExlRge.SetItem(_variant_t((long)5)?? _variant_t((long)3)?? _variant_t("????"));
m_ExlRge.SetItem(_variant_t((long)5)?? _variant_t((long)4)?? _variant_t("???????"));
m_ExlRge.AttachDispatch(m_ExlSheet.GetUsedRange()); //??????????????
m_ExlRge.SetWrapText(_variant_t((long)1));  //??????????????????????
//??????????????????
//?????????=1??????=-4108????=-4131????=-4152
//??????????=2??????=-4108????=-4160????=-4107
m_ExlRge.SetHorizontalAlignment(_variant_t((long)-4108));
m_ExlRge.SetVerticalAlignment(_variant_t((long)-4108));

 

??????????沢???

 

<span style="white-space:pre">    </span>CFileDialog dlg(FALSE);<span style="white-space:pre">    </span>//????????FALSE??????棬TRUE?????
if (dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
m_ExlSheet.SaveAs(strPath?? vtMissing?? vtMissing?? vtMissing?? vtMissing?? vtMissing?? vtMissing?? vtMissing?? vtMissing?? vtMissing);
//m_ExlApp.SetVisible(TRUE);
}
m_ExlBook.Close(covFalse?? covOptional?? covOptional);
m_ExlBooks.Close();
m_ExlApp.Quit();    //???????
m_ExlRge.ReleaseDispatch();     //???????????????
m_ExlSheet.ReleaseDispatch();
m_ExlSheets.ReleaseDispatch();
m_ExlBook.ReleaseDispatch();
m_ExlBooks.ReleaseDispatch();
m_ExlApp.ReleaseDispatch(); //m_ExlApp??????????????????????????excel?????????????У???????????е????????