如何将powerpoint转换为html

80酷酷网    80kuku.com

  erp|转换如何使用.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();
                

        }
    }
}
  

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: