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