1. Contents
PHPExcel Developer Documentation ............................................................................. 1
1. Contents......................................................................................................... 2
2. Prerequisites.................................................................................................... 4
2.1. Software requirements ................................................................................. 4
2.2. Installation instructions ................................................................................ 4
2.3. Getting started .......................................................................................... 4
2.4. Useful links and tools ................................................................................... 4
2.4.1. OpenXML / SpreadsheetML....................................................................... 4
2.4.2. Frequently asked questions...................................................................... 5
2.4.3. Tutorials ............................................................................................ 5
3. Architecture .................................................................................................... 6
3.1. Schematical .............................................................................................. 6
3.2. Lazy Loader .............................................................................................. 6
3.3. Spreadsheet in memory ................................................................................ 6
3.4. Readers and writers..................................................................................... 6
3.5. Fluent interfaces ........................................................................................ 7
4. Creating a spreadsheet ....................................................................................... 9
4.1. The PHPExcel class...................................................................................... 9
4.2. Configuration Settings .................................................................................. 9
4.2.1. Cell Caching ........................................................................................ 9
4.2.2. Language/Locale .................................................................................11
4.3. Clearing a Workbook from memory..................................................................11
4.4. Worksheets ..............................................................................................11
4.5. Accessing cells ..........................................................................................11
4.5.1. Setting a cell value by coordinate .............................................................11
4.5.2. Retrieving a cell by coordinate ................................................................11
4.5.3. Setting a cell value by column and row.......................................................11
4.5.4. Retrieving a cell by column and row ..........................................................12
4.5.5. Looping cells ......................................................................................12
4.5.6. Using value binders to facilitate data entry .................................................13
4.6. PHPExcel recipes .......................................................................................14
4.6.1. Setting a spreadsheet’s metadata .............................................................14
4.6.2. Setting a spreadsheet’s active sheet..........................................................14
4.6.3. Write a date into a cell..........................................................................14
4.6.4. Write a formula into a cell......................................................................15
4.6.5. Locale Settings for Formulae ...................................................................15
4.6.6. Write a newline character "\n" in a cell (ALT+"Enter") .....................................16
4.6.7. Explicitly set a cell’s datatype .................................................................16
4.6.8. Change a cell into a clickable URL ............................................................17
4.6.9. Setting a worksheet’s page orientation and size............................................17
4.6.10. Page Setup: Scaling options ....................................................................17
4.6.11. Page margins ......................................................................................18
4.6.12. Center a page horizontally/vertically.........................................................18
4.6.13. Setting the print header and footer of a worksheet........................................19
4.6.14. Setting printing breaks on a row or column..................................................20
4.6.15. Show/hide gridlines when printing ............................................................20
4.6.16. Setting rows/columns to repeat at top/left .................................................20
4.6.17. Specify printing area.............................................................................20
4.6.18. Formatting cells ..................................................................................21
4.6.19. Number formats ..................................................................................22
4.6.20. Alignment and wrap text........................................................................23
4.6.21. Setting the default style of a workbook ......................................................23
4.6.22. Styling cell borders...............................................................................23
4.6.23. Conditional formatting a cell...................................................................24
4.6.24. Add a comment to a cell ........................................................................25
4.6.25. Apply autofilter to a range of cells............................................................25
4.6.26. Setting security on a spreadsheet .............................................................25
PHPExcel Developer Documentation
2