Alignment
extends Supervisor
in package
Table of Contents
Constants
- HORIZONTAL_ALIGNMENT_FOR_HTML = [ self::HORIZONTAL_LEFT => self::HORIZONTAL_LEFT, self::HORIZONTAL_RIGHT => self::HORIZONTAL_RIGHT, self::HORIZONTAL_CENTER => self::HORIZONTAL_CENTER, self::HORIZONTAL_CENTER_CONTINUOUS => self::HORIZONTAL_CENTER, self::HORIZONTAL_JUSTIFY => self::HORIZONTAL_JUSTIFY, //self::HORIZONTAL_FILL => self::HORIZONTAL_FILL, // no reasonable equivalent for fill self::HORIZONTAL_DISTRIBUTED => self::HORIZONTAL_JUSTIFY, ]
- HORIZONTAL_ALIGNMENT_FOR_XLSX = [self::HORIZONTAL_LEFT => self::HORIZONTAL_LEFT, self::HORIZONTAL_RIGHT => self::HORIZONTAL_RIGHT, self::HORIZONTAL_CENTER => self::HORIZONTAL_CENTER, self::HORIZONTAL_CENTER_CONTINUOUS => self::HORIZONTAL_CENTER_CONTINUOUS, self::HORIZONTAL_JUSTIFY => self::HORIZONTAL_JUSTIFY, self::HORIZONTAL_FILL => self::HORIZONTAL_FILL, self::HORIZONTAL_DISTRIBUTED => self::HORIZONTAL_DISTRIBUTED]
- HORIZONTAL_CENTER = 'center'
- HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'
- HORIZONTAL_DISTRIBUTED = 'distributed'
- HORIZONTAL_FILL = 'fill'
- HORIZONTAL_GENERAL = 'general'
- HORIZONTAL_JUSTIFY = 'justify'
- HORIZONTAL_LEFT = 'left'
- HORIZONTAL_RIGHT = 'right'
- READORDER_CONTEXT = 0
- READORDER_LTR = 1
- READORDER_RTL = 2
- TEXTROTATION_STACK_EXCEL = 255
- TEXTROTATION_STACK_PHPSPREADSHEET = -165
- VERTICAL_ALIGNMENT_FOR_HTML = [ self::VERTICAL_BOTTOM => self::VERTICAL_BOTTOM, self::VERTICAL_TOP => self::VERTICAL_TOP, self::VERTICAL_CENTER => self::VERTICAL_MIDDLE, self::VERTICAL_JUSTIFY => self::VERTICAL_MIDDLE, self::VERTICAL_DISTRIBUTED => self::VERTICAL_MIDDLE, // css settings that arent't in sync with Excel self::VERTICAL_BASELINE => self::VERTICAL_BASELINE, self::VERTICAL_MIDDLE => self::VERTICAL_MIDDLE, self::VERTICAL_SUB => self::VERTICAL_SUB, self::VERTICAL_SUPER => self::VERTICAL_SUPER, self::VERTICAL_TEXT_BOTTOM => self::VERTICAL_TEXT_BOTTOM, self::VERTICAL_TEXT_TOP => self::VERTICAL_TEXT_TOP, ]
- VERTICAL_ALIGNMENT_FOR_XLSX = [ self::VERTICAL_BOTTOM => self::VERTICAL_BOTTOM, self::VERTICAL_TOP => self::VERTICAL_TOP, self::VERTICAL_CENTER => self::VERTICAL_CENTER, self::VERTICAL_JUSTIFY => self::VERTICAL_JUSTIFY, self::VERTICAL_DISTRIBUTED => self::VERTICAL_DISTRIBUTED, // css settings that arent't in sync with Excel self::VERTICAL_BASELINE => self::VERTICAL_BOTTOM, self::VERTICAL_MIDDLE => self::VERTICAL_CENTER, self::VERTICAL_SUB => self::VERTICAL_BOTTOM, self::VERTICAL_SUPER => self::VERTICAL_TOP, self::VERTICAL_TEXT_BOTTOM => self::VERTICAL_BOTTOM, self::VERTICAL_TEXT_TOP => self::VERTICAL_TOP, ]
- VERTICAL_BOTTOM = 'bottom'
- VERTICAL_CENTER = 'center'
- VERTICAL_DISTRIBUTED = 'distributed'
- VERTICAL_JUSTIFY = 'justify'
- VERTICAL_TOP = 'top'
- HORIZONTAL_CENTER_CONTINUOUS_LC = 'centercontinuous'
- VERTICAL_BASELINE = 'baseline'
- VERTICAL_MIDDLE = 'middle'
- VERTICAL_SUB = 'sub'
- VERTICAL_SUPER = 'super'
- VERTICAL_TEXT_BOTTOM = 'text-bottom'
- VERTICAL_TEXT_TOP = 'text-top'
Properties
- $horizontal : string|null
- Horizontal alignment.
- $indent : int
- Indent - only possible with horizontal alignment left and right.
- $isSupervisor : bool
- Supervisor?
- $parent : Spreadsheet|Supervisor
- Parent. Only used for supervisor.
- $parentPropertyName : string|null
- Parent property name.
- $readOrder : int
- Read order.
- $shrinkToFit : bool
- Shrink to fit.
- $textRotation : int|null
- Text rotation.
- $vertical : string|null
- Vertical alignment.
- $wrapText : bool
- Wrap text.
Methods
- __clone() : mixed
- Implement PHP __clone to create a deep clone, not just a shallow copy.
- __construct() : mixed
- Create a new Alignment.
- applyFromArray() : $this
- Apply styles from array.
- bindParent() : $this
- Bind parent. Only used for supervisor.
- exportArray() : array<string|int, mixed>
- Export style as array.
- getActiveCell() : string
- Get the currently active cell coordinate in currently active sheet.
- getActiveSheet() : Worksheet
- Get the currently active sheet. Only used for supervisor.
- getHashCode() : string
- Get hash code.
- getHorizontal() : null|string
- Get Horizontal.
- getIndent() : int
- Get indent.
- getIsSupervisor() : bool
- Is this a supervisor or a cell style component?
- getReadOrder() : int
- Get read order.
- getSelectedCells() : string
- Get the currently active cell coordinate in currently active sheet.
- getSharedComponent() : self
- Get the shared style component for the currently active cell in currently active sheet.
- getShrinkToFit() : bool
- Get Shrink to fit.
- getStyleArray() : array<string|int, mixed>
- Build style array from subcomponents.
- getTextRotation() : null|int
- Get TextRotation.
- getVertical() : null|string
- Get Vertical.
- getWrapText() : bool
- Get Wrap Text.
- setHorizontal() : $this
- Set Horizontal.
- setIndent() : $this
- Set indent.
- setReadOrder() : $this
- Set read order.
- setShrinkToFit() : $this
- Set Shrink to fit.
- setTextRotation() : $this
- Set TextRotation.
- setVertical() : $this
- Set Vertical.
- setWrapText() : $this
- Set Wrap Text.
- exportArray1() : array<string|int, mixed>
- Abstract method to be implemented in anything which extends this class.
- exportArray2() : void
- Populate array from exportArray1.
Constants
HORIZONTAL_ALIGNMENT_FOR_HTML
public
mixed
HORIZONTAL_ALIGNMENT_FOR_HTML
= [
self::HORIZONTAL_LEFT => self::HORIZONTAL_LEFT,
self::HORIZONTAL_RIGHT => self::HORIZONTAL_RIGHT,
self::HORIZONTAL_CENTER => self::HORIZONTAL_CENTER,
self::HORIZONTAL_CENTER_CONTINUOUS => self::HORIZONTAL_CENTER,
self::HORIZONTAL_JUSTIFY => self::HORIZONTAL_JUSTIFY,
//self::HORIZONTAL_FILL => self::HORIZONTAL_FILL, // no reasonable equivalent for fill
self::HORIZONTAL_DISTRIBUTED => self::HORIZONTAL_JUSTIFY,
]
HORIZONTAL_ALIGNMENT_FOR_XLSX
public
mixed
HORIZONTAL_ALIGNMENT_FOR_XLSX
= [self::HORIZONTAL_LEFT => self::HORIZONTAL_LEFT, self::HORIZONTAL_RIGHT => self::HORIZONTAL_RIGHT, self::HORIZONTAL_CENTER => self::HORIZONTAL_CENTER, self::HORIZONTAL_CENTER_CONTINUOUS => self::HORIZONTAL_CENTER_CONTINUOUS, self::HORIZONTAL_JUSTIFY => self::HORIZONTAL_JUSTIFY, self::HORIZONTAL_FILL => self::HORIZONTAL_FILL, self::HORIZONTAL_DISTRIBUTED => self::HORIZONTAL_DISTRIBUTED]
HORIZONTAL_CENTER
public
mixed
HORIZONTAL_CENTER
= 'center'
HORIZONTAL_CENTER_CONTINUOUS
public
mixed
HORIZONTAL_CENTER_CONTINUOUS
= 'centerContinuous'
HORIZONTAL_DISTRIBUTED
public
mixed
HORIZONTAL_DISTRIBUTED
= 'distributed'
HORIZONTAL_FILL
public
mixed
HORIZONTAL_FILL
= 'fill'
HORIZONTAL_GENERAL
public
mixed
HORIZONTAL_GENERAL
= 'general'
HORIZONTAL_JUSTIFY
public
mixed
HORIZONTAL_JUSTIFY
= 'justify'
HORIZONTAL_LEFT
public
mixed
HORIZONTAL_LEFT
= 'left'
HORIZONTAL_RIGHT
public
mixed
HORIZONTAL_RIGHT
= 'right'
READORDER_CONTEXT
public
mixed
READORDER_CONTEXT
= 0
READORDER_LTR
public
mixed
READORDER_LTR
= 1
READORDER_RTL
public
mixed
READORDER_RTL
= 2
TEXTROTATION_STACK_EXCEL
public
mixed
TEXTROTATION_STACK_EXCEL
= 255
TEXTROTATION_STACK_PHPSPREADSHEET
public
mixed
TEXTROTATION_STACK_PHPSPREADSHEET
= -165
VERTICAL_ALIGNMENT_FOR_HTML
public
mixed
VERTICAL_ALIGNMENT_FOR_HTML
= [
self::VERTICAL_BOTTOM => self::VERTICAL_BOTTOM,
self::VERTICAL_TOP => self::VERTICAL_TOP,
self::VERTICAL_CENTER => self::VERTICAL_MIDDLE,
self::VERTICAL_JUSTIFY => self::VERTICAL_MIDDLE,
self::VERTICAL_DISTRIBUTED => self::VERTICAL_MIDDLE,
// css settings that arent't in sync with Excel
self::VERTICAL_BASELINE => self::VERTICAL_BASELINE,
self::VERTICAL_MIDDLE => self::VERTICAL_MIDDLE,
self::VERTICAL_SUB => self::VERTICAL_SUB,
self::VERTICAL_SUPER => self::VERTICAL_SUPER,
self::VERTICAL_TEXT_BOTTOM => self::VERTICAL_TEXT_BOTTOM,
self::VERTICAL_TEXT_TOP => self::VERTICAL_TEXT_TOP,
]
VERTICAL_ALIGNMENT_FOR_XLSX
public
mixed
VERTICAL_ALIGNMENT_FOR_XLSX
= [
self::VERTICAL_BOTTOM => self::VERTICAL_BOTTOM,
self::VERTICAL_TOP => self::VERTICAL_TOP,
self::VERTICAL_CENTER => self::VERTICAL_CENTER,
self::VERTICAL_JUSTIFY => self::VERTICAL_JUSTIFY,
self::VERTICAL_DISTRIBUTED => self::VERTICAL_DISTRIBUTED,
// css settings that arent't in sync with Excel
self::VERTICAL_BASELINE => self::VERTICAL_BOTTOM,
self::VERTICAL_MIDDLE => self::VERTICAL_CENTER,
self::VERTICAL_SUB => self::VERTICAL_BOTTOM,
self::VERTICAL_SUPER => self::VERTICAL_TOP,
self::VERTICAL_TEXT_BOTTOM => self::VERTICAL_BOTTOM,
self::VERTICAL_TEXT_TOP => self::VERTICAL_TOP,
]
VERTICAL_BOTTOM
public
mixed
VERTICAL_BOTTOM
= 'bottom'
VERTICAL_CENTER
public
mixed
VERTICAL_CENTER
= 'center'
VERTICAL_DISTRIBUTED
public
mixed
VERTICAL_DISTRIBUTED
= 'distributed'
VERTICAL_JUSTIFY
public
mixed
VERTICAL_JUSTIFY
= 'justify'
VERTICAL_TOP
public
mixed
VERTICAL_TOP
= 'top'
HORIZONTAL_CENTER_CONTINUOUS_LC
private
mixed
HORIZONTAL_CENTER_CONTINUOUS_LC
= 'centercontinuous'
VERTICAL_BASELINE
private
mixed
VERTICAL_BASELINE
= 'baseline'
VERTICAL_MIDDLE
private
mixed
VERTICAL_MIDDLE
= 'middle'
VERTICAL_SUB
private
mixed
VERTICAL_SUB
= 'sub'
VERTICAL_SUPER
private
mixed
VERTICAL_SUPER
= 'super'
VERTICAL_TEXT_BOTTOM
private
mixed
VERTICAL_TEXT_BOTTOM
= 'text-bottom'
VERTICAL_TEXT_TOP
private
mixed
VERTICAL_TEXT_TOP
= 'text-top'
Properties
$horizontal
Horizontal alignment.
protected
string|null
$horizontal
= self::HORIZONTAL_GENERAL
$indent
Indent - only possible with horizontal alignment left and right.
protected
int
$indent
= 0
$isSupervisor
Supervisor?
protected
bool
$isSupervisor
$parent
Parent. Only used for supervisor.
protected
Spreadsheet|Supervisor
$parent
$parentPropertyName
Parent property name.
protected
string|null
$parentPropertyName
= null
$readOrder
Read order.
protected
int
$readOrder
= 0
$shrinkToFit
Shrink to fit.
protected
bool
$shrinkToFit
= false
$textRotation
Text rotation.
protected
int|null
$textRotation
= 0
$vertical
Vertical alignment.
protected
string|null
$vertical
= self::VERTICAL_BOTTOM
$wrapText
Wrap text.
protected
bool
$wrapText
= false
Methods
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
public
__clone() : mixed
__construct()
Create a new Alignment.
public
__construct([bool $isSupervisor = false ][, bool $isConditional = false ]) : mixed
Parameters
- $isSupervisor : bool = false
-
Flag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
- $isConditional : bool = false
-
Flag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are
applyFromArray()
Apply styles from array.
public
applyFromArray(array<string|int, mixed> $styleArray) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
[
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
'textRotation' => 0,
'wrapText' => TRUE
]
);
Parameters
- $styleArray : array<string|int, mixed>
-
Array containing style information
Return values
$thisbindParent()
Bind parent. Only used for supervisor.
public
bindParent(Spreadsheet|self $parent[, string|null $parentPropertyName = null ]) : $this
Parameters
- $parent : Spreadsheet|self
- $parentPropertyName : string|null = null
Return values
$thisexportArray()
Export style as array.
public
final exportArray() : array<string|int, mixed>
Available to anything which extends this class: Alignment, Border, Borders, Color, Fill, Font, NumberFormat, Protection, and Style.
Return values
array<string|int, mixed>getActiveCell()
Get the currently active cell coordinate in currently active sheet.
public
getActiveCell() : string
Only used for supervisor.
Return values
string —E.g. 'A1'
getActiveSheet()
Get the currently active sheet. Only used for supervisor.
public
getActiveSheet() : Worksheet
Return values
WorksheetgetHashCode()
Get hash code.
public
getHashCode() : string
Return values
string —Hash code
getHorizontal()
Get Horizontal.
public
getHorizontal() : null|string
Return values
null|stringgetIndent()
Get indent.
public
getIndent() : int
Return values
intgetIsSupervisor()
Is this a supervisor or a cell style component?
public
getIsSupervisor() : bool
Return values
boolgetReadOrder()
Get read order.
public
getReadOrder() : int
Return values
intgetSelectedCells()
Get the currently active cell coordinate in currently active sheet.
public
getSelectedCells() : string
Only used for supervisor.
Return values
string —E.g. 'A1'
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
public
getSharedComponent() : self
Only used for style supervisor.
Return values
selfgetShrinkToFit()
Get Shrink to fit.
public
getShrinkToFit() : bool
Return values
boolgetStyleArray()
Build style array from subcomponents.
public
getStyleArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed>getTextRotation()
Get TextRotation.
public
getTextRotation() : null|int
Return values
null|intgetVertical()
Get Vertical.
public
getVertical() : null|string
Return values
null|stringgetWrapText()
Get Wrap Text.
public
getWrapText() : bool
Return values
boolsetHorizontal()
Set Horizontal.
public
setHorizontal(string $horizontalAlignment) : $this
Parameters
- $horizontalAlignment : string
-
see self::HORIZONTAL_*
Return values
$thissetIndent()
Set indent.
public
setIndent(int $indent) : $this
Parameters
- $indent : int
Return values
$thissetReadOrder()
Set read order.
public
setReadOrder(int $readOrder) : $this
Parameters
- $readOrder : int
Return values
$thissetShrinkToFit()
Set Shrink to fit.
public
setShrinkToFit(bool $shrink) : $this
Parameters
- $shrink : bool
Return values
$thissetTextRotation()
Set TextRotation.
public
setTextRotation(int $angleInDegrees) : $this
Parameters
- $angleInDegrees : int
Return values
$thissetVertical()
Set Vertical.
public
setVertical(string $verticalAlignment) : $this
Parameters
- $verticalAlignment : string
-
see self::VERTICAL_*
Return values
$thissetWrapText()
Set Wrap Text.
public
setWrapText(bool $wrapped) : $this
Parameters
- $wrapped : bool
Return values
$thisexportArray1()
Abstract method to be implemented in anything which extends this class.
protected
exportArray1() : array<string|int, mixed>
This method invokes exportArray2 with the names and values of all properties to be included in output array, returning that array to exportArray, then to caller.
Return values
array<string|int, mixed>exportArray2()
Populate array from exportArray1.
protected
final exportArray2(array<string|int, mixed> &$exportedArray, string $index, mixed $objOrValue) : void
This method is available to anything which extends this class. The parameter index is the key to be added to the array. The parameter objOrValue is either a primitive type, which is the value added to the array, or a Style object to be recursively added via exportArray.
Parameters
- $exportedArray : array<string|int, mixed>
- $index : string
- $objOrValue : mixed