PHP Класс PHPRtfLite_Table

Автор: Denis Slaveckij ([email protected])
Автор: Steffen Zeidler ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
__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

Защищенные методы

Метод Описание
renderRowCells ( PHPRtfLite_Table_Row $row ) renders row cells

Приватные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

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

addColumn() публичный Метод

adds column
public addColumn ( float $width ) : PHPRtfLite_Table_Column
$width float column width
Результат PHPRtfLite_Table_Column

addColumnsList() публичный Метод

adds list of columns
public addColumnsList ( $columnWidths )

addImageFromStringToCell() публичный Метод

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.
Результат PHPRtfLite_Image

addImageToCell() публичный Метод

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.
Результат PHPRtfLite_Image

addRow() публичный Метод

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.
Результат PHPRtfLite_Table_Row

addRowList() публичный Метод

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() публичный Метод

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() публичный Метод

returns true, if column index is valid
public checkColumnIndex ( integer $colIndex ) : boolean
$colIndex integer
Результат boolean

checkIfCellExists() публичный Метод

returns true, if rowIndex and columnIndex do exists in table
public checkIfCellExists ( integer $rowIndex, integer $columnIndex ) : boolean
$rowIndex integer
$columnIndex integer
Результат boolean

checkRowIndex() публичный Метод

returns true, if row index is valid
public checkRowIndex ( integer $rowIndex ) : boolean
$rowIndex integer
Результат boolean

free() публичный Метод

public free ( )

getAlignment() публичный Метод

gets alignment
public getAlignment ( ) : string
Результат string

getCell() публичный Метод

gets the instance of cell
public getCell ( integer $rowIndex, integer $columnIndex ) : PHPRtfLite_Table_Cell
$rowIndex integer
$columnIndex integer
Результат PHPRtfLite_Table_Cell

getColumn() публичный Метод

gets column
public getColumn ( integer $colIndex ) : PHPRtfLite_Table_Column
$colIndex integer
Результат PHPRtfLite_Table_Column

getColumns() публичный Метод

gets table columns
public getColumns ( ) : PHPRtfLite_Table_Column[]
Результат PHPRtfLite_Table_Column[]

getColumnsCount() публичный Метод

gets number of columns in table
public getColumnsCount ( ) : integer
Результат integer

getContainer() публичный Метод

gets rtf container instance
public getContainer ( ) : PHPRtfLite_Container
Результат PHPRtfLite_Container

getLeftPosition() публичный Метод

gets left position of table
public getLeftPosition ( ) : float
Результат float

getNestDepth() публичный Метод

gets nested depth
public getNestDepth ( ) : integer
Результат integer

getPreventEmptyParagraph() публичный Метод

returns true, if no empty paragraph should be added after table
public getPreventEmptyParagraph ( ) : boolean
Результат boolean

getRow() публичный Метод

gets row instance
public getRow ( integer $rowIndex ) : PHPRtfLite_Table_Row
$rowIndex integer
Результат PHPRtfLite_Table_Row

getRows() публичный Метод

gets table rows
public getRows ( ) : PHPRtfLite_Table_Row[]
Результат PHPRtfLite_Table_Row[]

getRowsCount() публичный Метод

gets number of rows in table
public getRowsCount ( ) : integer
Результат integer

getRtf() публичный Метод

gets rtf instance
public getRtf ( ) : PHPRtfLite
Результат PHPRtfLite

isFirstRowHeader() публичный Метод

Returns true, if first row should be used as header. First row will be repeated at the top of each page.
public isFirstRowHeader ( ) : boolean
Результат boolean

isNestedTable() публичный Метод

checks, if table is a nested table
public isNestedTable ( ) : boolean
Результат boolean

isPreventPageBreak() публичный Метод

returns true, if a table should not be splited by a page break
public isPreventPageBreak ( ) : boolean
Результат boolean

mergeCellRange() публичный Метод

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() публичный Метод

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

render() публичный Метод

gets rtf code for table
public render ( ) : string
Результат string rtf code

renderRowCells() защищенный Метод

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

renderRowDefinition() публичный Метод

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

rotateCellRange() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

Устаревший: 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() публичный Метод

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

setFontForCellRange() публичный Метод

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() публичный Метод

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

setPreventPageBreak() публичный Метод

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

setTextAlignmentForCellRange() публичный Метод

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() публичный Метод

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() публичный Метод

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.
Результат PHPRtfLite_Element

Описание свойств

$_alignment защищенное свойство

protected string $_alignment
Результат string

$_columns защищенное свойство

array of PHPRtfLite_Table_Column instances
protected PHPRtfLite_Table_Column[] $_columns
Результат PHPRtfLite_Table_Column[]

$_container защищенное свойство

protected PHPRtfLite_Container $_container
Результат PHPRtfLite_Container

$_firstRowIsHeader защищенное свойство

protected bool $_firstRowIsHeader
Результат boolean

$_leftPosition защищенное свойство

protected int $_leftPosition
Результат integer

$_nestDepth защищенное свойство

.. and so on ..
protected int $_nestDepth
Результат integer

$_preventEmptyParagraph защищенное свойство

flag for preventing an empty paragraph after table
protected bool $_preventEmptyParagraph
Результат boolean

$_preventPageBreak защищенное свойство

protected bool $_preventPageBreak
Результат boolean

$_repeatFirstRowHeader защищенное свойство

protected bool $_repeatFirstRowHeader
Результат boolean

$_rows защищенное свойство

array of PHPRtfLite_Table_Row instances
protected PHPRtfLite_Table_Row[] $_rows
Результат PHPRtfLite_Table_Row[]