I am trying to find a Windows available spreadsheet with an option of graphs export to LaTeX. It would be great to export it directly from Excel, but I've read that it is not possible furthermore I am not able to find spreadsheet with LaTeX export option that will work on Windows, is there any? Or is there any other method to solve my problem with the exception of placing simple image in my TeX document.
2 Answers
I just answer the table part - not the diagram part:
I know of three possibilities to do the export:
- OpenOffice Macro
Calc2LaTeX
(Link 1, Link 2) - MS Excel Macro
Excel2LaTeX
(Link 1, Link 2, Link 3) - Editor
LaTable
(Link) - not exactly what you want probably
Other related questions and packages
- Importing csv file into latex as a table (package
csvsimple
) - Importing CSV file as a table in Latex but file too long (package
csvsimple
) - Package
pgfplotstable
which is part of thepgfplots
package (Link to documentation). - Package
datatool
(Link) - taken from Mike's comment. - Important: Big list of tools for table generation (Link, Comprehensive list of tools that simplify the generation of LaTeX tables)
Here is an example of moving Excel to LaTeX. First with copy and paste and second using R. The use of tikzDevice and knitr to build finish graphics is shown in Adam Liter's excellent answer in Best Practice for nice layout with tikzDevice
And I have implemented a very simple demonstration of using the data from the Excel spreadsheet to create a graphic which uses the current LaTeX font. This is done using R to input Excel data and controlling fonts with tikzDevice.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{center}\LARGE
\textbf{Using data contained in an Excel spreadsheet to create data tables and graphics in \LaTeX{} generated PDF}
\end{center}
An Excel spreadsheet has been saved as \textbf{dataandgraph.xlsx}. Now to get the data and the graphics into a PDF using \LaTeX{}.
\section{Copy and Paste Methods}
This approach is only useful for one-time graphics inclusions into \LaTeX. And you are very, very sure that there will be no editing or changes of the graphics. (This is rarely true for Excel graphics.)
\subsection{Copy graphic, paste to PowerPoint, Save as *.png}
This is quick and fairly easy to do. It is expecially useful if your workflow requires \LaTeX{} for the paper and PowerPoint for the presentations.
\includegraphics[width=.45\linewidth]{copypastetopptsaveaspng}
\subsection{Copy Data Table, paste to PowerPoint, Save as *.png}
This is quick and fairly easy to do. It is expecially useful if your workflow requires \LaTeX{} for the paper, Excel for data collection, and PowerPoint for the presentations.
\includegraphics[width=.45\linewidth]{CopyDataToPPTsaveAspng}
\section{Using the \textbf{R package xlsx} to read the \textit{*.xlsx} file and Knitr to move to \LaTeX{}}
\verb+http://www.sthda.com/english/wiki/+ \\
\verb+r-xlsx-package-a-quick-start-guide-to-manipulate-excel-files-in-r+.
Note: there is also a package \textbf{openxlsx} which offers more control on writing and reading of xlsx files from R.
\subsection{Using R to move the data table to \LaTeX{}}
This requires that the computer has R installed with the needed R packages. And that the user knows how to integrate the knitr and \LaTeX{} compile process. \verb+http://yihui.name/knitr/+
<<>>=
library(xlsx)
tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
str(tt)
tt
@
Using the Excel data to plot a graph.
<<out.width='3in'>>=
attach(tt)
plot(a,b,type="l")
@
\subsection{Now using the current \LaTeX{} font for the table}
Now the data output can be made to use \LaTeX{} fonts by xtable. Note: In the R-chunk all code output has been turned off.
<<echo=FALSE,results='asis'>>=
library(xtable)
tt<- data.frame(read.xlsx('dataandgraph.xlsx',1))
xtable(tt)
@
\clearpage
\subsection{Now using the current \LaTeX{} font for the graphics}
First a demo using a dataset built in to R and the packages ggplot2 and tikzDevice.
\begin{figure}[!h]
<<fig1,eval=TRUE,out.height='3in',echo=FALSE,dev='tikz'>>=
library(ggplot2)
library(tikzDevice)
qplot(displ, hwy, data = mpg, colour = factor(cyl))
@
\end{figure}
Now a plot from the data read in from the Excel spreadsheet. Note: the command \textit{library(tikzDevice)} only needs to be used once in a given *.Rnw file.
\begin{figure}[!h]
<<fig2,eval=TRUE,out.width='3in',echo=FALSE,dev='tikz'>>=
library(tikzDevice)
boxplot(tt$b~tt$number, col=rainbow(4),main="Using \\LaTeX{} Fonts")
@
\end{figure}
\end{document}
-
-
1@ManuelKuehner This is basically how all homework for my three different statistics course students was completed. I required each homework to be submitted as a zip file with all of the supporting and generated files contained within the zip. Then I would use the todo package (which I required to the in the LaTeX preamble) to provide grading information and feedback). No paper. May 8, 2015 at 13:09
Excel2Latex
: ctan.org/tex-archive/support/excel2latex/?lang=en, but that only does tables not graphs