亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

C#操作Word完全功略!

系統(tǒng) 2636 0
【摘自】? http://tmsoft.lsxy.com/trackback.php?tbID=334&extra=2aa67d ? 周老師科研站

前提:
導入COM庫:Microsoft word 11.0 Object Library.
引用里面就增加了:



創(chuàng)建新Word
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,? ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

打開文檔:
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????
object ?fileName? = ? @" E:CCCXCXXTestDoc.doc " ;
????????????oDoc?
= ?oWord.Documents.Open( ref ?fileName,
????????????
ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing,
????????????
ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing,
????????????
ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing,? ref ?oMissing);

導入模板
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????
object ?fileName? = ? @" E:XXXCCXTest.doc " ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?fileName,? ref ?oMissing,
????????????????????????????
ref ?oMissing,? ref ?oMissing);


.添加新表
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,? ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

????????????
object ?start? = ? 0 ;
????????????
object ?end? = ? 0 ;
????????????Word.Range?tableLocation?
= ?oDoc.Range( ref ?start,? ref ?end);
????????????oDoc.Tables.Add(tableLocation,?
3 ,? 4 ,? ref ?oMissing,? ref ?oMissing);

.表插入行
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,? ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

????????????
object ?start? = ? 0 ;
????????????
object ?end? = ? 0 ;
????????????Word.Range?tableLocation?
= ?oDoc.Range( ref ?start,? ref ?end);
????????????oDoc.Tables.Add(tableLocation,?
3 ,? 4 ,? ref ?oMissing,? ref ?oMissing);

????????????Word.Table?newTable?
= ?oDoc.Tables[ 1 ];
????????????
object ?beforeRow? = ?newTable.Rows[ 1 ];
????????????newTable.Rows.Add(
ref ?beforeRow);

.單元格合并
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,? ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

????????????
object ?start? = ? 0 ;
????????????
object ?end? = ? 0 ;
????????????Word.Range?tableLocation?
= ?oDoc.Range( ref ?start,? ref ?end);
????????????oDoc.Tables.Add(tableLocation,?
3 ,? 4 ,? ref ?oMissing,? ref ?oMissing);

????????????Word.Table?newTable?
= ?oDoc.Tables[ 1 ];
????????????
object ?beforeRow? = ?newTable.Rows[ 1 ];
????????????newTable.Rows.Add(
ref ?beforeRow);

????????????Word.Cell?cell?
= ?newTable.Cell( 1 ,? 1 );
????????????cell.Merge(newTable.Cell(
1 ,? 2 ));

.單元格分離
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

????????????
object ?start? = ? 0 ;
????????????
object ?end? = ? 0 ;
????????????Word.Range?tableLocation?
= ?oDoc.Range( ref ?start,? ref ?end);
????????????oDoc.Tables.Add(tableLocation,?
3 ,? 4 ,? ref ?oMissing,? ref ?oMissing);

????????????Word.Table?newTable?
= ?oDoc.Tables[ 1 ];
????????????
object ?beforeRow? = ?newTable.Rows[ 1 ];
????????????newTable.Rows.Add(
ref ?beforeRow);

????????????Word.Cell?cell?
= ?newTable.Cell( 1 ,? 1 );
????????????cell.Merge(newTable.Cell(
1 ,? 2 ));

????????????
object ?Rownum? = ? 2 ;
????????????
object ?Columnnum? = ? 2 ;
????????????cell.Split(
ref ?Rownum,? ref ??Columnnum);

通過段落控制插入
???????????? object ?oMissing? = ?System.Reflection.Missing.Value;
????????????
object ?oEndOfDoc? = ? " \endofdoc " ;? /**/ /* ?endofdoc?is?a?predefined?bookmark? */

????????????
// Start?Word?and?create?a?new?document.
????????????Word._Application?oWord;
????????????Word._Document?oDoc;
????????????oWord?
= ? new ?Word.Application();
????????????oWord.Visible?
= ? true ;
????????????oDoc?
= ?oWord.Documents.Add( ref ?oMissing,? ref ?oMissing,
????????????????
ref ?oMissing,? ref ?oMissing);

????????????
// Insert?a?paragraph?at?the?beginning?of?the?document.
????????????Word.Paragraph?oPara1;
????????????oPara1?
= ?oDoc.Content.Paragraphs.Add( ref ?oMissing);
????????????oPara1.Range.Text?
= ? " Heading?1 " ;
????????????oPara1.Range.Font.Bold?
= ? 1 ;
????????????oPara1.Format.SpaceAfter?
= ? 24 ;???? // 24?pt?spacing?after?paragraph.
????????????oPara1.Range.InsertParagraphAfter();

C#操作Word完全功略!


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 91探花在线 | 国产一级毛片国语普通话对白 | 亚洲精品国产一区二区在线 | www.青草| 美女黄频 | 五月婷婷开心综合 | 久久国产精品范冰啊 | 老子影院伦不卡欧美 | freesex寂寞老妇hd | 国产娱乐凹凸视觉盛宴在线视频 | 久久久久依人综合影院 | 欧美一级高清毛片aaa | 日本欧美高清全视频 | 欧洲精品在线观看 | 亚洲毛片免费观看 | 久久精品中文字幕首页 | 日本不卡视频 | 欧美性猛交xxx嘿人猛交 | 欧美一级毛片在线播放 | 国产在线精品一区二区高清不卡 | 亚洲综合欧美 | 国产亚洲漂亮白嫩美女在线 | 4虎成人 | 欧美综合图区 | 欧美啪啪毛片一区二区 | 亚洲欧美在线视频免费 | 欧美日韩中文在线视频 | 国产老熟| 青青热久久国产久精品 | 国产在线欧美精品中文一区 | 毛片在线播放a | 亚洲精品国产综合久久一线 | 免费观看国产精品 | 神马影院我不卡影院 | 香蕉eeww99国产在线观看 | 精品久久免费观看 | 欧美在线成人午夜网站 | 在线亚洲 欧美 日本专区 | 最新地址四虎www4hutv | 九九精品国产99精品 | 精品久久久久不卡无毒 |