PHP로 단어 이력서 만들기

不言
풀어 주다: 2023-03-23 07:08:01
원래의
5395명이 탐색했습니다.

PHP에는 phpword라는 단어를 조작하기 위한 매우 사용하기 쉬운 휠이 있습니다. 이 휠은 github(PHPOffice/PHPWord)에서 찾을 수 있습니다. 위에는 더 자세한 예제와 코드가 있으며 내부 소스 코드에는 머리글, 바닥글, 페이지 번호, 글꼴 스타일, 표, 그림 삽입 등과 같은 일반적인 작업을 포함한 몇 가지 일반적인 작업 예제가 포함되어 있습니다. 휠을 사용하여 이력서를 작성하는 방법은 다음과 같습니다.

많은 채용 웹사이트에는 이력서 다운로드 기능이 있습니다. PHP를 사용하여 이를 구현하는 방법은 무엇입니까? PHPOffice/PHPWord에는 단어 문서를 생성하고 문서에 일부 텍스트를 삽입하는 매우 간단한 방법이 있습니다. 여기서 사용하는 방법은 다소 영리합니다. 이 휠에 대한 문서에는 템플릿 처리가 포함되어 있는데, 이는 laravel의 블레이드 템플릿과 동일한 개념인 템플릿 교체로 이해됩니다. 다음에는 너무 많은 이야기는 하지 않고, laravel 프레임워크를 사용한다는 점만 언급하고 싶습니다.

1. PHPOffice/PHPWord

composer require phpoffice/phpword
로그인 후 복사

2를 설치하고 테스트용 컨트롤러 DocController와 테스트 메소드를 생성하고 라우팅을 설정합니다.

php artisan make:controller DocController
로그인 후 복사

3. 단어 템플릿을 만듭니다. 여기서는 단어 문서의 ${value} 형식 문자열을 대체합니다.
PHP로 단어 이력서 만들기
그림에서 볼 수 있듯이 데이터베이스에서 검색할 수 있는 몇 가지 기본 정보가 있습니다. 그러나 이번에는 대체 방법을 직접 사용합니다. 직장 경험, 교육 경험 등 여러 줄의 테이블의 경우 템플릿으로 한 줄만 필요합니다.

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');
로그인 후 복사

이렇게 하면 단어 템플릿을 만들어 이력서를 생성할 수 있습니다.

관련 권장 사항:

PHP에서 원형 사용자 아바타를 만드는 방법

PHP에서 밀리초 타임스탬프를 만드는 방법

Thinkphp를 사용하여 웹 라이브 방송을 만드는 방법




위 내용은 PHP로 단어 이력서 만들기의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!