tsv2013 / open-document-generator
dev-main
2024-04-15 17:32 UTC
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2024-09-15 18:19:30 UTC
README
Open Document Generator 库
允许创建和存储 ODT 文件。支持
- 标题
- 段落
- 表格
- 目录表
- 样式:文本、段落、表格单元格、表格列
需求
- 在 php.ini 文件中启用 zip 库
extension=zip
示例用法
创建 ODT 文件的最小代码
$fileName = dirname(__FILE__) . "/document1.odt"; $docFile = new ODFile($fileName); $document = $docFile->document; $document->add_heading("Test heading"); $document->add_para("Lorem ipsum"); $docFile->create();
创建 ODS 文件的最小代码
$fileName = dirname(__FILE__) . "/document1.ods"; $docFile = new ODFile($fileName); $document = $docFile->document; $table = new ODTable([10, 7]); $document->add($table); $row = $table->create_row(); $row->add_cell_with_text("Column 1"); $row->add_cell_with_text("Column 2"); $row = $table->create_row(); $row->add_cell_with_text("val 1"); $row->add_cell_with_text("val 2"); $docFile->create();
另请参阅
https://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html
https://getcomposer.org.cn/doc/articles/scripts.md
https://php.ac.cn/manual/en/function.xml-parse.php
https://php.ac.cn/manual/en/function.xml-parse-into-struct.php