Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

ODS file writer. The xml used here is derived from output of LibreOffice 3.6.4 The design is based on Excel writer abstraction by Eloy Lafuente and others.

Copyright: 2006 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1491 lines (59 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 5 classes

MoodleODSWorkbook:: (5 methods):
  __construct()
  add_worksheet()
  add_format()
  close()
  send()

MoodleODSCell:: (0 methods):

MoodleODSWorksheet:: (14 methods):
  __construct()
  write_string()
  write_number()
  write_url()
  write_date()
  write_formula()
  write_blank()
  write()
  set_row()
  set_column()
  hide_gridlines()
  hide_screen_gridlines()
  insert_bitmap()
  merge_cells()

MoodleODSFormat:: (24 methods):
  __construct()
  set_size()
  set_bold()
  set_underline()
  set_italic()
  set_strikeout()
  set_outline()
  set_shadow()
  set_script()
  set_color()
  set_fg_color()
  set_bg_color()
  set_pattern()
  set_text_wrap()
  set_align()
  set_h_align()
  set_v_align()
  set_top()
  set_bottom()
  set_left()
  set_right()
  set_border()
  set_num_format()
  parse_color()

MoodleODSWriter:: (9 methods):
  __construct()
  get_file_content()
  get_ods_content()
  get_ods_mimetype()
  get_ods_settings()
  get_ods_meta()
  get_ods_styles()
  get_ods_manifest()
  get_num_styles()


Class: MoodleODSWorkbook  - X-Ref

ODS workbook abstraction.

__construct($filename)   X-Ref
No description

add_worksheet($name = '')   X-Ref
Create one Moodle Worksheet.

param: string $name Name of the sheet
return: MoodleODSWorksheet

add_format($properties = array()   X-Ref
Create one Moodle Format.

param: array $properties array of properties [name]=value;
return: MoodleODSFormat

close()   X-Ref
Close the Moodle Workbook.


send($filename)   X-Ref
Not required to use.

param: string $filename Name of the downloaded file

Class: MoodleODSCell  - X-Ref

ODS Cell abstraction.

Class: MoodleODSWorksheet  - X-Ref

ODS Worksheet abstraction.

__construct($name, array $worksheets)   X-Ref
Constructs one Moodle Worksheet.

param: string $name The name of the file
param: array $worksheets existing worksheets

write_string($row, $col, $str, $format = null)   X-Ref
Write one string somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: string  $str    The string to write
param: mixed   $format The XF format for the cell

write_number($row, $col, $num, $format = null)   X-Ref
Write one number somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: float   $num    The number to write
param: mixed   $format The XF format for the cell

write_url($row, $col, $url, $format = null)   X-Ref
Write one url somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: string  $url    The url to write
param: mixed   $format The XF format for the cell

write_date($row, $col, $date, $format = null)   X-Ref
Write one date somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: string  $date    The url to write
param: mixed   $format The XF format for the cell

write_formula($row, $col, $formula, $format = null)   X-Ref
Write one formula somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: string  $formula The formula to write
param: mixed   $format The XF format for the cell

write_blank($row, $col, $format = null)   X-Ref
Write one blank somewhere in the worksheet.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: mixed   $format The XF format for the cell

write($row, $col, $token, $format = null)   X-Ref
Write anything somewhere in the worksheet,
type will be automatically detected.

param: integer $row    Zero indexed row
param: integer $col    Zero indexed column
param: mixed   $token  What we are writing
param: mixed   $format The XF format for the cell

set_row($row, $height, $format = null, $hidden = false, $level = 0)   X-Ref
Sets the height (and other settings) of one row.

param: integer $row    The row to set
param: integer $height Height we are giving to the row (null to set just format without setting the height)
param: mixed   $format The optional format we are giving to the row
param: bool    $hidden The optional hidden attribute
param: integer $level  The optional outline level (0-7)

set_column($firstcol, $lastcol, $width, $format = null, $hidden = false, $level = 0)   X-Ref
Sets the width (and other settings) of one column.

param: integer $firstcol first column on the range
param: integer $lastcol  last column on the range
param: integer $width    width to set (null to set just format without setting the width)
param: mixed   $format   The optional format to apply to the columns
param: bool    $hidden   The optional hidden attribute
param: integer $level    The optional outline level (0-7)

hide_gridlines()   X-Ref
Set the option to hide gridlines on the printed page.


hide_screen_gridlines()   X-Ref
Set the option to hide gridlines on the worksheet (as seen on the screen).


insert_bitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)   X-Ref
Insert a 24bit bitmap image in a worksheet.

param: integer $row     The row we are going to insert the bitmap into
param: integer $col     The column we are going to insert the bitmap into
param: string  $bitmap  The bitmap filename
param: integer $x       The horizontal position (offset) of the image inside the cell.
param: integer $y       The vertical position (offset) of the image inside the cell.
param: integer $scale_x The horizontal scale
param: integer $scale_y The vertical scale

merge_cells($first_row, $first_col, $last_row, $last_col)   X-Ref
Merges the area given by its arguments.

param: integer $first_row First row of the area to merge
param: integer $first_col First column of the area to merge
param: integer $last_row  Last row of the area to merge
param: integer $last_col  Last column of the area to merge

Class: MoodleODSFormat  - X-Ref

ODS cell format abstraction.

__construct($properties = array()   X-Ref
Constructs one Moodle Format.

param: array $properties

set_size($size)   X-Ref
Set the size of the text in the format (in pixels).
By default all texts in generated sheets are 10pt.

param: integer $size Size of the text (in points)

set_bold($weight = 1)   X-Ref
Set weight of the format.

param: integer $weight Weight for the text, 0 maps to 400 (normal text),

set_underline($underline = 1)   X-Ref
Set underline of the format.

param: integer $underline The value for underline. Possible values are:

set_italic()   X-Ref
Set italic of the format.


set_strikeout()   X-Ref
Set strikeout of the format


set_outline()   X-Ref
Set outlining of the format.


set_shadow()   X-Ref
Set shadow of the format.


set_script($script)   X-Ref
Set the script of the text.

param: integer $script The value for script type. Possible values are:

set_color($color)   X-Ref
Set color of the format.

param: mixed $color either a string (like 'blue'), or an integer (range is [8...63])

set_fg_color($color)   X-Ref
Not used.

param: mixed $color

set_bg_color($color)   X-Ref
Set background color of the cell.

param: mixed $color either a string (like 'blue'), or an integer (range is [8...63])

set_pattern($pattern=1)   X-Ref
Set the cell fill pattern.

param: integer

set_text_wrap()   X-Ref
Set text wrap of the format


set_align($location)   X-Ref
Set the cell alignment of the format.

param: string $location alignment for the cell ('left', 'right', 'justify', etc...)

set_h_align($location)   X-Ref
Set the cell horizontal alignment of the format.

param: string $location alignment for the cell ('left', 'right', 'justify', etc...)

set_v_align($location)   X-Ref
Set the cell vertical alignment of the format.

param: string $location alignment for the cell ('top', 'bottom', 'center', 'justify')

set_top($style)   X-Ref
Set the top border of the format.

param: integer $style style for the cell. 1 => thin, 2 => thick

set_bottom($style)   X-Ref
Set the bottom border of the format.

param: integer $style style for the cell. 1 => thin, 2 => thick

set_left($style)   X-Ref
Set the left border of the format.

param: integer $style style for the cell. 1 => thin, 2 => thick

set_right($style)   X-Ref
Set the right border of the format.

param: integer $style style for the cell. 1 => thin, 2 => thick

set_border($style)   X-Ref
Set cells borders to the same style

param: integer $style style to apply for all cell borders. 1 => thin, 2 => thick.

set_num_format($num_format)   X-Ref
Set the numerical format of the format.
It can be date, time, currency, etc...

param: mixed $num_format The numeric format

parse_color($color)   X-Ref
Standardise colour name.

param: mixed $color name of the color (i.e.: 'blue', 'red', etc..), or an integer (range is [8...63]).
return: string the RGB color value

Class: MoodleODSWriter  - X-Ref

ODS file writer.

__construct(array $worksheets)   X-Ref
No description

get_file_content()   X-Ref
Fetch the file ocntnet for the ODS.

return: string

get_ods_content()   X-Ref
No description

get_ods_mimetype()   X-Ref
No description

get_ods_settings()   X-Ref
No description

get_ods_meta()   X-Ref
No description

get_ods_styles()   X-Ref
No description

get_ods_manifest()   X-Ref
No description

get_num_styles()   X-Ref
No description