110,476
社区成员
发帖
与我相关
我的任务
分享
string fileFolder = Path.GetDirectoryName(wordFilePath);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(wordFilePath);
string htmlFilePath = fileFolder + @"\" + fileNameWithoutExtension + @".html";
Object objWordPath = wordFilePath;
Object objHtmlPath = htmlFilePath;
MSWord.Application wordApp;
MSWord.Document wordDoc;
Object Nothing = Missing.Value;
wordApp = new MSWord.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref objWordPath, ref Nothing, ref Nothing, ref Nothing);//===========PHP调用时这下面的语句执行不到
object format = MSWord.WdSaveFormat.wdFormatFilteredHTML;
wordDoc.SaveAs(ref objHtmlPath, ref format, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
dll注册后,PHP调用部分:
<?php
$c= new COM("ComLibrary.Test");
echo $c->SaveWordAsHtml("D:\\ningtao\\xampp\\htdocs\\test.doc");
?>
不知道是由什么引起的。
初步怀疑有2中可能:
1、dll注册为COM+再被PHP调用时,没有正确的调用office的com组件。
2、被PHP调用时,由于文件的读写权限引起的问题。
大家有没有遇到过类似问题的,该如何解决?