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 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
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:
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
That's it :)
This is another solution if you have Visio. This is the explanation for Visio 2010.
Step 1. Copy and paste the graph. Copy/paste your Excel graph to Visio. Be sure that it is pasted as Microsoft Office Excel Worksheet (this should be the default, but it can be ensured using the Paste Special option instead of Paste).
Step 2. Remove blanks spaces around the graph. Go to Design tab, then find Page Setup, go to Size and choose Fit to Drawing. This removes everything but margins. To remove margins, open the Page Setup (click on the small icon in the bottom right corner of this ribbon area), go to Print Setup tab, click on Setup and set the margins (it seems that the left margin cannot be set to 0, at least not using this approach). Then click OK twice.
Step 3. Create the PDF file. Now go to File, then Save As, from the Save as type list choose PDF. Click Options, adjust the options, then click OK and finally Save. Now there should be the PDF file with the graph.
Step 4. Import this PDF file into a LaTeX document. For this, the
\includegraphics command should be used.
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