Maison > php教程 > php手册 > le corps du texte

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

WBOY
Libérer: 2016-06-06 19:42:34
original
1176 Les gens l'ont consulté

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);
Copier après la connexion

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>?>
Copier après la connexion

不知道是由什么引起的。

初步怀疑有2中可能:

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

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

 

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

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!