# Is it possible to put MS Excel graphs into a LaTeX document?

I will be using Microsoft Excel to produce graphs and I was wondering if there was a simple way to put those graphs into a LaTeX document?

-
You have to export the graphs to eps or pdf or jpg and then include them with \includegraphics{}. –  Sigur Dec 28 '12 at 23:06
So I just save the graphic to .eps, .pdf or .jpg? I have heard that .png is the best file format to use? Is this right? –  CAF Dec 28 '12 at 23:13
@CAF: No, PNG is a raster format, which means it is not scalable. PDF or EPS are much better. –  C.R. Dec 29 '12 at 0:56

You can put the graph as a seperate document tab (opposed to inside a sheet). Then you can print it to PDF, using either some installed PDF printer or the Office built-in PDF printer. Then you can include the graph using the package graphicx and the command \includegraphics[width=\linewidth]{graph.pdf}.

You can as well download the TeX fonts as OTF and use them in Office, achieving the font consistency. The basic Computer Modern can be gotten here in the renewed version Latin Modern:

-
Or use the data points and plot the graph using pgfplots or tikz. –  Harish Kumar Dec 28 '12 at 23:11
@HarishKumar TBH, If I had to do it, and I had some calculations in Excel, I would prefer exporting the graphs, and would only care about the proper font family and eventually font size. –  tohecz Dec 28 '12 at 23:13
Where you say save to pdf, could I use png? I have heard this is the most reliable format. If so, why? –  CAF Dec 28 '12 at 23:20
In this case, pdf is certainly better, because png is raster graphics, making it badly scalable. For this, you are safe with pdf because you don't use any special functions (hyperlinks, embedded videos or who-knows-what). –  tohecz Dec 28 '12 at 23:24
I have tried this code, but the following error message appears: 'The required file tex\context\base\supp-pdf.mkii is missing. It is part of the following package: mptopdf. The package will be installed from: (link to choose repository directory). It then allows an option to install, but I have clicked this and the exact same message appears again and again... Any ideas? –  CAF Dec 29 '12 at 9:02

In addition to what the other posters said it is worth mentioning that one can also use VBA code to create regular exports from Excel, quite helpful if you need to repeat the exports because the data have changed.

A while ago I wrote a blogpost on this, the following VBA code is taken from this post:

Sub ExportAllCharts()

If ActiveSheet.ChartObjects.Count > 0 Then
For Each Diagram In ActiveSheet.ChartObjects
ActiveSheet.ChartObjects(Diagram.Name).Activate
Filename = ActiveChart.Name
ActiveChart.Axes(xlValue).MajorGridlines.Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\" & Filename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next Diagram
End If

End Sub

-

I wanted to add a very simple but effective way of how I was doing it. I was using Excel to graph results, because I didn't have that many graphs (much more tables). Nontheless I think the outcome is quite good and sufficient for many cases (exceptions would be if you needed to create a lot of graphs, then you might prefer other programs instead, like mathlab, or Latex packages to achieve a more consistent look with regard to captions).

First mark the graph/diagram and use file/save as...Here you must choose pdf-format. I would save the file in the same folder where you usually save all your tex-files.

The next step is to crop the image. There are numerous ways, e.g. Photoshop, IrfanView. A more professional, automated way would be pdfcrop. You need to download Perl first and install, then you can use it. A little warning: You need to use the command line for pdfcrop. The advantage is that you can very quickly crop all your images perfectly with little to no margins. There are many tutorials/explanations on these programs to find.

The final steps have been described before. You need to load the package graphicx and the command to insert a graph_x is \includegraphics[width=\linewidth]{graph_x.pdf}.

That's it :)

-

If you can switch to some other spreadsheet software, you can try one of those that support export to LaTeX: https://en.wikipedia.org/wiki/Comparison_of_spreadsheet_software

-
Does any of those support graphics? I would have assumed they only supported tabular material. –  Torbjørn T. Nov 11 '13 at 14:29