How to Install and Use ExcelTeX with LaTeX
At a glance
- 1. Check the package files
Find the ExcelTeX package and its documentation on CTAN; check whether your version also requires a spreadsheet-side exporter.
- 2. Install the LaTeX part
Use your TeX distribution’s package manager, then confirm LaTeX can locate exceltex.sty.
- 3. Export spreadsheet data
Run the companion exporter before compiling, following the instructions for your ExcelTeX version.
- 4. Include the output
Use the documented ExcelTeX command or, when the exporter creates a TeX fragment, include it with \input.
ExcelTeX is intended to connect spreadsheet data with a LaTeX document. The key point is that LaTeX does not normally read an Excel workbook such as .xlsx directly: spreadsheet data must first be exported or converted. Depending on the ExcelTeX release, that can involve a LaTeX package plus a companion spreadsheet macro or exporter.
Because ExcelTeX is a specialized, older workflow, check the instructions for the exact version you have. The package manager may install the LaTeX files without installing a separate Excel-side component.
Find and install the package
Start with the ExcelTeX entry on CTAN. Read the package notes and installation instructions, and check which files are included. In particular, look for both the LaTeX package file (usually a .sty file) and any spreadsheet-side exporter or macro.
If your TeX distribution provides the package, use its package manager:
- TeX Live: try
tlmgr install exceltexin a terminal. If the package is not available under that name in your repository, consult the CTAN instructions for manual installation. - MiKTeX: search for
exceltexin MiKTeX Console and install it if it is listed. Refresh the file name database if your installation does not find a package you have just installed.
To check whether TeX Live can locate the style file, run:
kpsewhich exceltex.sty
A path is returned if the file is found. If no path appears, check that you installed it into the TeX system used by your editor and compiler. Multiple TeX installations on one computer can cause an editor to use a different one from the package manager.
Export the spreadsheet data
Follow the instructions shipped with your ExcelTeX version to export the cells or ranges you need. Do this before compiling the LaTeX document. The export step may depend on a particular spreadsheet application or macro, so installing exceltex.sty alone may not be enough.
Do not guess the exporter command from a different version of the package. Use the command or menu described in that version’s manual, and check what kind of file it creates. If it produces a TeX fragment, LaTeX can include that fragment with \input. If it produces another format, use the import method documented for that format.
Include an exported TeX fragment
The following two-file example shows the handoff when an exporter creates a file containing LaTeX definitions. The fragment is illustrative; it is not a substitute for the ExcelTeX exporter’s own syntax.
Create exported-data.tex with the definitions generated from your spreadsheet:
\newcommand{\Revenue}{12500}
\newcommand{\Region}{North}
Then create and compile report.tex:
\documentclass{article}
\input{exported-data.tex}
\begin{document}
Revenue for the \Region{} region was \Revenue{}.
\end{document}
Here, \input reads the generated fragment as LaTeX source. The values in this example are ordinary text; if your spreadsheet contains special characters such as %, &, _, or #, ensure the exporter escapes them correctly for LaTeX. Otherwise they can be interpreted as syntax rather than data.
Common mistakes
- Installing only the
.styfile: The spreadsheet exporter may be a separate component. Check the package instructions for all required files. - Compiling before exporting: LaTeX can only use the data currently present in the exported file. Rerun the exporter after changing the spreadsheet.
- Using a different TeX installation: The editor, command line, and package manager may point to different TeX trees. Verify which compiler your editor runs.
- Assuming workbook formulas are recalculated: An exporter may read saved cell values rather than recalculate spreadsheet formulas. Recalculate and save the workbook in the spreadsheet application before exporting, unless the documentation says otherwise.
- Ignoring special characters or number formats: Check how the exporter handles text escaping, decimal separators, dates, and formatted values. Spreadsheet display formatting is not guaranteed to transfer unchanged.
If ExcelTeX does not work with your current spreadsheet application or TeX setup, a simpler alternative is to export a CSV file and use a LaTeX CSV-reading package. That is a different workflow, but it can be easier to maintain when you only need tabular data.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.