Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

File Size: 1869 lines (62 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Html:: (63 methods):
  __construct()
  save()
  generateHtmlAll()
  setEditHtmlCallback()
  mapVAlign()
  mapHAlign()
  mapBorderStyle()
  getSheetIndex()
  setSheetIndex()
  getGenerateSheetNavigationBlock()
  setGenerateSheetNavigationBlock()
  writeAllSheets()
  generateMeta()
  generateHTMLHeader()
  generateSheetPrep()
  generateSheetStarts()
  generateSheetTags()
  generateSheetData()
  generateNavigation()
  extendRowsForCharts()
  extendRowsForChartsAndImages()
  winFileToUrl()
  writeImageInCell()
  writeChartInCell()
  getChartCaption()
  generateStyles()
  buildCssRowHeights()
  buildCssPerSheet()
  buildCSS()
  createCSSStyle()
  createCSSStyleAlignment()
  createCSSStyleFont()
  createCSSStyleBorders()
  createCSSStyleBorder()
  createCSSStyleFill()
  generateHTMLFooter()
  generateTableTagInline()
  generateTableTag()
  generateTableHeader()
  generateTableFooter()
  generateRowStart()
  generateRowCellCss()
  generateRowCellDataValueRich()
  generateRowCellDataValue()
  generateRowCellData()
  generateRowIncludeCharts()
  generateRowSpans()
  generateRowWriteCell()
  generateRow()
  assembleCSS()
  getImagesRoot()
  setImagesRoot()
  getEmbedImages()
  setEmbedImages()
  getUseInlineCss()
  setUseInlineCss()
  getUseEmbeddedCSS()
  setUseEmbeddedCSS()
  formatColor()
  calculateSpans()
  calculateSpansOmitRows()
  writeComment()
  generatePageDeclarations()


Class: Html  - X-Ref

__construct(Spreadsheet $spreadsheet)   X-Ref
Create a new HTML.


save($pFilename)   X-Ref
Save Spreadsheet to file.

param: resource|string $pFilename

generateHtmlAll()   X-Ref
Save Spreadsheet as html to variable.

return: string

setEditHtmlCallback(?callable $callback)   X-Ref
Set a callback to edit the entire HTML.

The callback must accept the HTML as string as first parameter,
and it must return the edited HTML as string.

mapVAlign($vAlign)   X-Ref
Map VAlign.

param: string $vAlign Vertical alignment
return: string

mapHAlign($hAlign)   X-Ref
Map HAlign.

param: string $hAlign Horizontal alignment
return: string

mapBorderStyle($borderStyle)   X-Ref
Map border style.

param: int $borderStyle Sheet index
return: string

getSheetIndex()   X-Ref
Get sheet index.

return: int

setSheetIndex($pValue)   X-Ref
Set sheet index.

param: int $pValue Sheet index
return: $this

getGenerateSheetNavigationBlock()   X-Ref
Get sheet index.

return: bool

setGenerateSheetNavigationBlock($pValue)   X-Ref
Set sheet index.

param: bool $pValue Flag indicating whether the sheet navigation block should be generated or not
return: $this

writeAllSheets()   X-Ref
Write all sheets (resets sheetIndex to NULL).

return: $this

generateMeta($val, $desc)   X-Ref
No description

generateHTMLHeader($pIncludeStyles = false)   X-Ref
Generate HTML header.

param: bool $pIncludeStyles Include styles?
return: string

generateSheetPrep()   X-Ref
No description

generateSheetStarts($sheet, $rowMin)   X-Ref
No description

generateSheetTags($row, $theadStart, $theadEnd, $tbodyStart)   X-Ref
No description

generateSheetData()   X-Ref
Generate sheet data.

return: string

generateNavigation()   X-Ref
Generate sheet tabs.

return: string

extendRowsForCharts(Worksheet $pSheet, int $row)   X-Ref
Extend Row if chart is placed after nominal end of row.
This code should be exercised by sample:
Chart/32_Chart_read_write_PDF.php.
However, that test is suppressed due to out-of-date
Jpgraph code issuing warnings. So, don't measure
code coverage for this function till that is fixed.

param: Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
param: int $row Row to check for charts
return: array

extendRowsForChartsAndImages(Worksheet $pSheet, int $row)   X-Ref
No description

winFileToUrl($filename)   X-Ref
Convert Windows file name to file protocol URL.

param: string $filename file name on local system
return: string

writeImageInCell(Worksheet $pSheet, $coordinates)   X-Ref
Generate image tag in cell.

param: Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
param: string $coordinates Cell coordinates
return: string

writeChartInCell(Worksheet $pSheet, $coordinates)   X-Ref
Generate chart tag in cell.
This code should be exercised by sample:
Chart/32_Chart_read_write_PDF.php.
However, that test is suppressed due to out-of-date
Jpgraph code issuing warnings. So, don't measure
code coverage for this function till that is fixed.

param: Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
param: string $coordinates Cell coordinates
return: string

getChartCaption($cap)   X-Ref
Extend Row if chart is placed after nominal end of row.
This code should be exercised by sample:
Chart/32_Chart_read_write_PDF.php.
However, that test is suppressed due to out-of-date
Jpgraph code issuing warnings. So, don't measure
code coverage for this function till that is fixed.
Caption is described in documentation as fixed,
but in 32_Chart it is somehow an array of RichText.

param: mixed $cap
return: string

generateStyles($generateSurroundingHTML = true)   X-Ref
Generate CSS styles.

param: bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>)
return: string

buildCssRowHeights(Worksheet $sheet, array &$css, int $sheetIndex)   X-Ref
No description

buildCssPerSheet(Worksheet $sheet, array &$css)   X-Ref
No description

buildCSS($generateSurroundingHTML = true)   X-Ref
Build CSS styles.

param: bool $generateSurroundingHTML Generate surrounding HTML style? (html { })
return: array

createCSSStyle(Style $pStyle)   X-Ref
Create CSS style.

return: array

createCSSStyleAlignment(Alignment $pStyle)   X-Ref
Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Alignment).

param: Alignment $pStyle \PhpOffice\PhpSpreadsheet\Style\Alignment
return: array

createCSSStyleFont(Font $pStyle)   X-Ref
Create CSS style (\PhpOffice\PhpSpreadsheet\Style\Font).

return: array

createCSSStyleBorders(Borders $pStyle)   X-Ref
Create CSS style (Borders).

param: Borders $pStyle Borders
return: array

createCSSStyleBorder(Border $pStyle)   X-Ref
Create CSS style (Border).

param: Border $pStyle Border
return: string

createCSSStyleFill(Fill $pStyle)   X-Ref
Create CSS style (Fill).

param: Fill $pStyle Fill
return: array

generateHTMLFooter()   X-Ref
Generate HTML footer.


generateTableTagInline($pSheet, $id)   X-Ref
No description

generateTableTag($pSheet, $id, &$html, $sheetIndex)   X-Ref
No description

generateTableHeader($pSheet, $showid = true)   X-Ref
Generate table header.

param: Worksheet $pSheet The worksheet for the table we are writing
param: bool $showid whether or not to add id to table tag
return: string

generateTableFooter()   X-Ref
Generate table footer.


generateRowStart(Worksheet $pSheet, $sheetIndex, $pRow)   X-Ref
Generate row start.

param: Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
param: int $sheetIndex Sheet index (0-based)
param: int $pRow row number
return: string

generateRowCellCss($pSheet, $cellAddress, $pRow, $colNum)   X-Ref
No description

generateRowCellDataValueRich($cell, &$cellData)   X-Ref
No description

generateRowCellDataValue($pSheet, $cell, &$cellData)   X-Ref
No description

generateRowCellData($pSheet, $cell, &$cssClass, $cellType)   X-Ref
No description

generateRowIncludeCharts($pSheet, $coordinate)   X-Ref
No description

generateRowSpans($html, $rowSpan, $colSpan)   X-Ref
No description

generateRowWriteCell(&$html, $pSheet, $coordinate, $cellType, $cellData, $colSpan, $rowSpan, $cssClass, $colNum, $sheetIndex, $pRow)   X-Ref
No description

generateRow(Worksheet $pSheet, array $pValues, $pRow, $cellType)   X-Ref
Generate row.

param: Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
param: array $pValues Array containing cells in a row
param: int $pRow Row number (0-based)
param: string $cellType eg: 'td'
return: string

assembleCSS(array $pValue = [])   X-Ref
Takes array where of CSS properties / values and converts to CSS string.

return: string

getImagesRoot()   X-Ref
Get images root.

return: string

setImagesRoot($pValue)   X-Ref
Set images root.

param: string $pValue
return: $this

getEmbedImages()   X-Ref
Get embed images.

return: bool

setEmbedImages($pValue)   X-Ref
Set embed images.

param: bool $pValue
return: $this

getUseInlineCss()   X-Ref
Get use inline CSS?

return: bool

setUseInlineCss($pValue)   X-Ref
Set use inline CSS?

param: bool $pValue
return: $this

getUseEmbeddedCSS()   X-Ref
Get use embedded CSS?

return: bool

setUseEmbeddedCSS($pValue)   X-Ref
Set use embedded CSS?

param: bool $pValue
return: $this

formatColor($pValue, $pFormat)   X-Ref
Add color to formatted string as inline style.

param: string $pValue Plain formatted value without color
param: string $pFormat Format code
return: string

calculateSpans()   X-Ref
Calculate information about HTML colspan and rowspan which is not always the same as Excel's.


calculateSpansOmitRows($sheet, $sheetIndex, $candidateSpannedRow)   X-Ref
No description

writeComment(Worksheet $pSheet, $coordinate)   X-Ref
Write a comment in the same format as LibreOffice.

param: string $coordinate
return: string

generatePageDeclarations($generateSurroundingHTML)   X-Ref
Generate @page declarations.

param: bool $generateSurroundingHTML
return: string