Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(no description)

File Size: 1857 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()
  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()
  getOrientation()
  generatePageDeclarations()


Class: Html  - X-Ref

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


save($filename, int $flags = 0)   X-Ref
Save Spreadsheet to file.

param: resource|string $filename

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.

return: string
param: string $vAlign Vertical alignment

mapHAlign($hAlign)   X-Ref
Map HAlign.

return: string
param: string $hAlign Horizontal alignment

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

return: string
param: int $borderStyle Sheet index

getSheetIndex()   X-Ref
Get sheet index.


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

return: $this
param: int $sheetIndex Sheet index

getGenerateSheetNavigationBlock()   X-Ref
Get sheet index.

return: bool

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

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

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

return: $this

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

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

return: string
param: bool $includeStyles Include styles?

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 $worksheet, 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.

return: array
param: int $row Row to check for charts

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

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

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

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

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

writeChartInCell(Worksheet $worksheet, string $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.


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

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

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.

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

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

return: array

createCSSStyleAlignment(Alignment $alignment)   X-Ref
Create CSS style.

return: array

createCSSStyleFont(Font $font)   X-Ref
Create CSS style.

return: array

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

return: array
param: Borders $borders Borders

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

return: string
param: Border $border Border

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

return: array
param: Fill $fill Fill

generateHTMLFooter()   X-Ref
Generate HTML footer.


generateTableTagInline(Worksheet $worksheet, $id)   X-Ref
No description

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

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

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

generateTableFooter()   X-Ref
Generate table footer.


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

return: string
param: int $sheetIndex Sheet index (0-based)
param: int $row row number

generateRowCellCss(Worksheet $worksheet, $cellAddress, $row, $columnNumber)   X-Ref
No description

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

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

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

generateRowIncludeCharts(Worksheet $worksheet, $coordinate)   X-Ref
No description

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

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

generateRow(Worksheet $worksheet, array $values, $row, $cellType)   X-Ref
Generate row.

return: string
param: array $values Array containing cells in a row
param: int $row Row number (0-based)
param: string $cellType eg: 'td'

assembleCSS(array $values = [])   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($imagesRoot)   X-Ref
Set images root.

return: $this
param: string $imagesRoot

getEmbedImages()   X-Ref
Get embed images.

return: bool

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

return: $this
param: bool $embedImages

getUseInlineCss()   X-Ref
Get use inline CSS?

return: bool

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

return: $this
param: bool $useInlineCss

getUseEmbeddedCSS()   X-Ref
Get use embedded CSS?

return: bool

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

return: $this
param: bool $useEmbeddedCSS

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

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

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 $worksheet, $coordinate)   X-Ref
Write a comment in the same format as LibreOffice.

return: string
param: string $coordinate

getOrientation()   X-Ref
No description

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

return: string
param: bool $generateSurroundingHTML