search
Homephp教程php手册C#生成的dll(引用了office的com控件实现文档转换),PHP调用时

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);

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>?>

不知道是由什么引起的。

初步怀疑有2中可能:

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

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

 

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

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.