亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > PHP > 正文

PHP讀取PPT文件的方法

2024-05-04 23:40:53
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了PHP讀取PPT文件的方法,通過php第三方類庫PHPPowerPoint實現對ppt文件的讀取操作,需要的朋友可以參考下
 

本文實例講述了PHP讀取PPT文件的方法。分享給大家供大家參考,具體如下:

最近做一個和FLASH有關的東西,其中就要用到在網站上看PPT就像百度,豆丁網那樣可以直接在網站上讀,在網上搜了半天沒搜到,都是些什么安裝個軟件什么的,PHP網站放到空間上,誰能讓你在哪裝軟件呢?不是在瞎扯么?不過還好,最后在國外一個網站上搜到了一個解決思路,就是一個PHP操作PPT的類,當然這個網站還提供了操作OFFICES軟件的其他類,不過是2007版的OFFICES,現把網址貼出來奉獻給大家:http://phppowerpoint.codeplex.com/。也可點擊此處本站下載。

這個類可以實現 PPT2007格式的讀寫/生成

下面也貼出當時看到的一個例子:

本例子使用phppowerpoint類,使用該類注意兩點,一個是了解參數含義,二注意字符集

<?phpheader("content-type:text/html;charset=utf-8");//字體設置防止亂碼error_reporting(E_ALL);/** Include path **/set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');/** PHPPowerPoint */include 'PHPPowerPoint.php';/** PHPPowerPoint_IOFactory */include 'PHPPowerPoint/IOFactory.php';// Create new PHPPowerPoint object//echo date('H:i:s') . " Create new PHPPowerPoint object/n";$objPHPPowerPoint = new PHPPowerPoint();$objPHPPowerPoint->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 slideecho 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 slideecho 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 slideecho 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 slideecho 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;$i<4;$i++){$currentSlide = createTemplatedSlide1($objPHPPowerPoint,$row["titlepic"][$i]); // 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(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 slidereturn $slide;}

我的問題仍然還在研究中,如果大家有更好的解決方法,請繼續貼,期待更多好的分享

希望本文所述對大家PHP程序設計有所幫助。



注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
乱亲女秽乱长久久久| 亚洲成人在线网| 日韩视频免费在线观看| 在线亚洲欧美视频| 日韩av手机在线看| 欧美日韩国产区| 亚洲欧美日韩成人| 国产激情视频一区| 亚洲图中文字幕| 久久久久女教师免费一区| 欧美精品一区二区三区国产精品| 亚洲天堂2020| 亚洲一区二区免费| 精品一区二区三区四区在线| 在线看欧美日韩| 91免费欧美精品| 亚洲色图五月天| 中文字幕亚洲欧美| 国产999精品久久久影片官网| 亚洲精品999| 欧美激情2020午夜免费观看| 久久人91精品久久久久久不卡| 精品亚洲一区二区| 久久91亚洲精品中文字幕| 欧美精品videofree1080p| 色噜噜狠狠色综合网图区| www.日韩不卡电影av| 亚洲欧美一区二区三区情侣bbw| 国语自产精品视频在线看一大j8| 久久久久久久一区二区| 69av在线播放| 97视频免费观看| 国产精品日韩久久久久| 日韩视频免费中文字幕| 日韩美女福利视频| 91在线视频成人| 国产日韩av在线| 日韩成人在线免费观看| 国产午夜精品美女视频明星a级| 91免费视频网站| 国产日韩欧美日韩| 久久久噜噜噜久久久| 日韩亚洲成人av在线| 热久久免费视频精品| 懂色av中文一区二区三区天美| 成人观看高清在线观看免费| 国产视频亚洲精品| 97视频在线播放| 久久6精品影院| 亚洲精品久久久久久久久| 欧美一级大片视频| 色噜噜国产精品视频一区二区| 亚洲精品动漫100p| 92裸体在线视频网站| 国产精品久久视频| 国产精品视频中文字幕91| 日韩av资源在线播放| 精品动漫一区二区| 国产亚洲一区精品| 18性欧美xxxⅹ性满足| 国产精品高精视频免费| 日日骚av一区| 国产一区二区日韩| 国产精品九九九| 日韩中文在线中文网三级| 4444欧美成人kkkk| 亚洲欧美日本精品| 日本久久久久久久久久久| 国产精品国产自产拍高清av水多| 成人黄色av免费在线观看| 日韩欧美a级成人黄色| 久久亚洲精品中文字幕冲田杏梨| 国产精品999| 狠狠色狠狠色综合日日五| 欧美中文字幕精品| 成人福利网站在线观看| 国产精品jvid在线观看蜜臀| 91深夜福利视频| 国产精品爱啪在线线免费观看| 国产精品久久久av久久久| 国产视频亚洲视频| 精品国产一区二区三区久久久狼| 热久久这里只有| 亚洲男人天堂久| 亚洲综合在线中文字幕| 亚洲人成绝费网站色www| 日韩a**站在线观看| 久久久精品影院| 国产精品夜间视频香蕉| 久久精品最新地址| 国产乱人伦真实精品视频| 欧美裸体男粗大视频在线观看| 国产欧美 在线欧美| 久久99久久99精品中文字幕| 91久久久国产精品| 久久成人一区二区| 懂色av一区二区三区| 成人黄色免费在线观看| 国产a∨精品一区二区三区不卡| 精品欧美国产一区二区三区| 亚洲欧洲在线免费| 超碰精品一区二区三区乱码| 国产精品免费一区二区三区都可以| 成人黄色av网| 久久久精品国产亚洲| 91在线免费看网站| 亚洲精品自拍偷拍| 欧美有码在线观看| 亚洲国产精品人久久电影| 久久亚洲影音av资源网| 亚洲精品欧美一区二区三区| 综合网日日天干夜夜久久| 国产成人一区二区在线| 欧美激情第6页| 精品久久久999| 国产精品麻豆va在线播放| 91久久国产精品91久久性色| 日本欧美国产在线| 欧美极品少妇xxxxⅹ裸体艺术| 亚洲成人av资源网| 国产精品96久久久久久又黄又硬| 亚洲国产精品女人久久久| 在线播放国产精品| 色yeye香蕉凹凸一区二区av| 国产国语刺激对白av不卡| 亚洲男人第一av网站| 国内精品国产三级国产在线专| 亚洲网站视频福利| 亚洲高清在线观看| 国产精品一区二区在线| 欧美日韩高清区| 欧美一级淫片aaaaaaa视频| 日韩大胆人体377p| 中文字幕一区日韩电影| 一区二区三区天堂av| 日韩av在线直播| 国产91精品最新在线播放| 亚洲无亚洲人成网站77777| 91社区国产高清| 92看片淫黄大片看国产片| 欧美黑人视频一区| xxav国产精品美女主播| 日韩有码片在线观看| 日本高清不卡在线| 亚洲电影免费观看高清完整版在线观看| 日本欧美爱爱爱| 在线电影中文日韩| 久久资源免费视频| 精品人伦一区二区三区蜜桃网站| 亚洲新声在线观看| 人人做人人澡人人爽欧美| 91精品国产99久久久久久| 日本国产一区二区三区| 国产精品成人aaaaa网站| 成人福利网站在线观看| 97在线视频免费播放| 欧美在线视频一区| 欧美日韩国产精品一区二区三区四区| 精品国偷自产在线视频99| 成人在线激情视频| 国产日韩精品在线| 国产亚洲激情视频在线| www.欧美精品| 26uuu亚洲伊人春色|