PHP操作Word的组件PHPWord有两个版本


关键词

PHP Word PHPWord

摘要

PHP很简单、便捷的操作Word文档,这要归功于第三方的组件:PHPWord。其实在网上搜索会发现PHPWord有两个版本,一个版本叫PHPWord,另一个叫PhpWord。

从名字上看,细心的朋友可能已经发现其中的区别了,对的,就是有两字母大小写不同。我们一个一个来说:

PHPWord
官网:http://phpword.codeplex.com/
功能介绍:
PHPWord is a library written in PHP that create word documents. 
No Windows operating system is needed for usage because the result are docx files (Office Open XML) that can be opened by all major office software.

PHPWord is based on the fantastic PHPExcel / PHPPowerPoint libraries.
Major Features

Insert and format document sections
Insert and format Text elements
Insert Text breaks
Insert Page breaks
Insert and format Images and binary OLE-Objects
Insert and format watermarks (new)
Insert Header / Footer
Insert and format Tables
Insert native Titles and Table-of-contents
Insert and format List elements
Insert and format hyperlinks
Very simple template system (new)

PHPWord在用于操作中文时,要注意编码问题。需要对它做一些修改。


PhpWord
官网:https://github.com/PHPOffice/PHPWord
功能介绍:
With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP 5.3.3+ scripts. Below are some of the things that you can do with PHPWord library:

Set document properties, e.g. title, subject, and creator.
Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
Create header and footer for each sections
Set default font type, font size, and paragraph style
Use UTF-8 and East Asia fonts/characters
Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text
Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements
Insert titles (headers) and table of contents
Insert text breaks and page breaks
Insert and format images, either local, remote, or as page watermarks
Insert binary OLE Objects such as Excel or Visio
Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan)
Insert list items as bulleted, numbered, or multilevel
Insert hyperlinks
Insert footnotes and endnotes
Insert drawing shapes (arc, curve, line, polyline, rect, oval)
Insert charts (pie, doughnut, bar, line, area, scatter, radar)
Insert form fields (textinput, checkbox, and dropdown)
Create document from templates
Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
... and many more features on progress

从使用上说,PHPWord感觉要比PhpWord方便一些,但功能貌似后者更强大。

 

要饭二维码

洪哥写文章很苦逼,如果本文对您略有帮助,可以扫描下方二维码支持洪哥!金额随意,先行谢过!大家的支持是我前进的动力!

文章的版权

本文属于“洪哥笔记”原创文章,转载请注明来源地址:PHP操作Word的组件PHPWord有两个版本:http://www.splaybow.com/post/phpword-2-version-6890.html

如果您在服务器运维、网络管理、网站或系统开发过程有需要提供收费服务,请加QQ:8771947!十年运维经验,帮您省钱、让您放心!
亲,如果有需要,先存起来,方便以后再看啊!加入收藏夹的话,按Ctrl+D

« PHP中获取圆周率的值的函数pi() PHPWord操作中文乱码的修改办法 »