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

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條評論
主站蜘蛛池模板: h视频在线观看网站 | 一区二区三区欧美日韩国产 | 日韩h视频| 91在线播放免费不卡无毒 | 国产日韩美国成人 | 五月婷婷中文 | 亚洲国产字幕 | 青青青爽线在线视频观看 | 天天草天天 | 国产精品久久亚洲不卡动漫 | 亚洲欧洲第一页 | 四虎影视在线看免费观看 | 日本高清视频www夜色资源 | 亚洲欧美中文字幕 | 婷婷午夜激情 | 久久久久久久一精品 | 日韩精品一区二区三区免费视频 | 91精品久久久久亚洲国产 | www.欧美激情 | 青青草a免费线观a | 日本美女视频韩国视频网站免费 | 妖精www视频在线观看高清 | 国产一区二区久久 | 久久久久久91| 午夜精品久久久久久99热 | 精品成人免费一区二区在线播放 | 久久精品免费大片国产大片 | 在线观看国产视频 | 久久vs国产综合色大全 | 九九热视频免费观看 | 91精品国产91久久久久久青草 | 国产精品免费视频一区二区三区 | 雅虎日本免费一区二区三区 | 色综合激情 | 成人精品视频网站 | 国产一级特黄老妇女大片免费 | 久久香蕉国产线看观看亚洲片 | 四虎 影院ww9584h| 成人激情开心网 | 成人在线亚洲 | 中文字幕亚洲色图 |