Mark Baker     @Mark_BakerTechnical Team Lead at Inviqa  (formerly Ibuildings UK)Coordinator of Open Source libraries:    ...
PHPOffice                https://github.com/PHPOffice/Set of PHP Libraries for creating, reading and writingdocuments in s...
PHP Spreadsheet EngineMajor Features       Document Metadata (author, date created, etc.)       Cell and content Styles/...
require_once ../Classes/PHPExcel.php;$objReader = PHPExcel_IOFactory::createReader(Excel5);$objPHPExcel = $objReader->load...
File Formats                                                                                  Reading   WritingBIFF (BIFF5...
PHP Word Processing EngineMajor Features       Insert and format document sections       Insert and format Text elements...
File Formats                                                                        Reading   WritingOfficeOpenXMLMS Word ...
require_once ../src/PHPWord.php;// New Word Document$PHPWord = new PHPWord();// New portrait section$section = $PHPWord->c...
PHP Presentation LibraryMajor Features       Presentation meta data (author, title, description, ...)       Add slides t...
File Formats                                                                            Reading   WritingOfficeOpenXMLMS P...
include PHPPowerPoint.php;// Create new PHPPowerPoint object$objPHPPowerPoint = new PHPPowerPoint();// Set properties$objP...
PHPProjectPlanned File Formats                               Reading   WritingGantt ProjectMS Project Exchange
PHPVisioPlanned File Formats                        Reading   WritingMS VisioDiaGraphViz
PHPOfficeContributions Welcome    Code Writing          Bug fixes          Patches          Extensions          New F...
PHPOfficehttps://github.com/PHPOffice/
Upcoming SlideShare
Loading in …5
×

What is PHPOffice?

5,643 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,643
On SlideShare
0
From Embeds
0
Number of Embeds
1,039
Actions
Shares
0
Downloads
28
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

What is PHPOffice?

  1. 1. Mark Baker @Mark_BakerTechnical Team Lead at Inviqa (formerly Ibuildings UK)Coordinator of Open Source libraries: PHPExcel, PHPWord, PHPPowerPoint, PHPVisio, PHPProject
  2. 2. PHPOffice https://github.com/PHPOffice/Set of PHP Libraries for creating, reading and writingdocuments in standard office suite file formats PHPExcel PHPWord PHPPowerPoint PHPProject PHPVisioLicensed under LGPL (GNU LESSER GENERAL PUBLIC LICENSE)
  3. 3. PHP Spreadsheet EngineMajor Features  Document Metadata (author, date created, etc.)  Cell and content Styles/Formatting  Rich Text in cells  Conditional Formatting  Merged Cells  Hyperlinks  AutoFilter Ranges  Print Options  Freeze Panes  Embedded Images  Charts  Built-in Calculation engine for evaluating Excel formulae
  4. 4. require_once ../Classes/PHPExcel.php;$objReader = PHPExcel_IOFactory::createReader(Excel5);$objPHPExcel = $objReader->load("templates/invoiceTemplate.xls");$data = array(array(title => Excel for dummies, price => 17.99, quantity => 2 ), array(title => PHP for dummies, price => 15.99, quantity => 1 ), array(title => Inside OOP, price => 12.95, quantity => 1 ) );$objPHPExcel->getActiveSheet()->setCellValue(D1, PHPExcel_Shared_Date::PHPToExcel(time()));$baseRow = 5;foreach($data as $r => $dataRow) { $row = $baseRow + $r; $objPHPExcel->getActiveSheet()->insertNewRowBefore($row,1); $objPHPExcel->getActiveSheet()->setCellValue(A.$row, $r+1) ->setCellValue(B.$row, $dataRow[title]) ->setCellValue(C.$row, $dataRow[price]) ->setCellValue(D.$row, $dataRow[quantity]) ->setCellValue(E.$row, =C.$row.*D.$row);}$objPHPExcel->getActiveSheet()->removeRow($baseRow-1,1);$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, Excel5);$objWriter->save(str_replace(.php, .xls, __FILE__));
  5. 5. File Formats Reading WritingBIFF (BIFF5 - BIFF 8)MS Excel 95 and above (.xls .xlt)  OfficeOpenXMLMS Excel 2007 and above (Excel 2003 with Compatibility Pack) (.xlsx .xlsm .xltx  .xltm)SpreadsheetMLMS Excel 2003 and above (.xml) OASIS / Open Document FormatOpen/Libre Office Calc (.ods .ots) Gnumeric (.gnumeric) SYLKMS Multiplan Symbolic Link (.slk) HTML  CSV  PDF 
  6. 6. PHP Word Processing EngineMajor 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  Insert Header / Footer  Insert and format Tables  Insert native Titles and Table-of-contents  Insert and format List elements  Insert and format hyperlinks  Template system
  7. 7. File Formats Reading WritingOfficeOpenXMLMS Word 2007 and above (MS Word 2003 with Compatibility Pack) (.docx) OASIS / Open Document FormatOpen/Libre Office Writer (.odt) Rich-Text Format.rtf 
  8. 8. require_once ../src/PHPWord.php;// New Word Document$PHPWord = new PHPWord();// New portrait section$section = $PHPWord->createSection();// Add text elements$section->addText(Hello World!);$section->addTextBreak(2);$section->addText(I am inline styled., array(name=>Verdana, color=>006699));$section->addTextBreak(2);$PHPWord->addFontStyle(rStyle, array(bold=>true, italic=>true, size=>16));$PHPWord->addParagraphStyle(pStyle, array(align=>center, spaceAfter=>100));$section->addText(I am styled by two style definitions., rStyle, pStyle);$section->addText(I have only a paragraph style definition., null, pStyle);// Save File$objWriter = PHPWord_IOFactory::createWriter($PHPWord, Word2007);$objWriter->save(str_replace(.php, .docx, __FILE__));
  9. 9. PHP Presentation LibraryMajor Features  Presentation meta data (author, title, description, ...)  Add slides to presentation  Supports different fonts and font styles  Supports formatting, styles, fills, gradients, ...  Supports hyperlinks  Supports rich-text strings  Add images to your presentation  Set image styles  Set printing options
  10. 10. File Formats Reading WritingOfficeOpenXMLMS PowerPoint 2007 and above (MS PowerPoint 2003 with Compatibility Pack) (.pptx)OASIS / Open Document FormatOpen/Libre Office Impress (.odp) 
  11. 11. include PHPPowerPoint.php;// Create new PHPPowerPoint object$objPHPPowerPoint = new PHPPowerPoint();// Set properties$objPHPPowerPoint->getProperties()->setCreator(Mark Baker) ->setTitle(Office 2007 PPTX Test Document) ->setSubject(Office 2007 PPTX Test Document);// Create slide$currentSlide = $objPHPPowerPoint->getActiveSlide();// Create a shape (drawing)$shape = $currentSlide->createDrawingShape();$shape->setName(PHPPowerPoint logo) ->setDescription(PHPPowerPoint logo) ->setPath(./images/phppowerpoint_logo.gif) ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10);// Create a shape (text)$shape = $currentSlide->createRichTextShape() ->setHeight(300) ->setWidth(600) ->setOffsetX(170) ->setOffsetY(180);$shape->getActiveParagraph()->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );$textRun = $shape->createTextRun(Thank you for using PHPPowerPoint!);$textRun->getFont()->setBold(true) ->setSize(60) ->setColor( new PHPPowerPoint_Style_Color( FFC00000 ) );// Save PowerPoint 2007 file$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, PowerPoint2007);$objWriter->save(str_replace(.php, .pptx, __FILE__));
  12. 12. PHPProjectPlanned File Formats Reading WritingGantt ProjectMS Project Exchange
  13. 13. PHPVisioPlanned File Formats Reading WritingMS VisioDiaGraphViz
  14. 14. PHPOfficeContributions Welcome  Code Writing  Bug fixes  Patches  Extensions  New Features  New Readers  New Writers  Testing  Unit Tests  Testing against Office Suite programs  Documentation  API Document Blocks  Library Documents  Tutorials  Blog Posts  General  Answer questions on forums and message boards
  15. 15. PHPOfficehttps://github.com/PHPOffice/

×