Wolfram Research

Function Repository Resource:

CellInformation

Source Notebook

Retrieve information about selected cells in notebook

Contributed by: Wolfram Research

ResourceFunction["CellInformation"][notebook]

gives an association containing information about selected cells in the specified notebook object.

ResourceFunction["CellInformation"][obj]

gives information about the given cell or box object.

ResourceFunction["CellInformation"][{obj1,obj2,}]

gives a list of information corresponding to the obji.

ResourceFunction["CellInformation"][,prop]

gets the specified property.

Details and Options

ResourceFunction["CellInformation"] can take a NotebookObject, CellObject, or BoxObject.
ResourceFunction["CellInformation"] can give information both about selections within cells, and cells selected as a whole.
ResourceFunction["CellInformation"] returns a list of rules that include information on cell styles, selection positions, and other features.

Examples

Basic Examples

Get information about the current input cell:

In[1]:=
ResourceFunction["CellInformation"][EvaluationCell[]]
Out[1]=

See information about this text cell:

In[2]:=
ResourceFunction["CellInformation"][PreviousCell[]]
Out[2]=

Get a specific property:

In[3]:=
ResourceFunction["CellInformation"][EvaluationCell[], "Style"]
Out[3]=

Get multiple properties:

In[4]:=
ResourceFunction["CellInformation"][
 PreviousCell[], {"Style", "ContentData"}]
Out[4]=

Scope

Open a notebook as a NotebookObject:

In[5]:=
nb = NotebookOpen[FindFile["ExampleData/document.nb"]]
Out[5]=

Select the first cell:

In[6]:=
SelectionMove[nb, Next, Cell]

Get information about the current selection:

In[7]:=
ResourceFunction["CellInformation"][nb]
Out[7]=

Select multiple cells and get the selected cell styles:

In[8]:=
SelectionMove[nb, All, CellGroup];
ResourceFunction["CellInformation"][nb, "Style"]
Out[9]=
In[10]:=
NotebookClose[nb]

CellInformation can also take a BoxObject, and will return information about the parent cell:

In[11]:=
Framed[Dynamic[box = EvaluationBox[]]]
Out[11]=
In[12]:=
ResourceFunction["CellInformation"][box]
Out[12]=

This is equivalent to getting CellInformation of the ParentCell:

In[13]:=
cell = ParentCell[box]
Out[13]=
In[14]:=
ResourceFunction["CellInformation"][cell]
Out[14]=

Applications

Get a Dataset containing information about all cells in the current notebook:

In[15]:=
Dataset[ResourceFunction["CellInformation"][
  Cells[EvaluationNotebook[]]]]
Out[15]=

Resource History

See Also

License Information