1. 程式人生 > >excel修改單元格中文字上標

excel修改單元格中文字上標

需要編輯帶上標的文字格式。

CSheet sheet;   // 工作頁
....
CCharacters charac;
CFont0      font;
CRange      rangeTmp;

 // strStCell, strEndCell為起始單元格和終止單元格位置。
        rangeTmp.AttachDispatch(sheet.get_Range(_variant_t(_T(strStCell)), _variant_t(_T(strEndCell))), true);          

font.AttachDispatch(charac.get_Font());

// put_Superscript為上標格式函式
font.put_Superscript(_variant_t((LONG)1)); font.ReleaseDispatch(); charac.ReleaseDispatch(); rangeTmp.ReleaseDispatch();

sheet假設為已經申請好的工作簿資源。