PPT文件转换为HTML文件

参考01年王洪超写的,由于引用的Office版本不同,命名空间有所改变,故整理一下,代码如下:
//本案例中引用的是:11.0.0.0
using Microsoft.Office;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Interop;
using Microsoft.Office.Core;

/// <summary>
/// C#转换PPT文件为HTML文件
/// </summary>
public class ConvertPowerPoint
{
    /// <summary>
    /// 建立对PowerPoint.Application的Com组件的引用
    /// </summary>
    private Microsoft.Office.Interop.PowerPoint.Application ppt;
    /// <summary>
    /// 指向具体的文件;
    /// </summary>
    private Microsoft.Office.Interop.PowerPoint.Presentation pptFile;
    /// <summary>
    /// 构造器
    /// </summary>
    public ConvertPowerPoint()
    {
        ppt = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
    }
    /// <summary>
    /// 转换过程
    /// </summary>
    /// <param name="pptFilePath">欲转换的PPT文件的绝对路径</param>
   ///<param name="htmFilePath">htm文件的绝对路径,如”e:\\Project2008\\PPT_Test\\1.html“</param>

    public void Convert(string htmFilePath,string pptFilePath)
    {
        if (ppt == null)
            return;
        pptFile = ppt.Presentations.Open(pptFilePath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
        pptFile.SaveAs(htmlFilePath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoCTrue);
        pptFile.Close();
    }
}

转载于:https://www.cnblogs.com/tianyige/archive/2008/09/05/1285047.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值