class Xls (View source)

Methods

static int
sizeCol(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 int
sizeRow(Worksheet $sheet, int $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 int
getDistanceX(Worksheet $sheet, string $startColumn = 'A', int $startOffsetX = 0, string $endColumn = 'A', int $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.

static int
getDistanceY(Worksheet $sheet, int $startRow = 1, int $startOffsetY = 0, int $endRow = 1, int $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.

static array
oneAnchor2twoAnchor(Worksheet $sheet, string $coordinates, int $offsetX, int $offsetY, int $width, int $height)

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

Details

static int sizeCol(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

Worksheet $sheet The sheet
string $col The column

Return Value

int The width in pixels

static int sizeRow(Worksheet $sheet, int $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

Worksheet $sheet The sheet
int $row The row index (1-based)

Return Value

int The width in pixels

static int getDistanceX(Worksheet $sheet, string $startColumn = 'A', int $startOffsetX = 0, string $endColumn = 'A', int $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.

Parameters

Worksheet $sheet
string $startColumn
int $startOffsetX Offset within start cell measured in 1/1024 of the cell width
string $endColumn
int $endOffsetX Offset within end cell measured in 1/1024 of the cell width

Return Value

int Horizontal measured in pixels

static int getDistanceY(Worksheet $sheet, int $startRow = 1, int $startOffsetY = 0, int $endRow = 1, int $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.

Parameters

Worksheet $sheet
int $startRow (1-based)
int $startOffsetY Offset within start cell measured in 1/256 of the cell height
int $endRow (1-based)
int $endOffsetY Offset within end cell measured in 1/256 of the cell height

Return Value

int Vertical distance measured in pixels

static array oneAnchor2twoAnchor(Worksheet $sheet, string $coordinates, int $offsetX, int $offsetY, int $width, int $height)

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

Worksheet $sheet
string $coordinates E.g. 'A1'
int $offsetX Horizontal offset in pixels
int $offsetY Vertical offset in pixels
int $width Width in pixels
int $height Height in pixels

Return Value

array