WOLFRAM

Copy to clipboard.
NotebookRead[notebook]

gives the expression corresponding to the current selection in the specified notebook object.

Copy to clipboard.

gives the expression corresponding to the given cell or box object.

Copy to clipboard.
NotebookRead[{obj1,obj2,}]

gives a list of expressions corresponding to the obji.

Details and Options

  • NotebookRead is the basic way to get into the kernel pieces of notebooks that are being manipulated by the front end.
  • NotebookRead can take a NotebookObject, CellObject, or BoxObject.
  • If a list of CellObject or BoxObject expressions is given, then a list of equal length will be returned, with the expressions corresponding to each object.
  • If an object is no longer valid, NotebookRead returns $Failed. If a list of objects is given, then $Failed will be returned for each of the invalid objects.
  • The following options can be given:
  • CellContext Nonecontext to substitute for $CellContext`
    StripCellGrouping Falsewhether to strip cell grouping when reading contiguously selected cells
  • When NotebookRead[notebook] reads a contiguous selection of cells, selected cell groups are returned as Cell[CellGroupData[]] expressions by default. The option setting StripCellGroupingTrue will force selected cells to be returned as a flat list regardless of grouping.

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

This creates a document notebook:

Out[1]=1

This selects the first cell:

This reads the cell and returns its Cell expression:

Out[3]=3

Read a CellObject:

Out[1]=1

Read a BoxObject:

Out[1]=1

Scope  (1)Survey of the scope of standard use cases

Create a notebook and move the selection to the first "T":

Read the current selection:

Out[3]=3

Select multiple cells and read the content:

Out[5]=5

Select and read graphics:

Display the result:

Out[8]=8

Options  (2)Common values & functionality for each option

CellContext  (1)

Create a target cell with a raw expression in it:

Read the cell using NotebookRead:

Out[2]=2

Use CellContext to substitute a value for the $CellContext` context:

Out[3]=3

StripCellGrouping  (1)

Reading a group of cells includes CellGroupData constructs by default:

Out[1]=1

Use StripCellGrouping to remove the grouping information:

Out[2]=2

Applications  (1)Sample problems that can be solved with this function

A palette that reads the word at the current selection and makes it uppercase:

Out[1]=1
Wolfram Research (1996), NotebookRead, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookRead.html (updated 2024).
Copy to clipboard.
Wolfram Research (1996), NotebookRead, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookRead.html (updated 2024).

Text

Wolfram Research (1996), NotebookRead, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookRead.html (updated 2024).

Copy to clipboard.
Wolfram Research (1996), NotebookRead, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookRead.html (updated 2024).

CMS

Wolfram Language. 1996. "NotebookRead." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NotebookRead.html.

Copy to clipboard.
Wolfram Language. 1996. "NotebookRead." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/NotebookRead.html.

APA

Wolfram Language. (1996). NotebookRead. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NotebookRead.html

Copy to clipboard.
Wolfram Language. (1996). NotebookRead. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NotebookRead.html

BibTeX

@misc{reference.wolfram_2025_notebookread, author="Wolfram Research", title="{NotebookRead}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/NotebookRead.html}", note=[Accessed: 14-March-2025 ]}

Copy to clipboard.
@misc{reference.wolfram_2025_notebookread, author="Wolfram Research", title="{NotebookRead}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/NotebookRead.html}", note=[Accessed: 14-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_notebookread, organization={Wolfram Research}, title={NotebookRead}, year={2024}, url={https://reference.wolfram.com/language/ref/NotebookRead.html}, note=[Accessed: 14-March-2025 ]}

Copy to clipboard.
@online{reference.wolfram_2025_notebookread, organization={Wolfram Research}, title={NotebookRead}, year={2024}, url={https://reference.wolfram.com/language/ref/NotebookRead.html}, note=[Accessed: 14-March-2025 ]}