Heim > php教程 > php手册 > Hauptteil

C#生成的dll(引用了office的com控件实现文档转换),PHP调用时

WBOY
Freigeben: 2016-06-06 19:42:34
Original
1176 Leute haben es durchsucht

C#生成dll,其中引用了office的com控件实现文档转换。 当其他winform程序调用时正常。 但注册该dll后,由PHP调用时出错。 try catch了一下,输出 Word 出现问题 。 测试机器上装的是office2007。C#实现文档转换部分: string fileFolder = Path.GetDirectory

C#生成dll,其中引用了office的com控件实现文档转换。

当其他winform程序调用时正常。

但注册该dll后,由PHP调用时出错。

try catch了一下,输出“Word 出现问题”。

测试机器上装的是office2007。C#实现文档转换部分:

          <span>string</span> fileFolder =<span> Path.GetDirectoryName(wordFilePath);
          </span><span>string</span> fileNameWithoutExtension =<span> Path.GetFileNameWithoutExtension(wordFilePath);
          </span><span>string</span> htmlFilePath = fileFolder + <span>@"</span><span>\</span><span>"</span> + fileNameWithoutExtension + <span>@"</span><span>.html</span><span>"</span><span>;

          Object objWordPath </span>=<span> wordFilePath;
          Object objHtmlPath </span>=<span> htmlFilePath;
          MSWord.Application wordApp;
          MSWord.Document wordDoc;
          Object Nothing </span>=<span> Missing.Value;
          wordApp </span>= <span>new</span><span> MSWord.ApplicationClass();
          wordDoc </span>= wordApp.Documents.Add(<span>ref</span> objWordPath, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing);<span>//</span><span>===========PHP调用时这下面的语句执行不到</span>
          <span>object</span> format =<span> MSWord.WdSaveFormat.wdFormatFilteredHTML;
          wordDoc.SaveAs(</span><span>ref</span> objHtmlPath, <span>ref</span> format, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span><span> Nothing,
            </span><span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span><span> Nothing);
          wordDoc.Close(</span><span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span><span> Nothing);
          wordApp.Quit(</span><span>ref</span> Nothing, <span>ref</span> Nothing, <span>ref</span> Nothing);
Nach dem Login kopieren

dll注册后,PHP调用部分:

<span>php
</span><span>$c</span>= <span>new</span> COM("ComLibrary.Test"<span>);
</span><span>echo</span> <span>$c</span>->SaveWordAsHtml("D:\\ningtao\\xampp\\htdocs\\test.doc"<span>);
</span>?>
Nach dem Login kopieren

不知道是由什么引起的。

初步怀疑有2中可能:

1、dll注册为COM+再被PHP调用时,没有正确的调用office的com组件。

2、被PHP调用时,由于文件的读写权限引起的问题。

 

大家有没有遇到过类似问题的,该如何解决?

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!