Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
PhpOffice\PhpSpreadsheet\Style\Alignment Class Reference
Inheritance diagram for PhpOffice\PhpSpreadsheet\Style\Alignment:
PhpOffice\PhpSpreadsheet\Style\Supervisor PhpOffice\PhpSpreadsheet\IComparable

Public Member Functions

 __construct (bool $isSupervisor=false, bool $isConditional=false)
 Create a new Alignment.
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy.
 
 applyFromArray (array $styleArray)
 Apply styles from array.
 
 bindParent (Spreadsheet|self $parent, ?string $parentPropertyName=null)
 Bind parent.
 
 exportArray ()
 Export style as array.
 
 getActiveCell ()
 Get the currently active cell coordinate in currently active sheet.
 
 getActiveSheet ()
 Get the currently active sheet.
 
 getHashCode ()
 Get hash code.
 
 getHorizontal ()
 Get Horizontal.
 
 getIndent ()
 Get indent.
 
 getIsSupervisor ()
 Is this a supervisor or a cell style component?
 
 getJustifyLastLine ()
 Get Justify Last Line.
 
 getReadOrder ()
 Get read order.
 
 getSelectedCells ()
 Get the currently active cell coordinate in currently active sheet.
 
 getSharedComponent ()
 Get the shared style component for the currently active cell in currently active sheet.
 
 getShrinkToFit ()
 Get Shrink to fit.
 
 getStyleArray (array $array)
 Build style array from subcomponents.
 
 getTextRotation ()
 Get TextRotation.
 
 getVertical ()
 Get Vertical.
 
 getWrapText ()
 Get Wrap Text.
 
 setHorizontal (string $horizontalAlignment)
 Set Horizontal.
 
 setIndent (int $indent)
 Set indent.
 
 setJustifyLastLine (bool $justifyLastLine)
 Set Justify Last Line.
 
 setReadOrder (int $readOrder)
 Set read order.
 
 setShrinkToFit (bool $shrink)
 Set Shrink to fit.
 
 setTextRotation (int $angleInDegrees)
 Set TextRotation.
 
 setVertical (string $verticalAlignment)
 Set Vertical.
 
 setWrapText (bool $wrapped)
 Set Wrap Text.
 

Public Attributes

const HORIZONTAL_ALIGNMENT_FOR_HTML
 
const HORIZONTAL_ALIGNMENT_FOR_XLSX
 
const HORIZONTAL_CENTER = 'center'
 
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'
 
const HORIZONTAL_DISTRIBUTED = 'distributed'
 
const HORIZONTAL_FILL = 'fill'
 
const HORIZONTAL_GENERAL = 'general'
 
const HORIZONTAL_JUSTIFY = 'justify'
 
const HORIZONTAL_LEFT = 'left'
 
const HORIZONTAL_RIGHT = 'right'
 
const READORDER_CONTEXT = 0
 
const READORDER_LTR = 1
 
const READORDER_RTL = 2
 
const TEXTROTATION_STACK_EXCEL = 255
 
const TEXTROTATION_STACK_PHPSPREADSHEET = -165
 
const VERTICAL_ALIGNMENT_FOR_HTML
 
const VERTICAL_ALIGNMENT_FOR_XLSX
 
const VERTICAL_BOTTOM = 'bottom'
 
const VERTICAL_CENTER = 'center'
 
const VERTICAL_DISTRIBUTED = 'distributed'
 
const VERTICAL_JUSTIFY = 'justify'
 
const VERTICAL_TOP = 'top'
 

Protected Member Functions

 exportArray1 ()
 Abstract method to be implemented in anything which extends this class.
 
 exportArray2 (array &$exportedArray, string $index, mixed $objOrValue)
 Populate array from exportArray1.
 

Protected Attributes

string $horizontal = self::HORIZONTAL_GENERAL
 
int $indent = 0
 Indent - only possible with horizontal alignment left and right.
 
bool $isSupervisor
 
bool $justifyLastLine = null
 Justify Last Line alignment.
 
Spreadsheet Supervisor $parent
 Parent.
 
string $parentPropertyName = null
 Parent property name.
 
int $readOrder = 0
 Read order.
 
bool $shrinkToFit = false
 Shrink to fit.
 
int $textRotation = 0
 Text rotation.
 
string $vertical = self::VERTICAL_BOTTOM
 Vertical alignment.
 
bool $wrapText = false
 Wrap text.
 

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Style\Alignment::__construct ( bool $isSupervisor = false,
bool $isConditional = false )

Create a new Alignment.

Parameters
bool$isSupervisorFlag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
bool$isConditionalFlag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are

Member Function Documentation

◆ __clone()

PhpOffice\PhpSpreadsheet\Style\Supervisor::__clone ( )
inherited

Implement PHP __clone to create a deep clone, not just a shallow copy.

Reimplemented in PhpOffice\PhpSpreadsheet\Style\Font.

◆ applyFromArray()

PhpOffice\PhpSpreadsheet\Style\Alignment::applyFromArray ( array $styleArray)

Apply styles from array.

$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
array$styleArrayArray containing style information
Return values
$this

◆ bindParent()

PhpOffice\PhpSpreadsheet\Style\Supervisor::bindParent ( Spreadsheet|self $parent,
?string $parentPropertyName = null )
inherited

Bind parent.

Only used for supervisor.

Return values
$this

◆ exportArray()

PhpOffice\PhpSpreadsheet\Style\Supervisor::exportArray ( )
finalinherited

Export style as array.

Available to anything which extends this class: Alignment, Border, Borders, Color, Fill, Font, NumberFormat, Protection, and Style.

◆ exportArray1()

PhpOffice\PhpSpreadsheet\Style\Alignment::exportArray1 ( )
protected

Abstract method to be implemented in anything which extends this class.

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.

Reimplemented from PhpOffice\PhpSpreadsheet\Style\Supervisor.

◆ exportArray2()

PhpOffice\PhpSpreadsheet\Style\Supervisor::exportArray2 ( array & $exportedArray,
string $index,
mixed $objOrValue )
finalprotectedinherited

Populate array from exportArray1.

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.

◆ getActiveCell()

PhpOffice\PhpSpreadsheet\Style\Supervisor::getActiveCell ( )
inherited

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return values
stringE.g. 'A1'

◆ getActiveSheet()

PhpOffice\PhpSpreadsheet\Style\Supervisor::getActiveSheet ( )
inherited

Get the currently active sheet.

Only used for supervisor.

◆ getHashCode()

PhpOffice\PhpSpreadsheet\Style\Alignment::getHashCode ( )

Get hash code.

Return values
stringHash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

◆ getSelectedCells()

PhpOffice\PhpSpreadsheet\Style\Supervisor::getSelectedCells ( )
inherited

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return values
stringE.g. 'A1'

◆ getSharedComponent()

PhpOffice\PhpSpreadsheet\Style\Alignment::getSharedComponent ( )

Get the shared style component for the currently active cell in currently active sheet.

Only used for style supervisor.

Reimplemented from PhpOffice\PhpSpreadsheet\Style\Supervisor.

◆ getStyleArray()

PhpOffice\PhpSpreadsheet\Style\Alignment::getStyleArray ( array $array)

Build style array from subcomponents.

Reimplemented from PhpOffice\PhpSpreadsheet\Style\Supervisor.

◆ setHorizontal()

PhpOffice\PhpSpreadsheet\Style\Alignment::setHorizontal ( string $horizontalAlignment)

Set Horizontal.

Parameters
string$horizontalAlignmentsee self::HORIZONTAL_*
Return values
$this

◆ setIndent()

PhpOffice\PhpSpreadsheet\Style\Alignment::setIndent ( int $indent)

Set indent.

Return values
$this

◆ setJustifyLastLine()

PhpOffice\PhpSpreadsheet\Style\Alignment::setJustifyLastLine ( bool $justifyLastLine)

Set Justify Last Line.

Return values
$this

◆ setReadOrder()

PhpOffice\PhpSpreadsheet\Style\Alignment::setReadOrder ( int $readOrder)

Set read order.

Return values
$this

◆ setShrinkToFit()

PhpOffice\PhpSpreadsheet\Style\Alignment::setShrinkToFit ( bool $shrink)

Set Shrink to fit.

Return values
$this

◆ setTextRotation()

PhpOffice\PhpSpreadsheet\Style\Alignment::setTextRotation ( int $angleInDegrees)

Set TextRotation.

Return values
$this

◆ setVertical()

PhpOffice\PhpSpreadsheet\Style\Alignment::setVertical ( string $verticalAlignment)

Set Vertical.

Parameters
string$verticalAlignmentsee self::VERTICAL_*
Return values
$this

◆ setWrapText()

PhpOffice\PhpSpreadsheet\Style\Alignment::setWrapText ( bool $wrapped)

Set Wrap Text.

Return values
$this

Member Data Documentation

◆ $parent

Spreadsheet Supervisor PhpOffice\PhpSpreadsheet\Style\Supervisor::$parent
protectedinherited

Parent.

Only used for supervisor.

◆ HORIZONTAL_ALIGNMENT_FOR_HTML

const PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_ALIGNMENT_FOR_HTML
Initial value:
= [
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_DISTRIBUTED => self::HORIZONTAL_JUSTIFY,
]

◆ HORIZONTAL_ALIGNMENT_FOR_XLSX

const PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_ALIGNMENT_FOR_XLSX
Initial value:
= [
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,
]

◆ VERTICAL_ALIGNMENT_FOR_HTML

const PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_ALIGNMENT_FOR_HTML
Initial value:
= [
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,
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

const PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_ALIGNMENT_FOR_XLSX
Initial value:
= [
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,
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,
]

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