亚洲AV无码乱码在线观看不卡|最新大伊香蕉精品视频在线|亚洲不卡av一区二区|国产美女无遮挡免费

登錄論壇 | 注冊(cè)會(huì)員 設(shè)為首頁(yè) | 收藏本站
當(dāng)前位置 : 首頁(yè)>軟件學(xué)院>程序開(kāi)發(fā)>ASP.NET>正文
 
在ASP.NET中使用Microsoft Word文檔

http://m.yibo1263.com 2008-6-29 21:09:43  來(lái)源:本站  編輯:張賀兵
 
  在你使用的摸版里,你可以定義一些記號(hào),自動(dòng)化處理將向這些位置填充文本,如下: 

  object oBookMark = "MyBookmark";

  oWordDoc.Bookmarks.Item(ref oBookMark).Range.Text = "Some Text Here";
  

  使用摸版的另一個(gè)優(yōu)點(diǎn)是你可以創(chuàng)建和保存那些在運(yùn)行過(guò)程中你想要的格式化樣式,如下:  

  object oStyleName = "MyStyle";

  oWordDoc.Bookmarks.Item(ref oBookMark).Range.set_Style(ref oStyleName);   

  [使用CCWordApp類(lèi)]

  在工程中包含了CCWordApp.cs這個(gè)文件,我不想總是在寫(xiě)象插入文本,打開(kāi)文檔這樣的代碼。

  所以,我決定把一些最重要的功能封裝到CCWordApp類(lèi)里去。

  下面代碼簡(jiǎn)要描述了這個(gè)類(lèi)和他的功能:

  public class CCWordApp

  {

  //it's a reference to the COM object of Microsoft Word Application

  private Word.ApplicationClass oWordApplic;

  // it's a reference to the document in use

  private Word.Document oWordDoc;   

  // Activate the interface with the COM object of Microsoft Word

  public CCWordApp();  

  // Open an existing file or open a new file based on a template

  public void Open( string strFileName);  

  // Open a new document

  public void Open( );  

  // Deactivate the interface with the COM object of Microsoft Word

  public void Quit( );  

  // Save the document

  public void Save( );  

  //Save the document with a new name as HTML document

  public void SaveAs(string strFileName );  

  // Save the document in HTML format

  public void SaveAsHtml(string strFileName );

  // Insert Text

  public void InsertText( string strText);

  // Insert Line Break

  public void InsertLineBreak( );

  // Insert multiple Line Break

  public void InsertLineBreak( int nline);

  // Set the paragraph alignment

  // Possible values of strType :"Centre", "Right", "Left", "Justify"

  public void SetAlignment(string strType );

  // Set the font style

  // Possible values of strType :"Bold","Italic,"Underlined"

  public void SetFont( string strType );

  // Disable all the style

  public void SetFont( );

  // Set the font name

  public void SetFontName( string strType );

  // Set the font dimension

  public void SetFontSize( int nSize );

  // Insert a page break

  public void InsertPagebreak();

  // Go to a predefined bookmark

  public void GotoBookMark( string strBookMarkName);

  // Go to the end of document

  public void GoToTheEnd( );

  // Go to the beginning of document

  public void GoToTheBeginning( );

  打開(kāi)一個(gè)存在的文件的代碼將是這樣的:

  CCWordApp test ;

  test = new CCWordApp();

  test.Open ("c:\\database\\test.doc");

  test.InsertText("This is the text");

  test.InsertLineBreak;

  test.Save ();

  test.Quit();

  [細(xì)節(jié)]  

  演示工程包含:

  CCWordApp.cs - 上面使用的類(lèi)

  CreateDocModel.aspx - 建立基于使用書(shū)簽的摸版的新文檔的例子。

  CreateNewDoc.aspx - 建立新文檔,并向其中添加一寫(xiě)文本。

  ModifyDocument.aspx - 打開(kāi)一個(gè)存在的文檔,并在末尾追加一些文本。

  template\template1.dot - 摸版的例子(在CreateDocModel.aspx中使用到)

  注意你用來(lái)保存文檔的目錄,應(yīng)該是可重寫(xiě)的。

  可以在 Web.config 里修改這個(gè)路徑。

本新聞共2頁(yè),當(dāng)前在第2頁(yè)  1  2  

 
收藏】【打印】【進(jìn)入論壇
  相關(guān)文章:

·淺析五大ASP.NET數(shù)據(jù)控件
·Discuz!NT 3.1 為ASP.net社區(qū)提速 
·淺析五大ASP.NET數(shù)據(jù)控件
·ASP.NET全局異常處理的方法
·asp.net實(shí)現(xiàn)驗(yàn)證碼
·ASP.NET中在線用戶統(tǒng)計(jì)
·用ASP.NET加密口令
·Asp.net+Xml開(kāi)發(fā)網(wǎng)絡(luò)硬盤(pán) 
·用ASP.NET構(gòu)建簡(jiǎn)單的Web Form 
·ASP.Net中自定義Http處理及應(yīng)用之HttpModul
·用ASP.NET開(kāi)發(fā)Web服務(wù)的五則技巧

 
 
 
 
最新文章

中關(guān)村艷照門(mén)女主角詳記錄高清組圖 
大連護(hù)士門(mén)大尺度艷照高清組圖
iPhone女孩微博爆紅 最寶貴東西換iPhon
反恐精英之父內(nèi)維爾:改變電腦游戲銷(xiāo)售
團(tuán)購(gòu)網(wǎng)站黎明之前:中國(guó)市場(chǎng)慘烈廝殺不
團(tuán)購(gòu)鼻祖Groupon中國(guó)揭秘:快與慢的商業(yè)
Spil Games發(fā)布新的品牌形象
1800配置一臺(tái)主機(jī) 不要顯示器
聯(lián)想V360筆記本模特寫(xiě)真
愛(ài)國(guó)者第四代移動(dòng)硬盤(pán)將面市、低電壓保

 
推薦文章
1
2
3
4
5
6
7
8
9
10
iPhone女孩微博爆紅 最寶貴東西換
大連護(hù)士門(mén)大尺度艷照高清組圖
中關(guān)村艷照門(mén)女主角詳記錄高清組
蘋(píng)果員工中毒門(mén)
宮如敏不雅照瘋傳 看張馨予韓一菲
深耕市場(chǎng) 永續(xù)經(jīng)營(yíng)——專(zhuān)訪百腦匯
優(yōu)派專(zhuān)業(yè)電子書(shū) 讓您回家旅途多姿
揭曉百萬(wàn)大獎(jiǎng)三星bada魅力綻放中
大明龍權(quán)“江湖英雄會(huì)”全國(guó)PK大
永恒之塔校園達(dá)人挑戰(zhàn)賽完美落幕
八卦圖解 More>>
iPhone女孩微博爆紅 最寶貴東西換 大連護(hù)士門(mén)大尺度艷照高清組圖
中關(guān)村艷照門(mén)女主角詳記錄高清組 宮如敏不雅照瘋傳 看張馨予韓一菲
施秉县| 瑞昌市| 英超| 金寨县| 汉阴县| 绥江县| 郎溪县| 吉安市| 循化| 开封县| 东海县| 明水县| 临漳县| 清水县| 雷山县| 龙陵县| 随州市| 澎湖县| 德清县| 家居| 吴旗县| 五峰| 五河县| 铜山县| 龙门县| 黔西县| 万州区| 中卫市| 丰宁| 定南县| 浪卡子县| 伊吾县| 新干县| 奉新县| 仪征市| 南漳县| 河源市| 宜州市| 祁东县| 榆中县| 乳山市|