# Windows spreadsheet - latex export

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.

• I think you can export or print the graph to PDF from Excel, then include that PDF in Latex. Would that work for you? May 6 '15 at 13:23
• It works with R installed. Then use knitr to embed R commands in LaTeX. Now use the R packages which allow you to read and write Excel spreadsheets. Finally if you use xtable (R package) and appropriate other R packages you can have LaTeX table code output exactly as desired. This should give you the needed keywords to search cran.r-project.org for documentation and examples. When I was teaching, I regularly required my statistics students to handle data in this fashion, because I refused to even grade handwritten homework. May 6 '15 at 13:24
• this will not affect the resolution of this graph? but still there is an issue of font that will be different in this pdf, i want identical font type to be used everywhere in my document May 6 '15 at 13:24
• There is the package Excel2Latex: ctan.org/tex-archive/support/excel2latex/?lang=en, but that only does tables not graphs May 6 '15 at 15:10
• Does Drawing paths with TikZ from a DB with DataTool apply? That takes data from a CSV and plots lines. May 6 '15 at 15:41

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

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)
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)
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}


• Interesting approach! May 8 '15 at 6:58
• @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 '15 at 13:09