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

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

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

  object oBookMark = "MyBookmark";

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

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

  object oStyleName = "MyStyle";

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

  [使用CCWordApp類]

  在工程中包含了CCWordApp.cs這個文件,我不想總是在寫象插入文本,打開文檔這樣的代碼。

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

  下面代碼簡要描述了這個類和他的功能:

  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( );

  打開一個存在的文件的代碼將是這樣的:

  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 - 上面使用的類

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

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

  ModifyDocument.aspx - 打開一個存在的文檔,并在末尾追加一些文本。

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

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

  可以在 Web.config 里修改這個路徑。

本新聞共2頁,當(dāng)前在第2頁  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實現(xiàn)驗證碼
·ASP.NET中在線用戶統(tǒng)計
·用ASP.NET加密口令
·Asp.net+Xml開發(fā)網(wǎng)絡(luò)硬盤 
·用ASP.NET構(gòu)建簡單的Web Form 
·ASP.Net中自定義Http處理及應(yīng)用之HttpModul
·用ASP.NET開發(fā)Web服務(wù)的五則技巧

 
 
 
 
最新文章

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

 
推薦文章
1
2
3
4
5
6
7
8
9
10
iPhone女孩微博爆紅 最寶貴東西換
大連護(hù)士門大尺度艷照高清組圖
中關(guān)村艷照門女主角詳記錄高清組
蘋果員工中毒門
宮如敏不雅照瘋傳 看張馨予韓一菲
深耕市場 永續(xù)經(jīng)營——專訪百腦匯
優(yōu)派專業(yè)電子書 讓您回家旅途多姿
揭曉百萬大獎三星bada魅力綻放中
大明龍權(quán)“江湖英雄會”全國PK大
永恒之塔校園達(dá)人挑戰(zhàn)賽完美落幕
八卦圖解 More>>
iPhone女孩微博爆紅 最寶貴東西換 大連護(hù)士門大尺度艷照高清組圖
中關(guān)村艷照門女主角詳記錄高清組 宮如敏不雅照瘋傳 看張馨予韓一菲