TableView

TableView[{{expr11,expr12,},{expr21,expr22,},}]

displays as a spreadsheet-like table view for editing and viewing exprij.

TableView[Dynamic[x]]

takes the contents of the table view to be the dynamically updated current value of x, with the value of x being reset as the table view is interactively edited.

TableView[table,type]

uses the specified type by default to represent newly edited or created entries in the table view.

TableView[]

displays an empty table view.

Details and Options

  • TableView produces an interface that works similarly to common spreadsheet interfaces. Columns may be resized. Selections of entire rows, columns or blocks may be cut and pasted. Strings and numbers are automatically differentiated upon editing. The view may be scrolled to accommodate large numbers of entries.
  • The following are possible values of type:
  • Numbernumber
    Stringstring
    Expressionexpression
    Hold[Expression]expression in held form
    Boxesraw boxes
    {Number,String}use numbers when possible, or strings otherwise
  • When type is not specified, TableView defaults to {Number,String}.
  • The following options can be given:
  • AllowedDimensionsAutomaticrestrictions on number of rows or columns
    AppearanceElementsAutomaticelements to include in the displayed view
    BackgroundNonewhat background colors to use
    BaselinePositionAutomaticwhat to align with a surrounding text baseline
    BaseStyle{}base style specifications for the grid
    EditableTruewhether the individual entries can be edited
    ImageSizeAutomaticthe overall size of the table view
    ItemSizeAutomaticwidth and height of each item
    ItemStyleNonestyles for columns and rows
    ScrollbarsAutomatic
  • whether to include scrollbars
  • ScrollPosition{0,0}scroll position if scrolling is enabled
  • Settings for the options Alignment, Background, ItemSize and ItemStyle can be given as follows to apply separately to different items:
  • specapply spec to all items
    {specx}apply specx at successive horizontal positions
    {specx,specy}apply speck at successive horizontal and vertical positions
    {specx,specy,rules}also allow explicit rules for individual i, j elements
  • The speck can have the following forms:
  • {s1,s2,,sn}use s1 through sn, then use defaults
    {{c}}use c in all cases
    {{c1,c2}}alternate between c1 and c2
    {{c1,c2,}}cycle through all ci
    {s,{c}}use s, then repeatedly use c
    {s1,s2,,{c1, c2,},sm,,sn}use the first sequence of si at the beginning, then cyclically use ci, then use the last sequence of si at the end
    {i1->v1,i2->v2,}specify what to use at positions ik
    {spec,rules}use rules to override specifications in spec
  • TableView supports viewing and creation of ragged tables of data.
  • Empty entries in TableView are omitted upon evaluation if they can be clipped from the right edge of the table. If empty entries are within a table, they are represented as empty strings or Null as appropriate for the specified type.
  • Setting may be used with TableView to extract the underlying data.
  • TableView is specifically designed to allow efficient viewing, editing and file storage of very large tables of data in notebooks.
  • Possible elements in AppearanceElements include "RowHeaders", "CollapsedRowHeaders", "ColumnHeaders", "CollapsedColumnHeaders", "Frame" and "ResizeArea".

Examples

open allclose all

Basic Examples  (2)

Numerical data in TableView:

Numbers and strings:

Scope  (11)

Structure  (5)

An empty TableView:

A regular array of data:

A ragged array of data:

Arrays with empty fields:

Empty rows and columns:

Types  (6)

Numbers:

Strings:

Mixed data:

Expressions:

Images and graphics:

Boxes:

Options  (18)

AllowedDimensions  (2)

Set the dimensions to be exactly 4 columns by 3 rows:

Automatic scrollbars appear if the allowed dimensions cannot be displayed all at once:

With unconstrained dimensions, the scroll position can be set arbitrarily high:

With constrained dimensions, the scroll position will not move past the constraints:

AppearanceElements  (2)

Show collapsed headers and collapsed columns:

The "Frame" element always displays as a thin gray frame:

To use a customized frame, omit the "Frame" element and use Framed:

Background  (7)

Draw the view with a pink background:

Pink and gray backgrounds for the columns at the first and second horizontal positions:

An equivalent syntax:

Pink and gray backgrounds for the rows at the first and second vertical positions:

Alternating pink and gray backgrounds:

Alternating backgrounds with yellow superimposed in the first and last positions:

Blending of colors:

Set the background for specific items:

Set the background for a subregion of the grid:

BaselinePosition  (2)

Align the center of the grid with the baseline of surrounding text:

Align the bottom of the grid with the baseline:

ImageSize  (1)

Display views at various sizes:

Scrollbars  (3)

By default, scrollbars do not appear if the TableView can display all of the data at once:

They do appear if the data would otherwise be clipped:

Always display scrollbars, even when the data fits within the view:

Suppress scrollbars even if the data would be clipped at the current ImageSize:

ScrollPosition  (1)

Specify the initial position of a view:

Properties & Relations  (1)

TableView takes many of the same options as Grid with similar specifications:

Unlike Grid, TableView has no right or bottom; specifications of the right or bottom do not do anything:

Neat Examples  (1)

Use Magnify to see an overview of a large number of cells:

Introduced in 2020
 (12.1)