# Documentation

## Xls

getDistanceX()  : int
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.
getDistanceY()  : int
Get the vertical distance in pixels between two anchors The distanceY is found as sum of all the spanning rows minus two offsets.
oneAnchor2twoAnchor()  : null|array<string|int, mixed>
Convert 1-cell anchor coordinates to 2-cell anchor coordinates This function is ported from PEAR Spreadsheet_Writer_Excel with small modifications.
sizeCol()  : int
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.
sizeRow()  : int
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.

### Methods

#### getDistanceX()

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.

``` public static getDistanceX(Worksheet \$worksheet[, string \$startColumn = 'A' ], int \$startOffsetX[, string \$endColumn = 'A' ], int \$endOffsetX) : int```
##### Parameters
\$worksheet : Worksheet
\$startColumn : string = 'A'
\$startOffsetX : int

Offset within start cell measured in 1/1024 of the cell width

\$endColumn : string = 'A'
\$endOffsetX : int

Offset within end cell measured in 1/1024 of the cell width

##### Return values
int

Horizontal measured in pixels

#### getDistanceY()

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

``` public static getDistanceY(Worksheet \$worksheet[, int \$startRow = 1 ], int \$startOffsetY[, int \$endRow = 1 ], int \$endOffsetY) : int```
##### Parameters
\$worksheet : Worksheet
\$startRow : int = 1

(1-based)

\$startOffsetY : int

Offset within start cell measured in 1/256 of the cell height

\$endRow : int = 1

(1-based)

\$endOffsetY : int

Offset within end cell measured in 1/256 of the cell height

##### Return values
int

Vertical distance measured in pixels

#### oneAnchor2twoAnchor()

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

``` public static oneAnchor2twoAnchor(Worksheet \$worksheet, string \$coordinates, int \$offsetX, int \$offsetY, int \$width, int \$height) : null|array<string|int, mixed>```

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 : Worksheet
\$coordinates : string

E.g. 'A1'

\$offsetX : int

Horizontal offset in pixels

\$offsetY : int

Vertical offset in pixels

\$width : int

Width in pixels

\$height : int

Height in pixels

##### Return values
null|array<string|int, mixed>

#### sizeCol()

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.

``` public static sizeCol(Worksheet \$worksheet[, string \$col = 'A' ]) : int```
##### Parameters
\$worksheet : Worksheet

The sheet

\$col : string = 'A'

The column

##### Return values
int

The width in pixels

#### sizeRow()

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.

``` public static sizeRow(Worksheet \$worksheet[, int \$row = 1 ]) : int```
##### Parameters
\$worksheet : Worksheet

The sheet

\$row : int = 1

The row index (1-based)

##### Return values
int

The width in pixels