phpcom(PHPcomposer)

本文目錄一覽:

php中有個com組件,它裏面都有哪些屬性和方法可以調用呢?

先到PHP.INI中打開COM選項,com.allow_dcom = true

PHP 5.4.5後,com/dotnet 模塊已經成了單獨的擴展,所以需要在PHP.ini中配置extension=php_com_dotnet.dll,如果PHP VERSION5.4.5 則不需要。否則的話,可能就是報錯 Fatal error: Class ‘COM’ not found 了

配置方法為:只需在擴展列表裡添加extension=php_com_dotnet.dll即可

另外需要了解的是,COM組件雖然也是DLL擴展,但它不是PHP擴展,所以把Senc.dll拷貝到php/ext 目錄,然後在PHP.INI里加載是錯誤的,PHP也不認識它

配置完畢後可以測試下,語句為

$word = new COM(“word.application”) or die(“Unable to instanciate Word”);

print “Loaded Word, version {$word-Version}\n”;

上面語句本機必須安裝了office才可以

openoffice的為:

$obj = new COM(“com.sun.star.ServiceManager”) or die(“Unable to instanciate Word”);

PHP調用COM組件操作EXCEL文檔的問題

COM組件是通用的,如果你想用調用COM組件來操作EXCEL文檔,建議可以參考的工具和資料如下:

1. office (excel)VBA幫助文檔,VBA中包含對象、屬性、方法的說明。

2. 使用OCX、DLL等查看工具,比如:

oleview軟件

比較簡便的辦法,你可以下載 vbsEdit 軟件,其中帶有 oleview 查看工具,當你引入某個 com 組件時,會自動顯示該組件對象的方法、屬性等。

php com組件怎麼點擊a標籤

首先我假定你當前的URL是localhost/show.php 其次你數據庫的需要一個主鍵 PRIMARY KEY

如何用PHP調用自己編寫的COM組件

首先寫ActiveX Dll:

新建一個VB6工程,ActiveX Dll將工程命名為P_test,類名為c_test ,類的文件內容如下:

Option Explicit

Private MyscriptingContext As scriptingContext

Private MyApplication As Application

Private MyRequest As Request Private MyResponse As Response

Private MyServer As Server

Private MySession As Session Public

Sub OnStartPage(PassedscriptingContext As scriptingContext)

Set MyscriptingContext = PassedscriptingContext

Set MyApplication = MyscriptingContext.Application

Set MyRequest = MyscriptingContext.Request

Set MyResponse = MyscriptingContext.Response

Set MyServer = MyscriptingContext.Server

Set MySession = MyscriptingContext.Session

End Sub

Public Sub OnEndPage()

Set MyscriptingContext = Nothing

Set MyApplication = Nothing

Set MyRequest = Nothing

Set MyResponse = Nothing

Set MyServer = Nothing

Set MySession = Nothing

End Sub

Public Function Test_Number(num) As Variant

If num 0 Then Get_Number_Attrib = 1

If num = 0 Then Get_Number_Attrib = 0

End Function

編譯生成p_test.dll文件

註冊

提示符下運行:regsvr32 p_test.dll

編寫php文件,test.php4代碼如下:

?php

$b=new COM(“p_test.c_test”);

$a=$b-Test_Number(-454);

echo $a;

?

可能碰到的問題是,編譯工程時通不過,要將Microsoft Active Server Pages Object Library引用進來,具體實現”Project-References”找到改庫,並勾上 。

你好,請指導下php調用COM組件處理excel

以下一個php調用COM訪問excel的示例:

?php

//指定頁面編碼,防止出現中文亂碼的情形

header(‘Content-type: text/html; charset=gb2312’);

//啟動Excel

$ms_excel = new COM(“excel.application”) or die(“不能打開Excel應用程序”);

//打開excel文件

$ms_excel-Application-WorkBooks-Open( ‘e:\test\test.xls’) or die(“不能打開工作簿”);

//在工作簿的第2個工作表的單元格B1中輸入文本

$ms_excel-Worksheets(2)-Range(“B1”)-Value = “測試”;

//保存工作簿

if(!$ms_excel-ActiveWorkBook-Saved)

{

$ms_excel-ActiveWorkBook-save();

}

//關閉工作簿

$ms_excel-Quit();

//清空對象

$ms_excel = null;

?

如何解決php com

先到PHP.INI中打開COM選項,com.allow_dcom = true 注意: PHP 5.4.5後,com/dotnet 模塊已經成了單獨的擴展,所以需要在PHP.ini中配置extension=php_com_dotnet.dll ,

如果PHP VERSION5.4.5 低版本則不需要。

原創文章,作者:YWQPH,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/329404.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
YWQPH的頭像YWQPH
上一篇 2025-01-14 18:55
下一篇 2025-01-14 18:55

相關推薦

  • phpcom權限,php權限控制

    本文目錄一覽: 1、php 權限控制實現方式有幾種 2、php後台多用戶權限設置及實現思路 3、php怎麼開啟com組件 4、在php網站中用戶權限 5、php權限管理如何實現 p…

    編程 2024-10-22
  • phpcom對象,面向對象PHP

    本文目錄一覽: 1、PHP 調用COM組件問題求助,高分懸賞,求各位高手或有相似問題解決經歷的同學看看,不勝感謝! 2、PHP與ASP的區別是什麼 3、PHP的優缺點是什麼? 4、…

    編程 2024-10-04

發表回復

登錄後才能評論