说明¶
PHPWord是一个用纯PHP编写的库,它提供了一组类 写入和读取不同的文档文件格式。 当前 PHPWord版本支持微软的 Office Open XML <http://en.wikipedia.org/wiki/Office_Open_XML>`__ (OOXML or OpenXML), OASIS的 Office开放文档格式 应用程序 (OpenDocument or ODF), and 富文本 格式 (RTF).
PHPWord is an open source project licensed under the terms of LGPL version 3. PHPWord is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPWord by reading this Developers’ Documentation and the API Documentation.
特性¶
设置文档属性,例如标题、主题和创建者。
创建具有不同设置的文档部分,例如
纵向/横向、页面大小和页码 - 为每个部分创建页眉和页脚 - 设置默认字体类型、字体大小和段落样式 - 使用UTF-8和东亚字体/字符 - 定义自定义字体样式 (例如粗体、斜体、颜色) 和段落 样式 (例如居中、多柱、间距) 作为命名样式 或内联文本 - 插入段落,以简单文本或复杂文本 (文本 运行),其中包含其他元素 - 插入标题 (标题) 和目录 - 插入文本符和分页符 - 从右到左插入文本 - 插入和格式化本地、远程或作为页面水印的图像 - 插入二进制OLE对象,如Excel或Visio -为每一行插入和格式化具有自定义属性的表 (例如,作为标题行重复) 和单元格 (例如,背景色, rowspan,colspan) - 插入列表项,如项目符号、编号或多级 - 插入超链接 - 插入脚注和尾注 - 插入绘图形状 (圆弧、曲线、线、折线、矩形、椭圆形) - 插入图表 (馅饼、甜甜圈、条、线、面积、散射、雷达) - 插入表单字段 (文本输入、复选框和下拉菜单) - 插入注释 - 从模板创建文档 - 使用shrna 1.0样式表转换OOXML模板的标题、主文档部分和页脚 -……还有更多进展中的功能
文件格式¶
以下是每种文件格式支持的功能。
写入¶
Features |
OOXML |
ODF |
RTF |
HTML |
||
---|---|---|---|---|---|---|
Document Properties |
Standard |
✓ |
✓ |
✓ |
✓ |
✓ |
Custom |
✓ |
✓ |
||||
Element Type |
Text |
✓ |
✓ |
✓ |
✓ |
✓ |
Text Run |
✓ |
✓ |
✓ |
✓ |
✓ |
|
Title |
✓ |
✓ |
✓ |
✓ |
||
Link |
✓ |
✓ |
✓ |
✓ |
✓ |
|
Preserve Text |
✓ |
|||||
Text Break |
✓ |
✓ |
✓ |
✓ |
✓ |
|
Page Break |
✓ |
✓ |
||||
List |
✓ |
|||||
Table |
✓ |
✓ |
✓ |
✓ |
✓ |
|
Image |
✓ |
✓ |
✓ |
✓ |
||
Object |
✓ |
|||||
Watermark |
✓ |
|||||
Table of Contents |
✓ |
|||||
Header |
✓ |
|||||
Footer |
✓ |
|||||
Footnote |
✓ |
✓ |
||||
Endnote |
✓ |
✓ |
||||
Comments |
✓ |
|||||
Graphs |
2D basic graphs |
✓ |
||||
2D advanced graphs |
||||||
3D graphs |
✓ |
|||||
Math |
OMML support |
|||||
MathML support |
||||||
Bonus |
Encryption |
|||||
Protection |
读取¶
Features |
OOXML |
DOC |
ODF |
RTF |
HTML |
|
---|---|---|---|---|---|---|
Document Properties |
Standard |
✓ |
||||
Custom |
✓ |
|||||
Element Type |
Text |
✓ |
✓ |
✓ |
✓ |
✓ |
Text Run |
✓ |
|||||
Title |
✓ |
✓ |
||||
Link |
✓ |
✓ |
||||
Preserve Text |
✓ |
|||||
Text Break |
✓ |
✓ |
||||
Page Break |
✓ |
|||||
List |
✓ |
✓ |
✓ |
|||
Table |
✓ |
✓ |
||||
Image |
✓ |
✓ |
||||
Object |
||||||
Watermark |
||||||
Table of Contents |
||||||
Header |
✓ |
|||||
Footer |
✓ |
|||||
Footnote |
✓ |
|||||
Endnote |
✓ |
|||||
Comments |
||||||
Graphs |
2D basic graphs |
|||||
2D advanced graphs |
||||||
3D graphs |
||||||
Math |
OMML support |
|||||
MathML support |
||||||
Bonus |
Encryption |
|||||
Protection |
贡献¶
我们欢迎大家为PHPWord做出贡献。以下是一些你可以做的贡献。
读 我们的贡献指南.
提交 提交bug或特性请求 到 GitHub。
关注 @PHPWord 和 @PHPOffice 在Twitter。