Overview

Namespaces

  • PHP
  • SimpleExcel
    • Enums
    • Parser
    • Spreadsheet
    • Writer

Classes

  • Cell
  • Workbook
  • Worksheet
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace SimpleExcel\Spreadsheet;
 4: 
 5: use SimpleExcel\Enums\SimpleExcelException;
 6: 
 7: /**
 8:  * SimpleExcel class for constructing workbook
 9:  *  
10:  * @author  Faisalman
11:  * @package SimpleExcel
12:  */ 
13: class Workbook
14: {
15:     /**
16:     * Array of worksheets
17:     * 
18:     * @access   protected
19:     * @var      array
20:     */
21:     protected $worksheets;
22:     
23:     public function __construct () {
24:         $this->worksheets = array();
25:     }
26:     
27:     /**
28:     * Get specified worksheet by index
29:     * 
30:     * @param    int     $index      Worksheet index
31:     * @return   Worksheet
32:     */
33:     public function getWorksheet ($index) {
34:         if (!isset($this->worksheets[$index - 1])) {
35:             throw new \Exception('Worksheet ' . $index . ' is not found', SimpleExcelException::WORKSHEET_NOT_FOUND);
36:         } else {
37:             return $this->worksheets[$index - 1];
38:         }
39:     }
40:     
41:     /**
42:     * Get all worksheets
43:     * 
44:     * @return   array
45:     */
46:     public function getWorksheets () {
47:         return $this->worksheets;
48:     }
49:     
50:     /**
51:     * Insert a new worksheet
52:     * 
53:     * @param    Worksheet   $worksheet  Worksheet to be inserted
54:     */
55:     public function insertWorksheet (Worksheet $worksheet) {
56:         array_push($this->worksheets, $worksheet);
57:     }
58: 
59:     /**
60:     * Remove a worksheet from workbook
61:     * 
62:     * @param    int     $index  Worksheet index to be removed
63:     */
64:     public function removeWorksheet ($index) {
65:         array_splice($this->worksheets, $index - 1, 1);
66:     }
67: }
68: 
API documentation generated by ApiGen 2.8.0