set bg color:
CApplication app;
CWorkbooks books;
CWorkbook book;
CWorksheets sheets;
CWorksheet sheet;
CRange range;
CInterior interior;
......
COleVariant covTrue((short)TRUE), covFalse((short)FALSE), covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
if(!app.CreateDispatch(TEXT("Excel.Application"))) {
AfxMessageBox(TEXT("Couldn't start Excel and get Application object.\nPlease (re)install MS Excel.",MB_OK|MB_ICONSTOP));
return;
}
books = app.get_Workbooks();
if(m_bFromFile)
book = books.Open(m_strFile, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional, covOptional,covOptional,covOptional );
else
book = books.Add (covOptional);
sheets =book.get_Sheets();
sheet = sheets.get_Item(COleVariant((short)1));
range = sheet.get_Range(COleVariant(TEXT("A1")), COleVariant(TEXT("G1")));
interior=range.get_Interior();
interior.put_ColorIndex(COleVariant((short)36));
interior.put_Color(COleVariant(long(RGB(0xFF,0xC4,0xC4))));
here is how to merge:
range = sheet.get_Range(COleVariant(TEXT("A1")),COleVariant(TEXT("G1")));
range.Merge(covOptional);