ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPExcel_Shared_Excel5 Class Reference
+ Collaboration diagram for PHPExcel_Shared_Excel5:

Static Public Member Functions

static sizeCol ($sheet, $col='A')
 Get the width of a column in pixels. More...
 
static sizeRow ($sheet, $row=1)
 Convert the height of a cell from user's units to pixels. More...
 
static getDistanceX (PHPExcel_Worksheet $sheet, $startColumn='A', $startOffsetX=0, $endColumn='A', $endOffsetX=0)
 Get the horizontal distance in pixels between two anchors The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. More...
 
static getDistanceY (PHPExcel_Worksheet $sheet, $startRow=1, $startOffsetY=0, $endRow=1, $endOffsetY=0)
 Get the vertical distance in pixels between two anchors The distanceY is found as sum of all the spanning rows minus two offsets. More...
 
static oneAnchor2twoAnchor ($sheet, $coordinates, $offsetX, $offsetY, $width, $height)
 Convert 1-cell anchor coordinates to 2-cell anchor coordinates This function is ported from PEAR Spreadsheet_Writer_Excel with small modifications. More...
 

Detailed Description

Definition at line 35 of file Excel5.php.

Member Function Documentation

◆ getDistanceX()

static PHPExcel_Shared_Excel5::getDistanceX ( PHPExcel_Worksheet  $sheet,
  $startColumn = 'A',
  $startOffsetX = 0,
  $endColumn = 'A',
  $endOffsetX = 0 
)
static

Get the horizontal distance in pixels between two anchors The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets.

Parameters
PHPExcel_Worksheet$sheet
string$startColumn
integer$startOffsetXOffset within start cell measured in 1/1024 of the cell width
string$endColumn
integer$endOffsetXOffset within end cell measured in 1/1024 of the cell width
Returns
integer Horizontal measured in pixels

Definition at line 144 of file Excel5.php.

145 {
146 $distanceX = 0;
147
148 // add the widths of the spanning columns
149 $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; // 1-based
150 $endColumnIndex = PHPExcel_Cell::columnIndexFromString($endColumn) - 1; // 1-based
151 for ($i = $startColumnIndex; $i <= $endColumnIndex; ++$i) {
153 }
154
155 // correct for offsetX in startcell
156 $distanceX -= (int) floor(self::sizeCol($sheet, $startColumn) * $startOffsetX / 1024);
157
158 // correct for offsetX in endcell
159 $distanceX -= (int) floor(self::sizeCol($sheet, $endColumn) * (1 - $endOffsetX / 1024));
160
161 return $distanceX;
162 }
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
static sizeCol($sheet, $col='A')
Get the width of a column in pixels.
Definition: Excel5.php:46
$i
Definition: disco.tpl.php:19

References $i, PHPExcel_Cell\columnIndexFromString(), sizeCol(), and PHPExcel_Cell\stringFromColumnIndex().

Referenced by PHPExcel_Reader_Excel5\load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDistanceY()

static PHPExcel_Shared_Excel5::getDistanceY ( PHPExcel_Worksheet  $sheet,
  $startRow = 1,
  $startOffsetY = 0,
  $endRow = 1,
  $endOffsetY = 0 
)
static

Get the vertical distance in pixels between two anchors The distanceY is found as sum of all the spanning rows minus two offsets.

Parameters
PHPExcel_Worksheet$sheet
integer$startRow(1-based)
integer$startOffsetYOffset within start cell measured in 1/256 of the cell height
integer$endRow(1-based)
integer$endOffsetYOffset within end cell measured in 1/256 of the cell height
Returns
integer Vertical distance measured in pixels

Definition at line 175 of file Excel5.php.

176 {
177 $distanceY = 0;
178
179 // add the widths of the spanning rows
180 for ($row = $startRow; $row <= $endRow; ++$row) {
181 $distanceY += self::sizeRow($sheet, $row);
182 }
183
184 // correct for offsetX in startcell
185 $distanceY -= (int) floor(self::sizeRow($sheet, $startRow) * $startOffsetY / 256);
186
187 // correct for offsetX in endcell
188 $distanceY -= (int) floor(self::sizeRow($sheet, $endRow) * (1 - $endOffsetY / 256));
189
190 return $distanceY;
191 }
static sizeRow($sheet, $row=1)
Convert the height of a cell from user's units to pixels.
Definition: Excel5.php:93

References $row, and sizeRow().

Referenced by PHPExcel_Reader_Excel5\load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oneAnchor2twoAnchor()

static PHPExcel_Shared_Excel5::oneAnchor2twoAnchor (   $sheet,
  $coordinates,
  $offsetX,
  $offsetY,
  $width,
  $height 
)
static

Convert 1-cell anchor coordinates to 2-cell anchor coordinates This function is ported from PEAR Spreadsheet_Writer_Excel with small modifications.

Calculate the vertices that define the position of the image as required by the OBJ record.

     +------------+------------+
     |       A        |       B      |

+--—+---------—+---------—+ | |(x1,y1) | | | 1 |(A1)._______|______ | | | | | | | | | | | +--—+-—| BITMAP |--—+ | | | | | | 2 | |______________. | | | | (B2)| | | | (x2,y2)| +-— +---------—+---------—+

Example of a bitmap that covers some of the area from cell A1 to cell B2.

Based on the width and height of the bitmap we need to calculate 8 vars: $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. The width and height of the cells are also variable and have to be taken into account. The values of $col_start and $row_start are passed in from the calling function. The values of $col_end and $row_end are calculated by subtracting the width and height of the bitmap from the width and height of the underlying cells. The vertices are expressed as a percentage of the underlying cell width as follows (rhs values are in pixels):

    x1 = X / W *1024
    y1 = Y / H *256
    x2 = (X-1) / W *1024
    y2 = (Y-1) / H *256

    Where:  X is distance from the left side of the underlying cell
               Y is distance from the top of the underlying cell
               W is the width of the cell
               H is the height of the cell
Parameters
PHPExcel_Worksheet$sheet
string$coordinatesE.g. 'A1'
integer$offsetXHorizontal offset in pixels
integer$offsetYVertical offset in pixels
integer$widthWidth in pixels
integer$heightHeight in pixels
Returns
array

Definition at line 245 of file Excel5.php.

246 {
247 list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
249 $row_start = $row - 1;
250
251 $x1 = $offsetX;
252 $y1 = $offsetY;
253
254 // Initialise end cell to the same as the start cell
255 $col_end = $col_start; // Col containing lower right corner of object
256 $row_end = $row_start; // Row containing bottom right corner of object
257
258 // Zero the specified offset if greater than the cell dimensions
259 if ($x1 >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start))) {
260 $x1 = 0;
261 }
262 if ($y1 >= self::sizeRow($sheet, $row_start + 1)) {
263 $y1 = 0;
264 }
265
266 $width = $width + $x1 -1;
267 $height = $height + $y1 -1;
268
269 // Subtract the underlying cell widths to find the end cell of the image
270 while ($width >= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end))) {
271 $width -= self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end));
272 ++$col_end;
273 }
274
275 // Subtract the underlying cell heights to find the end cell of the image
276 while ($height >= self::sizeRow($sheet, $row_end + 1)) {
277 $height -= self::sizeRow($sheet, $row_end + 1);
278 ++$row_end;
279 }
280
281 // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
282 // with zero height or width.
283 if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) == 0) {
284 return;
285 }
286 if (self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) == 0) {
287 return;
288 }
289 if (self::sizeRow($sheet, $row_start + 1) == 0) {
290 return;
291 }
292 if (self::sizeRow($sheet, $row_end + 1) == 0) {
293 return;
294 }
295
296 // Convert the pixel values to the percentage value expected by Excel
297 $x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024;
298 $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256;
299 $x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
300 $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
301
302 $startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
303 $endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
304
305 $twoAnchor = array(
306 'startCoordinates' => $startCoordinates,
307 'startOffsetX' => $x1,
308 'startOffsetY' => $y1,
309 'endCoordinates' => $endCoordinates,
310 'endOffsetX' => $x2,
311 'endOffsetY' => $y2,
312 );
313
314 return $twoAnchor;
315 }
$column
Definition: 39dropdown.php:62
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
Definition: Cell.php:580

References $column, $row, PHPExcel_Cell\columnIndexFromString(), PHPExcel_Cell\coordinateFromString(), sizeCol(), sizeRow(), and PHPExcel_Cell\stringFromColumnIndex().

Referenced by PHPExcel_Writer_Excel5\_buildWorksheetEschers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeCol()

static PHPExcel_Shared_Excel5::sizeCol (   $sheet,
  $col = 'A' 
)
static

Get the width of a column in pixels.

We use the relationship y = ceil(7x) where x is the width in intrinsic Excel units (measuring width in number of normal characters) This holds for Arial 10

Parameters
PHPExcel_Worksheet$sheetThe sheet
string$colThe column
Returns
integer The width in pixels

Definition at line 46 of file Excel5.php.

47 {
48 // default font of the workbook
49 $font = $sheet->getParent()->getDefaultStyle()->getFont();
50
51 $columnDimensions = $sheet->getColumnDimensions();
52
53 // first find the true column width in pixels (uncollapsed and unhidden)
54 if ( isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1 ) {
55
56 // then we have column dimension with explicit width
57 $columnDimension = $columnDimensions[$col];
58 $width = $columnDimension->getWidth();
59 $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
60
61 } else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
62
63 // then we have default column dimension with explicit width
64 $defaultColumnDimension = $sheet->getDefaultColumnDimension();
65 $width = $defaultColumnDimension->getWidth();
66 $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
67
68 } else {
69
70 // we don't even have any default column dimension. Width depends on default font
72 }
73
74 // now find the effective column width in pixels
75 if (isset($columnDimensions[$col]) and !$columnDimensions[$col]->getVisible()) {
76 $effectivePixelWidth = 0;
77 } else {
78 $effectivePixelWidth = $pixelWidth;
79 }
80
81 return $effectivePixelWidth;
82 }
static cellDimensionToPixels($pValue=0, PHPExcel_Style_Font $pDefaultFont)
Convert column width from (intrinsic) Excel units to pixels.
Definition: Drawing.php:99
static getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels=false)
Get the effective column width for columns without a column dimension or column with width -1 For exa...
Definition: Font.php:571

References PHPExcel_Shared_Drawing\cellDimensionToPixels(), and PHPExcel_Shared_Font\getDefaultColumnWidthByFont().

Referenced by PHPExcel_Writer_Excel5_Worksheet\_positionImage(), getDistanceX(), PHPExcel_Reader_Excel5\load(), and oneAnchor2twoAnchor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeRow()

static PHPExcel_Shared_Excel5::sizeRow (   $sheet,
  $row = 1 
)
static

Convert the height of a cell from user's units to pixels.

By interpolation the relationship is: y = 4/3x. If the height hasn't been set by the user we use the default value. If the row is hidden we use a value of zero.

Parameters
PHPExcel_Worksheet$sheetThe sheet
integer$rowThe row index (1-based)
Returns
integer The width in pixels

Definition at line 93 of file Excel5.php.

94 {
95 // default font of the workbook
96 $font = $sheet->getParent()->getDefaultStyle()->getFont();
97
98 $rowDimensions = $sheet->getRowDimensions();
99
100 // first find the true row height in pixels (uncollapsed and unhidden)
101 if ( isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
102
103 // then we have a row dimension
104 $rowDimension = $rowDimensions[$row];
105 $rowHeight = $rowDimension->getRowHeight();
106 $pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10
107
108 } else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
109
110 // then we have a default row dimension with explicit height
111 $defaultRowDimension = $sheet->getDefaultRowDimension();
112 $rowHeight = $defaultRowDimension->getRowHeight();
113 $pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
114
115 } else {
116
117 // we don't even have any default row dimension. Height depends on default font
119 $pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
120
121 }
122
123 // now find the effective row height in pixels
124 if ( isset($rowDimensions[$row]) and !$rowDimensions[$row]->getVisible() ) {
125 $effectivePixelRowHeight = 0;
126 } else {
127 $effectivePixelRowHeight = $pixelRowHeight;
128 }
129
130 return $effectivePixelRowHeight;
131 }
static pointsToPixels($pValue=0)
Convert points to pixels.
Definition: Drawing.php:140
static fontSizeToPixels($fontSizeInPoints=11)
Calculate an (approximate) pixel size, based on a font points size.
Definition: Font.php:394
static getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
Get the effective row height for rows without a row dimension or rows with height -1 For example,...
Definition: Font.php:603

References $row, PHPExcel_Shared_Font\fontSizeToPixels(), PHPExcel_Shared_Font\getDefaultRowHeightByFont(), and PHPExcel_Shared_Drawing\pointsToPixels().

Referenced by PHPExcel_Writer_Excel5_Worksheet\_positionImage(), getDistanceY(), PHPExcel_Reader_Excel5\load(), and oneAnchor2twoAnchor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: