PHP Class PHPRtfLite_Table

Author: Denis Slaveckij ([email protected])
Author: Steffen Zeidler ([email protected])
Afficher le fichier Open project: phprtflite/phprtflite Class Usage Examples

Protected Properties

Свойство Type Description
$_alignment string
$_columns PHPRtfLite_Table_Column[] array of PHPRtfLite_Table_Column instances
$_container PHPRtfLite_Container
$_firstRowIsHeader boolean
$_leftPosition integer
$_nestDepth integer .. and so on ..
$_preventEmptyParagraph boolean flag for preventing an empty paragraph after table
$_preventPageBreak boolean
$_repeatFirstRowHeader boolean
$_rows PHPRtfLite_Table_Row[] array of PHPRtfLite_Table_Row instances

Méthodes publiques

Méthode Description
__construct ( PHPRtfLite_Container_Base $container, string $alignment = self::ALIGN_LEFT, integer $nestDepth = 1 ) constructor
addColumn ( float $width ) : PHPRtfLite_Table_Column adds column
addColumnsList ( $columnWidths ) adds list of columns
addImageFromStringToCell ( integer $rowIndex, integer $columnIndex, string $imageString, string $type, PHPRtfLite_ParFormat $parFormat = null, float $width = null, float $height = null ) : PHPRtfLite_Image adds image to cell
addImageToCell ( integer $rowIndex, integer $columnIndex, string $file, PHPRtfLite_ParFormat $parFormat = null, float $width = null, float $height = null ) : PHPRtfLite_Image adds image to cell
addRow ( float $height = null ) : PHPRtfLite_Table_Row adds row
addRowList ( array $heights ) adds list of rows to a table.
addRows ( integer $rowCnt, float $height = null ) adds rows
checkColumnIndex ( integer $colIndex ) : boolean returns true, if column index is valid
checkIfCellExists ( integer $rowIndex, integer $columnIndex ) : boolean returns true, if rowIndex and columnIndex do exists in table
checkRowIndex ( integer $rowIndex ) : boolean returns true, if row index is valid
free ( )
getAlignment ( ) : string gets alignment
getCell ( integer $rowIndex, integer $columnIndex ) : PHPRtfLite_Table_Cell gets the instance of cell
getColumn ( integer $colIndex ) : PHPRtfLite_Table_Column gets column
getColumns ( ) : PHPRtfLite_Table_Column[] gets table columns
getColumnsCount ( ) : integer gets number of columns in table
getContainer ( ) : PHPRtfLite_Container gets rtf container instance
getLeftPosition ( ) : float gets left position of table
getNestDepth ( ) : integer gets nested depth
getPreventEmptyParagraph ( ) : boolean returns true, if no empty paragraph should be added after table
getRow ( integer $rowIndex ) : PHPRtfLite_Table_Row gets row instance
getRows ( ) : PHPRtfLite_Table_Row[] gets table rows
getRowsCount ( ) : integer gets number of rows in table
getRtf ( ) : PHPRtfLite gets rtf instance
isFirstRowHeader ( ) : boolean Returns true, if first row should be used as header. First row will be repeated at the top of each page.
isNestedTable ( ) : boolean checks, if table is a nested table
isPreventPageBreak ( ) : boolean returns true, if a table should not be splited by a page break
mergeCellRange ( integer $startRow, integer $startColumn, integer $endRow, integer $endColumn ) merges cells of a given cell range
preventEmptyParagraph ( $value = true ) prevents adding an empty paragraph after table
render ( ) : string gets rtf code for table
renderRowDefinition ( PHPRtfLite_Table_Row $row ) renders row definition
rotateCellRange ( string $rotateTo, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) rotates cells of a given cell range
setBackgroundForCellRange ( string $backgroundColor, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) sets background color of cells of a given cell range
setBorderForCellRange ( PHPRtfLite_Border $border, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) sets border to cells of a given cell range
setBordersForCellRange ( PHPRtfLite_Border_Format $borderFormat, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null, boolean $left = true, boolean $top = true, boolean $right = true, boolean $bottom = true )
setFirstRowAsHeader ( ) Sets first row as header row. First row will be repeated at the top of each page.
setFontForCellRange ( PHPRtfLite_Font $font, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) sets font to empty cells of a given cell range
setLeftPosition ( float $leftPosition ) sets left position of table
setPreventPageBreak ( ) Sets that table won't be splited by a page break. By default page break splits table.
setTextAlignmentForCellRange ( string $alignment, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) sets alignments to empty cells of a given cell range
setVerticalAlignmentForCellRange ( string $verticalAlignment, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null ) sets vertical alignment to cells of a given cell range
writeToCell ( integer $rowIndex, integer $columnIndex, string $text, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null, boolean $convertTagsToRtf = true ) : PHPRtfLite_Element writes text to cell

Méthodes protégées

Méthode Description
renderRowCells ( PHPRtfLite_Table_Row $row ) renders row cells

Private Methods

Méthode Description
getCellsByCellRange ( integer $startRow, integer $startColumn, integer $endRow, integer $endColumn ) : PHPRtfLite_Table_Cell[]
getValidCellRange ( integer $startRow, integer $startColumn, integer $endRow, integer $endColumn ) : array corrects cell range to be valid

Method Details

__construct() public méthode

constructor
public __construct ( PHPRtfLite_Container_Base $container, string $alignment = self::ALIGN_LEFT, integer $nestDepth = 1 )
$container PHPRtfLite_Container_Base
$alignment string
$nestDepth integer

addColumn() public méthode

adds column
public addColumn ( float $width ) : PHPRtfLite_Table_Column
$width float column width
Résultat PHPRtfLite_Table_Column

addColumnsList() public méthode

adds list of columns
public addColumnsList ( $columnWidths )

addImageFromStringToCell() public méthode

adds image to cell
public addImageFromStringToCell ( integer $rowIndex, integer $columnIndex, string $imageString, string $type, PHPRtfLite_ParFormat $parFormat = null, float $width = null, float $height = null ) : PHPRtfLite_Image
$rowIndex integer row index of cell
$columnIndex integer column index of cell
$imageString string image source code
$type string image type (GD, WMF)
$parFormat PHPRtfLite_ParFormat paragraph format
$width float if null image is displayed by it's original height.
$height float if null image is displayed by it's original width. If boths parameters are null, image is displayed as it is.
Résultat PHPRtfLite_Image

addImageToCell() public méthode

adds image to cell
public addImageToCell ( integer $rowIndex, integer $columnIndex, string $file, PHPRtfLite_ParFormat $parFormat = null, float $width = null, float $height = null ) : PHPRtfLite_Image
$rowIndex integer row index of cell
$columnIndex integer column index of cell
$file string image file.
$parFormat PHPRtfLite_ParFormat paragraph format
$width float if null image is displayed by it's original height.
$height float if null image is displayed by it's original width. If boths parameters are null, image is displayed as it is.
Résultat PHPRtfLite_Image

addRow() public méthode

adds row
public addRow ( float $height = null ) : PHPRtfLite_Table_Row
$height float row height. When 0, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.
Résultat PHPRtfLite_Table_Row

addRowList() public méthode

adds list of rows to a table.
public addRowList ( array $heights )
$heights array array of heights for each row to add. When height is null, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.

addRows() public méthode

adds rows
public addRows ( integer $rowCnt, float $height = null )
$rowCnt integer
$height float row height. When null, the height is sufficient for all the text in the line; when positive, the height is guaranteed to be at least the specified height; when negative, the absolute value of the height is used, regardless of the height of the text in the line.

checkColumnIndex() public méthode

returns true, if column index is valid
public checkColumnIndex ( integer $colIndex ) : boolean
$colIndex integer
Résultat boolean

checkIfCellExists() public méthode

returns true, if rowIndex and columnIndex do exists in table
public checkIfCellExists ( integer $rowIndex, integer $columnIndex ) : boolean
$rowIndex integer
$columnIndex integer
Résultat boolean

checkRowIndex() public méthode

returns true, if row index is valid
public checkRowIndex ( integer $rowIndex ) : boolean
$rowIndex integer
Résultat boolean

free() public méthode

public free ( )

getAlignment() public méthode

gets alignment
public getAlignment ( ) : string
Résultat string

getCell() public méthode

gets the instance of cell
public getCell ( integer $rowIndex, integer $columnIndex ) : PHPRtfLite_Table_Cell
$rowIndex integer
$columnIndex integer
Résultat PHPRtfLite_Table_Cell

getColumn() public méthode

gets column
public getColumn ( integer $colIndex ) : PHPRtfLite_Table_Column
$colIndex integer
Résultat PHPRtfLite_Table_Column

getColumns() public méthode

gets table columns
public getColumns ( ) : PHPRtfLite_Table_Column[]
Résultat PHPRtfLite_Table_Column[]

getColumnsCount() public méthode

gets number of columns in table
public getColumnsCount ( ) : integer
Résultat integer

getContainer() public méthode

gets rtf container instance
public getContainer ( ) : PHPRtfLite_Container
Résultat PHPRtfLite_Container

getLeftPosition() public méthode

gets left position of table
public getLeftPosition ( ) : float
Résultat float

getNestDepth() public méthode

gets nested depth
public getNestDepth ( ) : integer
Résultat integer

getPreventEmptyParagraph() public méthode

returns true, if no empty paragraph should be added after table
public getPreventEmptyParagraph ( ) : boolean
Résultat boolean

getRow() public méthode

gets row instance
public getRow ( integer $rowIndex ) : PHPRtfLite_Table_Row
$rowIndex integer
Résultat PHPRtfLite_Table_Row

getRows() public méthode

gets table rows
public getRows ( ) : PHPRtfLite_Table_Row[]
Résultat PHPRtfLite_Table_Row[]

getRowsCount() public méthode

gets number of rows in table
public getRowsCount ( ) : integer
Résultat integer

getRtf() public méthode

gets rtf instance
public getRtf ( ) : PHPRtfLite
Résultat PHPRtfLite

isFirstRowHeader() public méthode

Returns true, if first row should be used as header. First row will be repeated at the top of each page.
public isFirstRowHeader ( ) : boolean
Résultat boolean

isNestedTable() public méthode

checks, if table is a nested table
public isNestedTable ( ) : boolean
Résultat boolean

isPreventPageBreak() public méthode

returns true, if a table should not be splited by a page break
public isPreventPageBreak ( ) : boolean
Résultat boolean

mergeCellRange() public méthode

merges cells of a given cell range
public mergeCellRange ( integer $startRow, integer $startColumn, integer $endRow, integer $endColumn )
$startRow integer start row
$startColumn integer start column
$endRow integer end row
$endColumn integer end column

preventEmptyParagraph() public méthode

prevents adding an empty paragraph after table
public preventEmptyParagraph ( $value = true )

render() public méthode

gets rtf code for table
public render ( ) : string
Résultat string rtf code

renderRowCells() protected méthode

renders row cells
protected renderRowCells ( PHPRtfLite_Table_Row $row )
$row PHPRtfLite_Table_Row

renderRowDefinition() public méthode

renders row definition
public renderRowDefinition ( PHPRtfLite_Table_Row $row )
$row PHPRtfLite_Table_Row

rotateCellRange() public méthode

rotates cells of a given cell range
public rotateCellRange ( string $rotateTo, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$rotateTo string direction of rotation
Possible values (represented by PHPRtfLite_Table_Cell::ROTATE_*):
PHPRtfLite_Table_Cell::ROTATE_RIGHT => 'right'
PHPRtfLite_Table_Cell::ROTATE_LEFT => 'left'
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then rotation is set only to the row range.
$endColumn integer end column, if null, then rotation is set just to the column range.

setBackgroundForCellRange() public méthode

sets background color of cells of a given cell range
public setBackgroundForCellRange ( string $backgroundColor, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$backgroundColor string background color
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then rotation is set only to the row range.
$endColumn integer end column, if null, then rotation is set just to the column range.

setBorderForCellRange() public méthode

sets border to cells of a given cell range
public setBorderForCellRange ( PHPRtfLite_Border $border, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$border PHPRtfLite_Border border
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then border is set only to the row range.
$endColumn integer end column, if null, then border is set just to the column range.

setBordersForCellRange() public méthode

Deprecation: use setBorderForCellRange() instead
public setBordersForCellRange ( PHPRtfLite_Border_Format $borderFormat, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null, boolean $left = true, boolean $top = true, boolean $right = true, boolean $bottom = true )
$borderFormat PHPRtfLite_Border_Format border format
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then border is set only to the row range.
$endColumn integer end column, if null, then border is set just to the column range.
$left boolean if false, left border is not set (default true)
$top boolean if false, top border is not set (default true)
$right boolean if false, right border is not set (default true)
$bottom boolean if false, bottom border is not set (default true)

setFirstRowAsHeader() public méthode

Sets first row as header row. First row will be repeated at the top of each page.
public setFirstRowAsHeader ( )

setFontForCellRange() public méthode

sets font to empty cells of a given cell range
public setFontForCellRange ( PHPRtfLite_Font $font, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$font PHPRtfLite_Font font for empty cells. The method PHPRtfLite_Table_Cell->writeToCell() overrides it with another PHPRtfLite_Font.
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then font is set only to the row range.
$endColumn integer end column, if null, then font is set just to the column range.

setLeftPosition() public méthode

sets left position of table
public setLeftPosition ( float $leftPosition )
$leftPosition float left position of table.

setPreventPageBreak() public méthode

Sets that table won't be splited by a page break. By default page break splits table.
public setPreventPageBreak ( )

setTextAlignmentForCellRange() public méthode

sets alignments to empty cells of a given cell range
public setTextAlignmentForCellRange ( string $alignment, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$alignment string alignment of cell. The method PHPRtfLite_Table_Cell->writeToCell() overrides it with PHPRtfLite_ParFormat alignment.
Alignment is represented by class constants PHPRtfLite_Container::TEXT_ALIGN_*
Possible values:
PHPRtfLite_Container::TEXT_ALIGN_LEFT => 'left' - left alignment
PHPRtfLite_Container::TEXT_ALIGN_RIGHT => 'right' - right alignment
PHPRtfLite_Container::TEXT_ALIGN_CENTER => 'center' - center alignment
PHPRtfLite_Container::TEXT_ALIGN_JUSTIFY => 'justify' - justify alignment
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then text alignment is set only to the row range.
$endColumn integer end column, if null, then text alignment is set just to the column range.

setVerticalAlignmentForCellRange() public méthode

sets vertical alignment to cells of a given cell range
public setVerticalAlignmentForCellRange ( string $verticalAlignment, integer $startRow, integer $startColumn, integer $endRow = null, integer $endColumn = null )
$verticalAlignment string Vertical alignment of cell (default top). Represented by PHPRtfLite_Container::VERTICAL_ALIGN_*
Possible values:
PHPRtfLite_Container::VERTICAL_ALIGN_TOP => 'top' - top alignment;
PHPRtfLite_Container::VERTICAL_ALIGN_CENTER => 'center' - center alignment;
PHPRtfLite_Container::VERTICAL_ALIGN_BOTTOM => 'bottom' - bottom alignment.
$startRow integer start row
$startColumn integer start column
$endRow integer end row, if null, then vertical alignment is set only to the row range.
$endColumn integer end column, if null, then vertical alignment is set just to the column range.

writeToCell() public méthode

writes text to cell
public writeToCell ( integer $rowIndex, integer $columnIndex, string $text, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null, boolean $convertTagsToRtf = true ) : PHPRtfLite_Element
$rowIndex integer row index of cell
$columnIndex integer column index of cell
$text string Text. Also you can use html style tags. @see PHPRtfLite_Container#writeText()
$font PHPRtfLite_Font Font of text
$parFormat PHPRtfLite_ParFormat Paragraph format
$convertTagsToRtf boolean If false, then html style tags are not replaced with rtf code.
Résultat PHPRtfLite_Element

Property Details

$_alignment protected_oe property

protected string $_alignment
Résultat string

$_columns protected_oe property

array of PHPRtfLite_Table_Column instances
protected PHPRtfLite_Table_Column[] $_columns
Résultat PHPRtfLite_Table_Column[]

$_container protected_oe property

protected PHPRtfLite_Container $_container
Résultat PHPRtfLite_Container

$_firstRowIsHeader protected_oe property

protected bool $_firstRowIsHeader
Résultat boolean

$_leftPosition protected_oe property

protected int $_leftPosition
Résultat integer

$_nestDepth protected_oe property

.. and so on ..
protected int $_nestDepth
Résultat integer

$_preventEmptyParagraph protected_oe property

flag for preventing an empty paragraph after table
protected bool $_preventEmptyParagraph
Résultat boolean

$_preventPageBreak protected_oe property

protected bool $_preventPageBreak
Résultat boolean

$_repeatFirstRowHeader protected_oe property

protected bool $_repeatFirstRowHeader
Résultat boolean

$_rows protected_oe property

array of PHPRtfLite_Table_Row instances
protected PHPRtfLite_Table_Row[] $_rows
Résultat PHPRtfLite_Table_Row[]