国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

PHP制作word簡歷

2020-03-22 18:53:43
字體:
來源:轉載
供稿:網友
PHP操作word有一個非常好用的輪子,就是phpword,該輪子可以在github上查找到(PHPOffice/PHPWord)。上面有較為詳細的例子和代碼,其中里面的源碼包含有一些常用的操作例子,包括設置頁眉、頁腳、頁碼、字體樣式、表格、插入圖片等常用的操作。這里介紹的是如何使用該輪子來制作一個簡歷。

在許多招聘網站都有一個簡歷下載的功能,如何用php實現呢?在PHPOffice/PHPWord里面就有一個非常簡單的生成一個word文檔,向文檔中插入一些文字。這里我使用的方式比較取巧,這個輪子的說明文檔中有template processing,我理解為模板替換,也就是跟laravel的blade模板一個概念。接下來就不多廢話,直接說如何操作,這里提一句使用的是laravel框架

1.安裝PHPOffice/PHPWord

composer require phphtml' target='_blank'>office/phpword

2.創建控制器DocController及test方法用于測試,并建立路由。

php artisan make:controller DocController

3.建立word模板,這里說明一下,該輪子替換的是word文檔中格式為${value}格式的字符串,這里我簡易的搭建一個模板如下圖1所示:

從圖中可以看到有一些基本的信息,這些可以從數據庫中撈取數據。不過這次是直接使用替換的方式,像工作經歷和教育經歷這種多行表格的模式這里也只需要取一行作為模板即可。

4.具體代碼

//load template docx        $templateProcessor = new TemplateProcessor('./sample.docx');        //基礎信息填寫替換        $templateProcessor->setValue('update_at', date('Y-m-d H:i:s'));        $templateProcessor->setValue('number', '123456');        $templateProcessor->setValue('Name', '張三');        $templateProcessor->setValue('sex', '男');        $templateProcessor->setValue('birth', '1996年10月');        $templateProcessor->setValue('age', '22');        $templateProcessor->setValue('shortcut', '待業/aaa');        $templateProcessor->setValue('liveArea', '福建省莆田市涵江區');        $templateProcessor->setValue('domicile', '福建省莆田市涵江區');        $templateProcessor->setValue('address', '');        $templateProcessor->setValue('hopetodo', 'IT');        $templateProcessor->setValue('hopeworkin', '互聯網');        $templateProcessor->setValue('hopes', '7000+');        $templateProcessor->setValue('worklocation', '福建省莆田市');        $templateProcessor->setValue('phone', '123456789');        $templateProcessor->setValue('mail', '456789@qq.com');        $templateProcessor->setValue('qqnum', '456789');        $templateProcessor->setValue('selfjudge', '哇哈哈哈哈哈哈哈');        //工作經歷表格替換        $templateProcessor->cloneRow('experience_time', 2);//該表通過克隆行的方式,形成兩行        $templateProcessor->setValue('experience_time#1', '2010-09~2014-06');//每行參數是用value#X(X表示行號,從1開始)        $templateProcessor->setValue('job#1', 'ABC company CTO');        $templateProcessor->setValue('experience_time#2', '2014-09~至今');        $templateProcessor->setValue('job#2', 'JBC company CTO');        //教育經歷        $templateProcessor->cloneRow('time', 2);        $templateProcessor->setValue('time#1', '2010-09~2014-06');        $templateProcessor->setValue('school#1', 'ABC');        $templateProcessor->setValue('major#1', 'Computer science');        $templateProcessor->setValue('time#2', '2014-09~至今');        $templateProcessor->setValue('school#2', 'JBC');        $templateProcessor->setValue('major#2', 'Computer science');        //語言能力        $templateProcessor->cloneRow('lang',2);        $templateProcessor->setValue('lang#1', '漢語|精通');        $templateProcessor->setValue('lang#2', '英語|精通');        //技能        $templateProcessor->cloneRow('skill',3);        $templateProcessor->setValue('skill#1', 'JAVA|精通');        $templateProcessor->setValue('skill#2', 'Python|精通');        $templateProcessor->setValue('skill#3', 'PHP|精通');        // Saving the document        $templateProcessor->saveAs('my.docx');

這樣就可以通過建立word模板的方式產生一個簡歷了。

相關推薦:

php制作圓形用戶頭像方法

PHP制作毫秒時間戳的方法

如何使用Thinkphp制作網頁直播



以上就是PHP制作word簡歷 的詳細內容,更多請關注 其它相關文章!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 景德镇市| 怀柔区| 阳春市| 万源市| 鸡东县| 密山市| 霞浦县| 万年县| 汉沽区| 镇远县| 平湖市| 焦作市| 闻喜县| 漯河市| 扶风县| 加查县| 都匀市| 修水县| 句容市| 大同县| 泌阳县| 印江| 通许县| 慈利县| 唐山市| 顺昌县| 延寿县| 孟州市| 龙海市| 平舆县| 绥化市| 塔河县| 曲麻莱县| 池州市| 辽宁省| 犍为县| 伊通| 耒阳市| 青河县| 康马县| 喜德县|