How to convert powerpoint to html file using .net
Of course we have to use the com component, so we need to install powerpoint2000 first, add a reminder in vs.net, find Microsoft Powerpoint object library 9.0, and add it.
Then write the following code, it's very simple, I don't have to explain it :)
using system;
using office;
using powerpoint;
namespace courseserver.course
{
/// <summary>
/// author:Wang Hongchao
/// version:1.0
/// date:2001/6/9
/// description: Convert the ppt file of powerpoint to html file
/// </summary>
public class convertpowerpoint
{
/// <summary>
/// Create a reference to the com component of powerpoint.application
/// </summary>
private powerpoint.application ppt;
/// <summary>
/// Point to specific files;
/// </summary>
private powerpoint.presentation pptfile;
private string _htmlfilename;
/// <summary>
/// Only write attributes, set the file path of the saved html file
/// </summary>
public string htmlfilename
{
set
{
_htmlfilename=value;
}
}
/// <summary>
/// Constructor
/// </summary>
public convertpowerpoint()
{
//
// todo: add constructor logic here
//
ppt=new powerpoint.application();
}
/// <summary>
/// Conversion process
/// </summary>
/// <param name=pptfilename>The powerpoint file name to be converted</param>
public void convert(string pptfilename)
{
pptfile=ppt.presentations.open(pptfilename,office.msotristate.msottrue,office.msotristate.msottrue,office.msotristate.msofalse);
pptfile.saveas(_htmlfilename,powerpoint.ppsaveasfiletype.ppsaveashtml,office.msotristate.msoctrue);
pptfile.close();
}
}
}