<spreadsheet>
<spreadsheet> is a General Operator
component that renders a basic embedded spreadsheet tool.
Its cells are selected through cells: $ss.cells[1][2] is the cell in row 1 and column 2. An index on the spreadsheet itself, such as $ss[1], names nothing.
Attributes and Properties
Attributes for <spreadsheet>
Other (10)
boolean. Default value: true. Header labels for the columns.
integer. Default value: 0. Number of left columns fixed in place when scrolling.
integer. Default value: 0. Number of top rows fixed in place when scrolling.
componentSize. Display height of the spreadsheet.
number. Default value: 4. Minimum number of columns displayed.
number. Default value: 4. Minimum number of rows displayed.
boolean. Default value: true. Header labels for the rows.
componentSize. Default value: 100%. Display width of the spreadsheet.
Common to all components (10)
copyreference. Create an independent copy of another component by reference, as if its DoenetML were written here: it starts fresh, without the reader's changes, and makes its own random choices. Enter a reference as $name.
copyWithStateIn developmentreference. Create an independent copy of another component by reference that starts with that component's current state, including the reader's changes and its random choices. Enter a reference as $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <spreadsheet name="s">
Other (21)
$s.cells[ cell ]. The raw text contents of all cells.
$s.columnHeadersboolean. Header labels for the columns.
$s.columnsAdded in 0.7.13[ cell ]. The cells grouped by column.
$s.evaluatedCells[ cell ]. The evaluated values of all cells.
$s.evaluatedColumnsAdded in 0.7.13[ cell ]. The evaluated cell values grouped by column.
$s.evaluatedRowsAdded in 0.7.13[ cell ]. The evaluated cell values grouped by row.
$s.fixedColumnsLeftinteger. Number of left columns fixed in place when scrolling.
$s.fixedRowsTopinteger. Number of top rows fixed in place when scrolling.
$s.heightcomponentSize. Display height of the spreadsheet.
$s.minNumColumnsnumber. Minimum number of columns displayed.
$s.minNumRowsnumber. Minimum number of rows displayed.
$s.numColumnsnumber. The number of columns.
$s.numRowsnumber. The number of rows.
$s.pointsInCells[ point ]. Cells whose values are interpreted as points.
$s.pointsInColumnsAdded in 0.7.13[ point ]. Cell-derived points grouped by column.
$s.pointsInRowsAdded in 0.7.13[ point ]. Cell-derived points grouped by row.
$s.rowHeadersboolean. Header labels for the rows.
$s.rowsAdded in 0.7.13[ cell ]. The cells grouped by row.
$s.widthcomponentSize. Display width of the spreadsheet.
Common to all components (8)
$s.disabledboolean. Whether this component is disabled and cannot be interacted with.
$s.doenetMLtext. The DoenetML source code that produced this component.
$s.fixedboolean. Whether this component's value is fixed and cannot be modified.
$s.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$s.hideboolean. Whether to hide this component from the rendered output.
$s.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$s.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: default <spreadsheet>
Without any additional attributes, the default <spreadsheet> is rows by columns.
Example: referencing <spreadsheet> data
Values stored within individual cells of a <spreadsheet> can be accessed using the following
notation: spreadsheetName.cell## where ## is the column letter and row number of the cell.
For example, $foods.cellA2 refers to the cell in the first column and second row of the
<spreadsheet> component.
Example: <spreadsheet> with <cell> children
Initial data can be prefilled using nested <cell> children. The rowNum and colNum attributes
can be used to locate data.
When only one or neither of these attributes is specified, data is populated in the following manner:
- data is placed in the first row, first column
- subsequent entries are placed in the next availabe column, in the same row
- if only the column number is specified, data is placed in the previously used row
- if only the row number is specified, data is placed in the previously used column
Example: build <spreadsheet> with rows
Initial data can be prefilled using nested <row> children, which in turn contain
individual <cell> children.
Example: build <spreadsheet> with columns
Initial data can be prefilled using nested <column> children, which in turn contain
individual <cell> children.
Example: setting column widths
Without widths, each column is sized to fit its contents, so a column left
empty for students to type into is drawn narrow. A <col> per
column sets the widths, exactly as it does in a <tabular>:
the <col> components apply to the columns in order, and each width is
a percentage of the width of the spreadsheet (beside the row numbers, when they
are shown). A column that is already written out as a
<column> can instead take the same width attribute
itself. The spreadsheet still has at least minNumColumns columns, by
default, so set minNumColumns when the widths are meant to share the
spreadsheet among fewer columns; otherwise the extra columns are added beyond
the widths and the spreadsheet scrolls sideways.
Example: using spreadsheets for computations
Spreadsheet computation formulas can be entered directly into an individual <cell> component.
References for data within spreadsheets follow standard spreadsheet naming conventions,
but no $ is required. Formulas can be prefilled, or entered manually by the user by clicking on the cell.
Try directly entering a formula into cell B3 that references one or more of the other cells.
Example: emphasizing a header row
Add header to a <row> and its cells are drawn in bold. A header row can still be edited
like any other. The emphasis is not only visual: the cells of a header row are announced to a
screen reader as headers for the columns beneath them.
Example: cells the user cannot edit
Add fixed to a <cell> and the user cannot change it: the cell is greyed and clicking it
opens no editor, though it can still be selected and copied. Use it to protect labels and computed
results while leaving the data cells open. Adding fixed to a <row> fixes every cell of
that row, and adding it to the <spreadsheet> itself makes the whole grid read-only.
Attribute Examples
Attribute Example: minNumRows, minNumColumns
The default size <spreadsheet/> of 4 rows by 4 columns has been modified with
the minNumRows and the minNumColumns attributes.
Attribute Example: width, height
The default size <spreadsheet> component (100% of available screen width) is shown
above one with a specified width of 50% of available width.
A width may equally be given as a number of pixels (600, 600px) or a
physical measurement (6in); a height takes those same absolute sizes. See
Sizes.
Attribute Example: rowHeaders, columnHeaders
In this example, the rowHeaders and columnHeaders are suppressed by setting these attributes to false.
Attribute Example: hiddenRows, hiddenColumns
Individual rows and columns may be hidden using the hiddenRows and hiddenColumns attributes.
Attribute Example: fixedRowsTop, fixedColumnsLeft
Individual rows and columns may be fixed in place during scrolling using the fixedRowsTop and fixedColumnsLeft attributes. Each of these accepts an integer value for the number of rows or columns to fix in place.
Since Doenet will allow for as much height as required for the spreadsheet to display its rows, this effect is easier to observe with the columns than the rows.