如何使用.NET將PowerPoint轉(zhuǎn)為HTML文件 我們當(dāng)然要使用Com組件了,所以要先安裝powerpoint2000,在VS.NET里面添加一個(gè)refrence,找到microsoft PowerPoint object library 9.0,添加進(jìn)來。 然后寫如下代碼,很簡(jiǎn)單,我就不必解釋了:) using System; using Office; using PowerPoint;
namespace CourseServer.Course { /// <summary> /// Author:王洪超 /// Version:1.0 /// Date:2001/6/9 /// Description:轉(zhuǎn)換PowerPoint的PPT文件為HTML文件 /// </summary> public class ConvertPowerPoint { /// <summary> /// 建立對(duì)PowerPoint.Application的Com組件的引用 /// </summary> private PowerPoint.Application ppt; /// <summary> /// 指向具體的文件; /// </summary> private PowerPoint.Presentation pptFile; private string _HtmlFileName; /// <summary> /// 只寫屬性,設(shè)置另存的HTML文件的文件路徑 /// </summary> public string HtmlFileName { set { _HtmlFileName=value; } }
/// <summary> /// 構(gòu)造器 /// </summary> public ConvertPowerPoint() { // // TODO: Add constructor logic here //
ppt=new PowerPoint.Application(); } /// <summary> /// 轉(zhuǎn)換過程 /// </summary> /// <param name="pptFileName">欲轉(zhuǎn)換的PowerPoint文件名稱</param>
public void Convert(string pptFileName) {
pptFile=ppt.Presentations.Open(pptFileName,Office.MsoTriState.msoTrue,Office.MsoTriState.msoCTrue,Office.MsoTriState.msoFalse); pptFile.SaveAs(_HtmlFileName,PowerPoint.PpSaveAsFileType.ppSaveAsHTML,Office.MsoTriState.msoCTrue); pptFile.Close();
} } } &n
|
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!