29 if (!defined(
'PHPEXCEL_ROOT')) {
33 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
37 require_once PHPEXCEL_ROOT .
'PHPExcel/Cell.php';
40 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/Drawing.php';
60 public static function sizeCol($sheet, $col =
'A')
63 $fontSize = $sheet->getParent()->getDefaultStyle()->getFont()->getSize();
65 $columnDimensions = $sheet->getColumnDimensions();
68 if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) {
71 $columnDimension = $columnDimensions[$col];
72 $width = $columnDimension->getWidth();
75 }
else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
78 $defaultColumnDimension = $sheet->getDefaultColumnDimension();
79 $width = $defaultColumnDimension->getWidth();
83 $pixelWidth = (int) 64 * $fontSize / 11;
87 if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
88 $effectivePixelWidth = 0;
90 $effectivePixelWidth = $pixelWidth;
93 return $effectivePixelWidth;
107 $rowDimensions = $sheet->getRowDimensions();
110 if ( isset($rowDimensions[
$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
113 $rowDimension = $rowDimensions[
$row];
114 $rowHeight = $rowDimension->getRowHeight();
115 $pixelRowHeight = (int) ceil(4 * $rowHeight / 3);
117 }
else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
120 $defaultRowDimension = $sheet->getDefaultRowDimension();
121 $rowHeight = $defaultRowDimension->getRowHeight();
125 $pixelRowHeight = 20;
129 if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) {
130 $effectivePixelRowHeight = 0;
132 $effectivePixelRowHeight = $pixelRowHeight;
135 return $effectivePixelRowHeight;
156 for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) {
161 $distanceX -= (int) floor(self::sizeCol($sheet, $startColumn) * $startOffsetX / 1024);
164 $distanceX -= (int) floor(self::sizeCol($sheet, $endColumn) * (1 - $endOffsetX / 1024));
190 $distanceY -= (int) floor(self::sizeRow($sheet, $startRow) * $startOffsetY / 256);
193 $distanceY -= (int) floor(self::sizeRow($sheet, $endRow) * (1 - $endOffsetY / 256));
254 $row_start =
$row - 1;
260 $col_end = $col_start;
261 $row_end = $row_start;
267 if ($y1 >= self::sizeRow($sheet, $row_start + 1)) {
271 $width = $width + $x1 -1;
272 $height = $height + $y1 -1;
281 while ($height >= self::sizeRow($sheet, $row_end + 1)) {
294 if (self::sizeRow($sheet, $row_start + 1) == 0) {
297 if (self::sizeRow($sheet, $row_end + 1) == 0) {
311 'startCoordinates' => $startCoordinates,
312 'startOffsetX' => $x1,
313 'startOffsetY' => $y1,
314 'endCoordinates' => $endCoordinates,