如何將powerpoint轉換為html
2024-08-26 00:15:32
供稿:網友
如何使用.net將powerpoint轉為html文件
我們當然要使用com組件了,所以要先安裝powerpoint2000,在vs.net里面添加一個refrence,找到microsoft powerpoint object library 9.0,添加進來。
然后寫如下代碼,很簡單,我就不必解釋了:)
using system;
using office;
using powerpoint;
namespace courseserver.course
{
/// <summary>
/// author:王洪超
/// version:1.0
/// date:2001/6/9
/// description:轉換powerpoint的ppt文件為html文件
/// </summary>
public class convertpowerpoint
{
/// <summary>
/// 建立對powerpoint.application的com組件的引用
/// </summary>
private powerpoint.application ppt;
/// <summary>
/// 指向具體的文件;
/// </summary>
private powerpoint.presentation pptfile;
private string _htmlfilename;
/// <summary>
/// 只寫屬性,設置另存的html文件的文件路徑
/// </summary>
public string htmlfilename
{
set
{
_htmlfilename=value;
}
}
/// <summary>
/// 構造器
/// </summary>
public convertpowerpoint()
{
//
// todo: add constructor logic here
//
ppt=new powerpoint.application();
}
/// <summary>
/// 轉換過程
/// </summary>
/// <param name="pptfilename">欲轉換的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();
}
}
}