一个棘手的问题请高手指教!!!!!asp.net中调用PPT DLL
代码如下:
FUpload.SaveAs(uploadPath + "\\" + dlistClass.SelectedItem.Text + "\\" + newFileName);
//如果存储文件类型为ppt,pps,pptx则需要另存一个htm格式的文件以便支持在线浏览功能。
if (FileOpt.GetFileType(oldFileName) == ".ppt" || FileOpt.GetFileType(oldFileName) == ".pptx" || FileOpt.GetFileType(oldFileName) == ".pps")
{
ConvertToHTML(sonPath + "\\" + newFileName, pptToHtml + "\\" + newFileName);
}
return true;
/// <summary>
/// 将PPT文件转换为htm
/// </summary>
/// <param name="PptFilePath">PPT文件的绝对路径</param>
/// <param name="HtmFilePath">htm文件的绝对路径</param>
public void ConvertToHTML(string PptFilePath, string HtmFilePath)
{
string pptPath = PptFilePath;
string htmlFileName = HtmFilePath.Substring(0,HtmFilePath.Length-Path.GetExtension(HtmFilePath).Length) + ".htm";
Label1.Text = "打开文档中请稍等。。。";
//执行到这里程序就终止了。在vs的调试模式或自带的web服务器上运行正常,移植到iis中就无法得到正常执行了。
PPT.ApplicationClass ppta = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
try
{
PPT.Presentation pptFile;
pptFile = ppta.Presentations.Open(pptPath, MsoTriState.msoCTrue, MsoTriState.msoCTrue, MsoTriState.msoFalse);
Label1.Text = "保存文档中请稍等。。。。。";
pptFile.SaveAs(htmlFileName, PPT.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTriStateToggle);
Label1.Text = "操作完成!";
pptFile.Close();
ppta.Quit();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}