이 기사의 예에서는 PHP로 PPT 파일을 읽는 방법을 설명합니다. 참고로 내용을 공유해드리고자 합니다.
최근 FLASH에 관련된 내용을 작성했는데, 바이두나 Docin처럼 홈페이지에서 PPT를 보시면서 보실 수 있습니다. 오랫동안 온라인으로 검색한 결과 소프트웨어 설치에 대한 내용을 찾을 수 없었습니다. PHP 웹사이트가 공간에 배치되어 있으면 소프트웨어를 어디에 설치할 수 있는지 알려줄 수 있습니까? 말도 안 되는 소리 하는 거 아냐? 다행히 외국 웹사이트에서 드디어 해결책을 찾았습니다. PPT 운영을 위한 PHP 클래스입니다. 물론 이 웹사이트에서도 OFFICES 소프트웨어 운영을 위한 다른 클래스도 제공하고 있지만, 지금은 OFFICES 2007 버전의 URL을 올려드리겠습니다. 모든 사람에게 바칩니다: http://phppowerpoint.codeplex.com/. 여기를 클릭하여 이 사이트에서 다운로드할 수도 있습니다.
이 클래스는 PPT2007 형식의 읽기, 쓰기/생성을 구현할 수 있습니다.
제가 본 예제도 아래에 게시되어 있습니다.
이 예제에서는 phppowerpoint 클래스를 사용합니다. 주의하세요. 이 클래스를 사용할 때 두 가지 점은 매개 변수의 의미를 이해하는 것과 문자 집합에 주의하는 것입니다
getProperties()->setCreator("Maarten Balliauw"); $objPHPPowerPoint->getProperties()->setLastModifiedBy("Maarten Balliauw"); $objPHPPowerPoint->getProperties()->setTitle("Office 2007 PPTX Test Document"); $objPHPPowerPoint->getProperties()->setSubject("Office 2007 PPTX Test Document"); $objPHPPowerPoint->getProperties()->setDescription("Test document for Office 2007 PPTX, generated using PHP classes."); $objPHPPowerPoint->getProperties()->setKeywords("office 2007 openxml php"); $objPHPPowerPoint->getProperties()->setCategory("Test result file"); // Remove first slide //echo date('H:i:s') . " Remove first slide\n"; $objPHPPowerPoint->removeSlideByIndex(0); // Create templated slide //echo date('H:i:s') . " Create templated slide\n"; /*$currentSlide = createTemplatedSlide($objPHPPowerPoint); // local function // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(200); $shape->setWidth(600); $shape->setOffsetX(10); $shape->setOffsetY(400); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('Introduction to'); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('PHPPowerPoint'); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(60); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create templated slide echo date('H:i:s') . " Create templated slide\n"; $currentSlide = createTemplatedSlide($objPHPPowerPoint); // local function // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(100); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(10); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('What is PHPPowerPoint?'); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(48); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(600); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(100); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('- A class library'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('- Written in PHP'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('- Representing a presentation'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('- Supports writing to different file formats'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create templated slide echo date('H:i:s') . " Create templated slide\n"; $currentSlide = createTemplatedSlide($objPHPPowerPoint); // local function // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(100); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(10); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('What\'s the point?'); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(48); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(600); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(100); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('- Generate slide decks'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - Represent business data'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - Show a family slide show'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - ...'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('- Export these to different formats'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - PowerPoint 2007'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - Serialized'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' - ... (more to come) ...'); $textRun->getFont()->setSize(28); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create templated slide echo date('H:i:s') . " Create templated slide\n"; $currentSlide = createTemplatedSlide($objPHPPowerPoint); // local function // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(100); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(10); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('Need more info?'); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(48); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create a shape (text) echo date('H:i:s') . " Create a shape (rich text)\n"; $shape = $currentSlide->createRichTextShape(); $shape->setHeight(600); $shape->setWidth(930); $shape->setOffsetX(10); $shape->setOffsetY(100); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $textRun = $shape->createTextRun('Check the project site on CodePlex:'); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); $shape->createBreak(); $textRun = $shape->createTextRun(' ); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( 'FFFFFFFF' ) ); // Create templated slide echo date('H:i:s') . " Create templated slide\n";*/ //test //从数据库调取数据进行for循环 $row=array('titlepic'=>array('./images/love.gif','./images/love1.gif','./images/love2.gif','./images/love3.gif'),'xsprice'=>array("55","33","22","333"),'cjid'=>array('100','222','333','3333'),'lpid'=>array('111','222','333','444'),'price'=>array('111','433','243','3245')); for($i=0;$icreateRichTextShape(); $shape->setHeight(100); $shape->setWidth(930); //调整字体的高度宽度 $shape->setOffsetX(20); $shape->setOffsetY(400); //$shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); $row["price"]=iconv("utf-8","gb2312",$row["price"][$i]); $textRun = $shape->createTextRun('礼品网价格:'.$row["xsprice"][$i]); $textRun->getFont()->setBold(true); $textRun->getFont()->setSize(48); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '#000000' ) ); $shape = $currentSlide->createRichTextShape(); $shape->setHeight(600); $shape->setWidth(930); $shape->setOffsetX(20); $shape->setOffsetY(500); $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT ); //添加多行内容从这开始 $textRun = $shape->createTextRun('公司编号: '.$row["cjid"][$i]); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '#000000' ) ); $shape->createBreak(); $textRun = $shape->createTextRun('礼品网编号: '.$row["lpid"][$i]); $textRun->getFont()->setSize(36); $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '#000000' ) ); //test // Save PowerPoint 2007 file } //echo date('H:i:s') . " Write to PowerPoint2007 format\n"; $objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007'); $objWriter->save(str_replace('.php', '.pptx',__FILE__)); header("Content-type:application/vnd.ms-powerpoint;"); header("location:02presentation.pptx"); // Echo memory peak usage //echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done //echo date('H:i:s') . " Done writing file.\r\n"; /** * Creates a templated slide * * @param PHPPowerPoint $objPHPPowerPoint * @return PHPPowerPoint_Slide */ function createTemplatedSlide1(PHPPowerPoint $objPHPPowerPoint,$cs1) { // Create slide $slide = $objPHPPowerPoint->createSlide(); // Add background image $shape = $slide->createDrawingShape(); $shape->setName('Background'); $shape->setDescription('Background'); $shape->setPath('./images/realdolmen_bg.jpg'); $shape->setWidth(950); $shape->setHeight(720); $shape->setOffsetX(0); $shape->setOffsetY(0); // Add logo $shape = $slide->createDrawingShape(); $shape->setName('PHPPowerPoint logo'); $shape->setDescription('PHPPowerPoint logo'); $shape->setPath($cs1); $shape->setHeight(120); $shape->setOffsetX(10); $shape->setOffsetY(10); // Return slide return $slide; }
제 문제는 아직 연구 중입니다. 더 나은 해결책이 있다면 계속해서 게시해 주시기 바랍니다. 앞으로도 좋은 공유를 기대합니다
이 글이 PHP 프로그래밍에 종사하는 모든 분들께 도움이 되기를 바랍니다.
위 내용은 관련 내용을 포함하여 PHP에서 PPT 파일을 읽는 방법을 소개한 내용입니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되었으면 좋겠습니다.

TomakePhPapplicationSfaster, followthesesteps : 1) useopCodeCaching likeOpcachetOrpectipiledScriptBecode.2) MinimizedAtabaseQueriesByUsingQueryCachingandEfficientIndexing.3) leveragephp7 assistorBetterCodeeficiession.4) 구현 전략적 지시

toImprovePhPapplicationSpeed, followthesesteps : 1) enableOpCodeCachingWithApcuTeCeScripteXecutionTime.2) 구현 구현

의존성 주입 (DI)은 명시 적으로 전이적 종속성에 의해 PHP 코드의 테스트 가능성을 크게 향상시킵니다. 1) DI 디퍼 커플 링 클래스 및 특정 구현은 테스트 및 유지 보수를보다 유연하게 만듭니다. 2) 세 가지 유형 중에서, 생성자는 상태를 일관성있게 유지하기 위해 명시 적 표현 의존성을 주입합니다. 3) DI 컨테이너를 사용하여 복잡한 종속성을 관리하여 코드 품질 및 개발 효율성을 향상시킵니다.

DatabaseQuesyOptimizationInphPinVolvesVesstoigiestoInsperferferferferformance.1) SelectOnlyNecessaryColumnstoredAtatatransfer.2) useinDexingTeSpeedUpdatarretieval.3) ubstractOrerEresultSoffRequeries.4) UtilizePreDstatements Offeffi

phpisusedforendingemailsduetoitsbuitsbuitsbuit-inmail () functionandsupportivelibraries lifephpmailerandswiftmailer.1) usethemail () functionforbasicemails, butithaslimitations.2) EmployPhpmailerforAdvancedFeatirehtMailsAndAtachments.3))

PHP 성능 병목 현상은 다음 단계를 통해 해결할 수 있습니다. 1) 성능 분석을 위해 Xdebug 또는 Blackfire를 사용하여 문제를 찾으십시오. 2) 데이터베이스 쿼리 최적화 및 APCU와 같은 캐시 사용; 3) Array_Filter와 같은 효율적인 기능을 사용하여 배열 작업을 최적화합니다. 4) 바이트 코드 캐시에 대한 OpCache 구성; 5) HTTP 요청을 줄이고 사진 최적화와 같은 프론트 엔드 최적화; 6) 지속적으로 모니터링하고 성능을 최적화합니다. 이러한 방법을 통해 PHP 응용 프로그램의 성능을 크게 향상시킬 수 있습니다.

종속성 주사 (di) inphpisadesignpattern thatmanages 및 enpleducesclassdelencies, 향상 codemodularity, trestability 및 maintainability .itallowspassingDepporsingDikedAbaseConnectionStoclassesAssparameters, 촉진 이용성.

cachingimprovesphpperferferfermanceStoringResultsOfcomputationSorqueriesforquickRetrieval, retingServerloadandenhancancing responsetimestimes : 1) opcodecaching, opcodecaching, whitescompiledphps scriptsinmorytoskipcompileation; 2) dataCachingUsingmemmc


핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

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

인기 기사

뜨거운 도구

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

Dreamweaver Mac版
시각적 웹 개발 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

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

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!