谁能帮我解释一下下面代码的意思,我看不懂,所以有错都调试不来,在每一行后面//注释一下,麻烦了
voidCTestExcelDlg::OnButton1()
{
//TODO:Addyourcontrolnotificationhandlercodehere
_Applicationapp;
Workbooksbooks;
_Workbookbook;
Worksheetssheets;
_Worksheetsheet;
Rangerange;
Fontfont;
Rangecols;
COleVariantcovOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
if(!app.CreateDispatch("Excel.Application")){
this->MessageBox("无法创建Excel应用!");
return;
}
books=app.GetWorkbooks();
book=books.Add(covOptional);
sheets=book.GetSheets();
sheet=sheets.GetItem(COleVariant((short)1));
range=sheet.GetRange(COleVariant("A1"),COleVariant("A1"));
range.SetValue(COleVariant("HELLOEXCEL!"));
font=range.GetFont();
font.SetBold(COleVariant((short)TRUE));
range=sheet.GetRange(COleVariant("A2"),COleVariant("A2"));
range.SetFormula(COleVariant("=RAND()*100000"));
range.SetNumberFormat(COleVariant("$0.00"));
cols=range.GetEntireColumn();
cols.AutoFit();
app.SetVisible(TRUE);
app.SetUserControl(TRUE);
}