VC生成word文檔的部分代碼的記錄_第1頁(yè)
VC生成word文檔的部分代碼的記錄_第2頁(yè)
VC生成word文檔的部分代碼的記錄_第3頁(yè)
VC生成word文檔的部分代碼的記錄_第4頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、protected:/變量 _application wordapp; documents worddocs; _document worddoc; selection wordselection; range wordrange; tables wordtables; table wordtable; cell wordcell; cells wordcells; _font wordfont; void cautoyaoce:oncreatereport() / currentcount mothervoltagecount commonvoltagecount powercount po

2、werfactorcount frequencycount / todo:初始化word :coinitialize(null); /初始化com組件(必須添加,否則無(wú)法啟動(dòng)word)調(diào)用完畢后 couninitialize(); if (!wordapp.createdispatch(_t(word.application) afxmessagebox(word createdispatch failed!); wordapp.setvisible(true);/make visible wordapp.activate();/激活 worddocs=wordapp.getdocuments

3、();/get documents object / ccomvariant tpl(_t(),visble,doctype(0),newtemplate(false); worddoc=worddocs.add(&tpl,&newtemplate,&doctype,&visble); wordselection=wordapp.getselection(); systemtime systime; getlocaltime(&systime); cstring strreport; strreport.format( 日期: %d-%d-%d 時(shí)間: %d:%d:%d rn rn,systi

4、me.wyear,systime.wmonth,systime.wday,systime.whour,systime.wminute,systime.wsecond); wordselection.typetext(strreport); updatedata(); cstring m_pct; m_pct.format(ct變比:%f,m_ct); wordselection.typetext(m_pct+ ); m_pct.format(pt變比:%f,m_pt); wordselection.typetext(m_pct+rn); /todo:在word中插入表格 if(currentc

5、ount) createdoc(遙測(cè)電流幅值檢驗(yàn),currentbuf,currentcount,3); /生成電流報(bào)表 if(mothervoltagecount) createdoc(遙測(cè)電壓母線幅值檢驗(yàn),mothervoltagebuf,currentcount,3); /生成母線電壓報(bào)表 if(commonvoltagecount) createdoc(遙測(cè)電壓普線幅值檢驗(yàn),commonvoltagebuf,currentcount,3); /生成普線電壓報(bào)表 if(powercount) createdoc(遙測(cè)功率測(cè)量檢驗(yàn),powerbuf,currentcount,2); /生成

6、功率報(bào)表 if(powerfactorcount) createdoc(遙測(cè)功率因數(shù)測(cè)量檢驗(yàn),powerfactorbuf,currentcount,1); /生成功率因數(shù)報(bào)表 if(frequencycount) createdoc(遙測(cè)頻率測(cè)量檢驗(yàn),frequencybuf,currentcount,1); /生成頻率報(bào)表 /todo:保存word ccomvariant filename,fileformat(0),lockcomments(false),password(_t(),addtorecentfiles(true),writepassword(_t(); ccomvarian

7、t readonlyrecommended(false),embedtruetypefonts(false),savenativepictureformat(false),saveformsdata(false),saveasaoceletter(false); ccomvariant encoding(false),insertlinebreaks(false),allowsubstitutions(false),lineending(false),addbidimarks(false); strreport.format(d:%d年%d月%d日%d時(shí)%d分%d秒 報(bào)告,systime.wy

8、ear,systime.wmonth,systime.wday,systime.whour,systime.wminute,systime.wsecond); filename=strreport; /文件名 worddoc.saveas(&filename,&fileformat,&lockcomments,&password,&addtorecentfiles,&writepassword, &readonlyrecommended,&embedtruetypefonts,&savenativepictureformat,&saveformsdata, &saveasaoceletter,

9、 &encoding,&insertlinebreaks,&allowsubstitutions,&lineending,&addbidimarks); wordfont.releasedispatch();wordcells.releasedispatch();wordtable.releasedispatch();wordtables.releasedispatch();wordrange.releasedispatch(); wordselection.releasedispatch();worddoc.releasedispatch();worddocs.releasedispatch

10、();wordapp.releasedispatch(); :coinitialize(null); void cautoyaoce:createcurrentdoc() wordselection.typetext( 遙測(cè)電流幅值檢驗(yàn)報(bào)表rn rn); wordselection.typetext( 日期: 2008-*-*時(shí)間: *:*rn rn); wordtables=worddoc.gettables(); wordrange=wordselection.getrange(); ccomvariant defaultbehavior(1),autofitbehavior(0); wo

11、rdtable=wordtables.add(wordrange,7,7,&defaultbehavior,&autofitbehavior); / updatedata(); wordcell=wordtable.cell(1,1); wordcell.select(); wordselection.movedown(&ccomvariant(5),&ccomvariant(1),&ccomvariant(1); wordcells=wordselection.getcells(); wordcells.merge(); wordcells.setverticalalignment(1);

12、wordselection.typetext(二次電流); wordcell=wordtable.cell(1,2); wordcell.select(); wordselection.moveright(&ccomvariant(1),&ccomvariant(2),&ccomvariant(1); /合并單元格時(shí)要使用&ccomvariant(1) wordcells=wordselection.getcells(); wordcells.merge(); wordselection.typetext(測(cè)控裝置顯示值); wordcell=wordtable.cell(1,3); word

13、cell.select(); wordselection.moveright(&ccomvariant(1),&ccomvariant(2),&ccomvariant(1); wordcells=wordselection.getcells(); wordcells.merge(); wordselection.typetext(操作員工作站顯示值); wordselection.moveright(&ccomvariant(12),&ccomvariant(2),&ccomvariant(0); cstring temp6=ia(a),ib(a),ic(a),ia(a),ib(a),ic(a

14、); for(int i=0;i6;i+) wordselection.typetext(tempi); wordselection.moveright(&ccomvariant(12),&ccomvariant(1),&ccomvariant(0); /單純右移時(shí)使用&ccomvariant(12) cstring str21=1.0000,x,x,x,x,x,x,5.0000,xx,xx,xx,xx,xx,xx,基本誤差,xxx,xxx,xxx,xxx,xxx,xxx; for(i=0;i21;i+) wordselection.typetext(stri); wordselection.

15、moveright(&ccomvariant(12),&ccomvariant(1),&ccomvariant(0); wordselection.typetext(結(jié)論); wordcell=wordtable.cell(6,2); wordcell.select(); wordselection.moveright(&ccomvariant(1),&ccomvariant(5),&ccomvariant(1); wordcells=wordselection.getcells(); wordcells.merge(); wordselection.typetext(合格); wordselection.moveright(&ccomvariant(12),&ccomvariant(1),&ccomvariant(0); wordselection.typetext(備注); wordcell=wordtable.cell(7,2); wordcell.select(); wordselection.moveright(&ccomvar

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論