Make word resume with PHP
PHP has a very easy-to-use wheel for operating word, which is phpword. This wheel can be found on github (PHPOffice/PHPWord). There are more detailed examples and codes above, and the source code inside contains some common operation examples, including common operations such as setting headers, footers, page numbers, font styles, tables, inserting pictures, etc. Here's how to use the wheel to build a resume.
Many recruitment websites have a resume download function. How to implement it using PHP? In PHPOffice/PHPWord, there is a very simple way to generate a word document and insert some text into the document. The method I use here is rather clever. The documentation for this wheel includes template processing, which I understand to be template replacement, which is the same concept as laravel's blade template. I won’t talk too much next, let’s just talk about how to operate it. I’d like to mention that the laravel framework is used.
1. Install PHPOffice/PHPWord
composer require phpoffice/phpword
2. Create the controller DocController and test method for testing, and establish routing.
php artisan make:controller DocController
3. Create a word template. Let me explain here. The wheel replaces the string in the ${value} format in the word document. Here I simply build a template as shown in Figure 1 below:
You can see from the picture that there is some basic information, which can be used to retrieve data from the database. However, this time the replacement method is used directly. For multi-line tables such as work experience and education experience, only one line is needed as a template.
4. Specific code
//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');
This way you can generate a resume by creating a word template.
Related recommendations:
How to make a circular user avatar in PHP
How to make a millisecond timestamp in PHP
How to use Thinkphp to create a web live broadcast
##
The above is the detailed content of Make word resume with PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
