This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Getting Started / System-Specific Information /

Importing and Exporting

Mathematica has many capabilities for importing and exporting text, data, and graphics.

To import data from a spreadsheet:

1. Save the data from your spreadsheet to a file where row entries are separated with spaces or tabs. Numbers should be written in C or Fortran-like "E" notation. For example, in Excel 2000 you can save the data by setting the file type to Text (Tab delimited).

2. Evaluate Import["file", "Table"] in a notebook.

To export a matrix to a file:

Evaluate Export["file", expr, "Table"] in a notebook. The file will have spaces between row entries. Numbers are written in C or Fortran-like "E" notation, usually with six-digit precision.

The file can be read into a spreadsheet. For example, in Excel 2000 you can open the file and the Text Import Wizard will help you interpret rows and columns in the file.

To import and manipulate a bitmap image:

Evaluate the command Import["name.ext"]. The result will be a Mathematica expression that corresponds to the graphic in the specified file.

Use the Mathematica command Show to display the graphic.

Use InputForm to see the structure of the Mathematica expression. See Section 2.10.20 in The Mathematica Book for information on manipulating this expression.

To export an image:

Evaluate Export["name.ext", expr].

If you are not using a bitmap format and you used mathematical notation or other text in the image, the Mathematica fonts should be made available to any program or printer that will use the image.

Some operating systems, such as Windows, will use the fonts automatically if they are installed on the machine and if the machine can download the fonts to the printer.

To export a Notebook as HTML:

1. Choose File RightTriangleSave As Special RightTriangleHTML.

2. Specify a name and location for the file in the Save As dialog box.

3. Click OK.

Mathematica converts any graphic to a GIF image and creates the appropriate reference to the image in the HTML file. By default, a closed cell group is converted to a link, and the contents of the closed cell are saved as a separate HTML file.

When you save a notebook as HTML, any mathematical expressions are saved as embedded images. You can also choose to save formulas in MathML, an XML format developed by the World Wide Web Consortium (W3C) for representing mathematical formulas in web pages. To do this, choose File RightTriangle Save As Special RightTriangle XML (XHTML + MathML). The resulting file can then be viewed in any browser that supports MathML.

To export a Notebook as XML:

You can also save notebooks as XML files by choosing File RightTriangleSave As Special RightTriangleXML (NotebookML). NotebookML is an XML format developed by Wolfram Research for representing Mathematica notebooks.

When saving as NotebookML, all mathematical formulas are saved as images. However, you can choose to save formulas in MathML by choosing File RightTriangleSave As Special RightTriangleXML (NotebookML + MathML).

To import an XML document:

1. Choose File RightTriangleOpen.

2. Choose the XML file you wish to open in the Open dialog box.

3. Click OK.

If the file being imported is in NotebookML format, it will automatically be converted into a Mathematica notebook. For any other type of XML file, the contents of the file are imported as plain text.

For more information

BulletThe Mathematica Book, Sections 1.11 and 2.10.20.

Bullet The entries for Import and Export in the Built-in Functions category of the Help Browser.

Bullet The XML Capabilities section in the Add-ons & Links category of the Help Browser.

Bullet The Technical Support FAQs at


BulletImport and Export support a wide variety of text, graphics, and sound formats.

Bullet The values of $ImportFormats and $ExportFormats tell you which formats are supported on your platform.

Bullet Besides saving as HTML or XML, the File RightTriangleSave As Special command also allows you to save notebooks in .