COMFunctionsinPHP4(Windows)_PHP
Using the PHP4 COM functions with MS Excel
As for the Word example above, study the code with the help from the Visual Basic Editor ObjectBrowser for Excel.
#Set the workbook to use and its sheet. In this example we use a spreadsheet that
#comes with the Excel installation called: SOLVSAMP.XLS
$workbook = "C:\Program Files\Microsoft office\Office\Samples\SOLVSAMP.XLS";
$sheet = "Quick Tour";
#Instantiate the spreadsheet component.
$ex = new COM("Excel.sheet") or Die ("Did not connect");
#Get the application name and version
print "Application name:{$ex->Application->value}
" ;
print "Loaded version: {$ex->Application->version}
";
#Open the workbook that we want to use.
$wkb = $ex->application->Workbooks->Open($workbook) or Die ("Did not open");
#Create a copy of the workbook, so the original workbook will be preserved.
$ex->Application->ActiveWorkbook->SaveAs("Ourtest");
#$ex->Application->Visible = 1; #Uncomment to make Excel visible.
# Read and write to a cell in the new sheet
# We want to read the cell E11 (Advertising in the 4th. Quarter)
$sheets = $wkb->Worksheets($sheet); #Select the sheet
$sheets->activate; #Activate it
$cell = $sheets->Cells(11,5) ; #Select the cell (Row Column number)
$cell->activate; #Activate the cell
print "Old Value = {$cell->value}
"; #Print the value of the cell:10000
$cell->value = 15000; #Change it to 15000
print "New value = {$cell->value}
";#Print the new value=15000
#Eventually, recalculate the sheet with the new value.
$sheets->Calculate; #Necessary only if calc. option is manual
#And see the effect on total cost(Cell E13)
$cell = $sheets->Cells(13,5) ; #Select the cell (Row Column number)
$number = Number_format($cell->value);
print "New Total cost =\$$number - was \$47,732 before.
";
#Should print $57,809 because the advertising affects the Corporate overhead in the
# cell formula.
#Example of use of the built-in functions in Excel:
#Function: PMT(percent/12 months,Number of payments,Loan amount)
$pay = $ex->application->pmt(0.08/12,10,10000);
$pay = sprintf("%.2f",$pay);
print "Monthly payment for $10,000 loan @8% interest /10 months: \$ $pay
";
#Should print monthly payment = $ -1,037.03
#Optionally, save the modified workbook
$ex->Application->ActiveWorkbook->SaveAs("Ourtest");
#Close all workbooks without questioning
$ex->application->ActiveWorkbook->Close("False");
unset ($ex);
?>
This example should get you going with the Excel COM and PHP. Of course there are many more objects to use. Writing an OOP wrapper for the principal functions will make access to the excel objects even easier.
Using PHP COM with Adobe Distiller
This last example is for a non-MS program: If your program has produced a PostScript document, it may be interesting to transform it (Distill it) to a PDF document. Adobe has a program called Distiller with a windows version that can be instantiated, with the following code:
$pdf = new COM("pdfdistiller.pdfdistiller.1");
?>
Note that the OLE Identifier name is not obvious, especially when the distiller documentation (Adobe's Technical Note #5158) refers to it as "pdfdistiller."
The principal method to distill a document is:
$pdf->FileToPdf ($psfile, strOutputPDF '', strJobOptions "");
?>
Where $psfile is the name of the PostScript file, strOutputPDF is the name for the output PDF file. StrJobOptions is the name of the parameters file for Distiller. The two last parameters of the method can be left blank to use the same name, the PS file for the PDF file and to use the default Job options file. For example:
$pdf->FileToPdf ($psfile, "", "");
#Where $psfile could be Myfile.ps and the result file: Myfile.pdf
?>
There are more methods and properties that can be used with Distiller. If you are interested, look at the Adobe's technical note.
Caveats/Possible problems
If there are some errors in your code, you may instantiate the object and your program may not close before it times out. Worst of all, the application may retentively be instantiated. As a result, several copies may lay around in your programs list and interfere after you have corrected the problem. The solution: After fixing the bug, clean up (CTRL+ALT+Delete> and End Task) all the instances in the program list before you restart. For this same reason, always close the application at the end of your code and unlink the instance.
You may experience some oddities with com_get and com_set. For example: $Version = Com_get($instance->Application,"Version"); Works with Word, but produces an error with Excel.
Some Objects won't be instantiated by PHP4, it appears that these objects need a custom interface that PHP4-COM doesn't support.
Why use it?
Hopefully, these three examples have shown you the ropes. PHP COM allows the connection to many Windows programs inside a PHP script. The code is simpler than ASP's and can be integrated with the rest of PHP's powerful database functions. Microsoft markets the COM technology everywhere and under different names and architectures, like COM+(Combine COM with Microsoft Transaction Server MTS), ADO, OLE DB, OWC, Windows DNA, etc. PHP and Apache, working together, are now offering an open source solution to this confusion.
http://phpclasses.upperdesign.com/browse.html?package=86
--Alain
PS: See the EXCEL class using the COM interface at:

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











오픈 소스에 대해 자세히 알아보려면 다음을 방문하세요. 51CTO Hongmeng 개발자 커뮤니티 https://ost.51cto.com 실행 환경 DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. 애플리케이션을 생성하려면 파일을 클릭합니다. >새파일->CreateProgect. 템플릿 선택: [OpenHarmony]EmptyAbility: 프로젝트 이름 shici, 애플리케이션 패키지 이름 com.nut.shici 및 애플리케이션 저장 위치 XXX(한자, 특수 문자, 공백 없음)를 입력합니다. CompileSDK10, 모델: 스테이지. 장치

기계력 보고서 편집자: 우신(Wu Xin) 국내판 휴머노이드 로봇+대형 모델팀이 옷 접기 등 복잡하고 유연한 재료의 작업 작업을 처음으로 완료했습니다. OpenAI 멀티모달 대형 모델을 접목한 Figure01이 공개되면서 국내 동종업체들의 관련 진전이 주목받고 있다. 바로 어제, 중국의 "1위 휴머노이드 로봇 주식"인 UBTECH는 Baidu Wenxin의 대형 모델과 긴밀하게 통합되어 몇 가지 흥미로운 새로운 기능을 보여주는 휴머노이드 로봇 WalkerS의 첫 번째 데모를 출시했습니다. 이제 Baidu Wenxin의 대형 모델 역량을 활용한 WalkerS의 모습은 이렇습니다. Figure01과 마찬가지로 WalkerS는 움직이지 않고 책상 뒤에 서서 일련의 작업을 완료합니다. 인간의 명령을 따르고 옷을 접을 수 있습니다.

인공 지능(AI)은 많은 산업 분야의 판도를 변화시켜 기업이 효율성, 의사 결정 및 고객 경험을 개선할 수 있도록 지원합니다. AI가 계속 발전하고 더욱 복잡해짐에 따라 기업은 AI 개발 및 배포를 지원하기 위해 올바른 인프라에 투자하는 것이 중요합니다. 이 인프라의 핵심 측면은 IT 팀과 데이터 과학 팀 간의 협업입니다. 둘 다 AI 이니셔티브의 성공을 보장하는 데 중요한 역할을 하기 때문입니다. 인공 지능의 급속한 발전으로 인해 컴퓨팅 성능, 스토리지 및 네트워크 기능에 대한 수요가 증가했습니다. 이러한 요구는 AI에 필요한 복잡하고 리소스 집약적인 워크로드를 처리하도록 설계되지 않은 기존 IT 인프라에 부담을 줍니다. 결과적으로 기업은 이제 AI 워크로드를 지원할 수 있는 시스템을 구축하기 위해 노력하고 있습니다.

comcn과 com의 차이점: 1. comcn과 com은 의미상 차이는 있지만 접속 속도에는 차이가 없습니다. 2. comcn은 국제 도메인 이름으로 다음 사용자가 사용하는 글로벌 최상위 도메인 이름입니다. cn은 중국 회사 도메인 이름이지만 국내 상업 기관, 국내 도메인 이름은 기업만 등록할 수 있습니다. 3. 검색 우선 순위는 cn이 .cn 서버를 찾은 후 .cn을 먼저 검색하는 것입니다. 그러면 서버는 .com을 검색합니다. 4. cn은 cnnic China Internet Center Management에서 제공하고 com의 관리 조직은 해외에 있습니다.

옛날에 제가 컴퓨터 과학을 전공하는 신입생이었을 때, 채용 웹사이트에서 많은 채용 공고를 찾아보던 중 R&D 엔지니어, 운영 및 유지 관리 엔지니어, 테스트 엔지니어 등 눈부신 기술 직위에 대해 혼란스러웠습니다. , 제 전문 과정은 그저 그랬고 기술적 비전도 없었으며 어떤 기술적 방향을 추구해야 할지 명확한 아이디어도 없었습니다. 한 선배가 나에게 "운영 및 유지 관리를 하세요. 운영 및 유지 관리를 위해 매일 코드를 작성할 필요가 없습니다. Liunx를 사용할 수 있으면 됩니다! 개발을 하는 것보다 훨씬 쉽습니다!"라고 말하기 전까지는 말이죠. 믿다... 10년 넘게 업계에 있으면서 고생도 많이 했고, 비난도 많이 받았고, 서버도 죽였고, 부서 해고도 경험했다. 지금 누가 나에게 개발보다 운영과 유지가 쉽다고 말한다면. , 그럼 그럴게요

우리 중 많은 사람들이 Python 코드에서 다음 코드 조각을 반복해서 보았습니다: with open('Hi.text', 'w') as f: f.write("Hello, there") 그러나 우리 중 일부는 그렇지 않습니다. with가 무엇에 사용되는지, 왜 여기서 사용해야 하는지 모르겠습니다. 이 글을 읽으면 해결 가능한 거의 모든 문제에 대해 알게 될 것입니다. 시작하자! 먼저, with 키워드를 사용하지 않고 무엇을 해야 하는지 생각해 봅시다. 이 경우 먼저 파일을 열고 쓰기를 시도해야 합니다. 성공이든 실패든 우리는

Win10 시스템이 충돌하고 메모리 부족이 표시됩니다. 최근 많은 사용자가 컴퓨터를 사용할 때 이 메시지가 표시되어 수리를 위해 자주 다시 시작해야 합니다. 그렇다면 이 문제를 해결하려면 어떻게 해야 할까요? 더 많은 친구들이 문제를 해결할 수 있도록 돕기 위해 대다수의 사용자와 함께 작업 단계를 수행합니다. win10 시스템이 충돌하고 메모리 부족이 표시되는 경우 수행할 작업 1. 바탕 화면에서 이 컴퓨터를 마우스 오른쪽 버튼으로 클릭하고 옵션 목록에서 "속성"을 선택합니다. 2. 새 창 인터페이스에 들어간 후 왼쪽 상단에 있는 "고급 시스템 설정" 옵션을 클릭합니다. 3. 열리는 창에서 "

IT는 정보를 관리하고 처리하는 데 주로 사용되는 다양한 기술의 총칭입니다. IT는 오늘날 사회에서 없어서는 안될 부분으로, 우리가 생활하고 일하는 방식을 변화시킴으로써 많은 편리함과 기회를 제공합니다. 도청될 가능성이 있습니다. IT의 지속적인 발전과 함께 우리는 삶에 더 큰 변화를 가져올 더 많은 새로운 애플리케이션과 기술의 출현을 기대합니다.
