Mark V
1: <?php
2: namespace MOC\V\Component\Document\Component\Bridge\Repository;
3:
4: use MOC\V\Component\Document\Component\Bridge\Repository\PhpExcel\Cell;
5: use MOC\V\Component\Document\Component\Bridge\Repository\PhpExcel\File;
6: use MOC\V\Component\Document\Component\Bridge\Repository\PhpExcel\Style;
7:
8: /**
9: * Class PhpExcel
10: *
11: * @package MOC\V\Component\Document\Component\Bridge\Repository
12: */
13: class PhpExcel extends File
14: {
15:
16: /**
17: *
18: */
19: public function __construct()
20: {
21:
22: require_once( __DIR__.'/../../../Vendor/PhpExcel/1.8.0/Classes/PHPExcel.php' );
23: }
24:
25: /**
26: * @param string|int $Column Name or Index
27: * @param null|int $Row Index
28: *
29: * @return Cell
30: */
31: public function getCell($Column, $Row = null)
32: {
33:
34: if (preg_match('![a-z]!is', $Column)) {
35: $Coordinate = \PHPExcel_Cell::coordinateFromString($Column);
36: $Column = \PHPExcel_Cell::columnIndexFromString($Coordinate[0]) - 1;
37: $Row = $Coordinate[1];
38: } else {
39: $Row += 1;
40: }
41: return new Cell($Column, $Row);
42: }
43:
44: /**
45: * @param Cell $Cell
46: * @param mixed $Value
47: *
48: * @return $this
49: */
50: public function setValue(Cell $Cell, $Value)
51: {
52:
53: $this->Source->getActiveSheet()->setCellValueExplicitByColumnAndRow($Cell->getColumn(), $Cell->getRow(),
54: $Value);
55: return $this;
56: }
57:
58: /**
59: * @param Cell $Cell
60: *
61: * @return mixed
62: */
63: public function getValue(Cell $Cell)
64: {
65:
66: return $this->Source->getActiveSheet()->getCellByColumnAndRow($Cell->getColumn(),
67: $Cell->getRow())->getValue();
68: }
69:
70: /**
71: * @param Cell $Cell Single Cell or Top-Left
72: * @param Cell|null $Range Bottom-Right
73: *
74: * @return Style
75: */
76: public function setStyle(Cell $Cell, Cell $Range = null)
77: {
78:
79: return new Style($this->Source->getActiveSheet(), $Cell, $Range);
80: }
81:
82: /**
83: * @return int
84: */
85: public function getSheetColumnCount()
86: {
87:
88: return \PHPExcel_Cell::columnIndexFromString(
89: $this->Source->getActiveSheet()->getHighestColumn()
90: );
91: }
92:
93: /**
94: * @return int
95: */
96: public function getSheetRowCount()
97: {
98:
99: return $this->Source->getActiveSheet()->getHighestRow();
100: }
101: }
102: