class PHPExcel_Shared_Excel5

PHPExcelSharedExcel5

Copyright (c) 2006 - 2015 PHPExcel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Methods

static integer
sizeCol(PHPExcel_Worksheet $sheet, string $col = 'A')

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

static integer
sizeRow(PHPExcel_Worksheet $sheet, integer $row = 1)

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.

static integer
getDistanceX(PHPExcel_Worksheet $sheet, string $startColumn = 'A', integer $startOffsetX, string $endColumn = 'A', integer $endOffsetX)

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

static integer
getDistanceY(PHPExcel_Worksheet $sheet, integer $startRow = 1, integer $startOffsetY, integer $endRow = 1, integer $endOffsetY)

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

static array
oneAnchor2twoAnchor(PHPExcel_Worksheet $sheet, string $coordinates, integer $offsetX, integer $offsetY, integer $width, integer $height)

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

Details

at line 48
static integer sizeCol(PHPExcel_Worksheet $sheet, string $col = 'A')

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 $sheet The sheet
string $col The column

Return Value

integer The width in pixels

at line 90
static integer sizeRow(PHPExcel_Worksheet $sheet, integer $row = 1)

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 $sheet The sheet
integer $row The row index (1-based)

Return Value

integer The width in pixels

at line 135
static integer getDistanceX(PHPExcel_Worksheet $sheet, string $startColumn = 'A', integer $startOffsetX, string $endColumn = 'A', integer $endOffsetX)

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 $startOffsetX Offset within start cell measured in 1/1024 of the cell width
string $endColumn
integer $endOffsetX Offset within end cell measured in 1/1024 of the cell width

Return Value

integer Horizontal measured in pixels

at line 166
static integer getDistanceY(PHPExcel_Worksheet $sheet, integer $startRow = 1, integer $startOffsetY, integer $endRow = 1, integer $endOffsetY)

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 $startOffsetY Offset within start cell measured in 1/256 of the cell height
integer $endRow (1-based)
integer $endOffsetY Offset within end cell measured in 1/256 of the cell height

Return Value

integer Vertical distance measured in pixels

at line 236
static array oneAnchor2twoAnchor(PHPExcel_Worksheet $sheet, string $coordinates, integer $offsetX, integer $offsetY, integer $width, integer $height)

Convert 1-cell anchor coordinates to 2-cell anchor coordinates This function is ported from PEAR SpreadsheetWriterExcel 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: $colstart, $rowstart, $colend, $rowend, $x1, $y1, $x2, $y2. The width and height of the cells are also variable and have to be taken into account. The values of $colstart and $rowstart are passed in from the calling function. The values of $colend and $rowend 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 $coordinates E.g. 'A1'
integer $offsetX Horizontal offset in pixels
integer $offsetY Vertical offset in pixels
integer $width Width in pixels
integer $height Height in pixels

Return Value

array