Go to page:

Search help:

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

CopyTablesFromSpreadsheets

Categories: Tips
<< WordCount | Page list | Correcting split Subversion keywords >>

Pasting data from a spreadsheet into LyX

As of Lyx 1.5, you can get data copied from a spreadsheet into Lyx using the "Paste Special" command:

  • Follow the procedure below up to step 5
  • Instead of using the middle button, select either Edit -> Paste Special -> Plain Text or Edit -> Paste Special -> Plain Text, Join Lines
  • Sometimes you seem to need the "Join Lines" version, sometimes the standard one (?)

-- Zeyn

On the mailing list Samar Singh indicated a great and apparently undocumented way to get tabular data inside a Lyx table:

1. open your xls file with gnumeric or open office.

2. Select the requisite number of columns and rows

3. Come back to your lyx document

4. Insert a table which has at least the selected number of rows and columns

5. Go to the cell on your lyx table where you want the top left corner of the 
   section to be placed.

6. Click the middle button on your mouse (if you only have two buttons, press 
   both buttons simultaneously).

That should be it. The experts tell me this should not work but unfortunately 
for the theory, it does for me. 

samar

-- samar j. singh

Kenward Vaughan added:

... it is VERY important that you do NOT instigate any typing in the table when you do this. If you click in the 1st box of the table and see a red-bordered box inside, before you click the middle mouse button, this paste won't work. It will instead paste the whole excel contents into that one cell.
Simply _position_ the cursor over the cell before ...

I myself have tried this succesfully on Windows with Excel and Lyx 1.3.6 -- and by the way, instead of the middle mouse button sometimes it also worked to paste via menu selection or C-v shortcut (but not always).

--

For my Excel 2002 on WinXP and LyX on Win V136-1 it also works by direcly copying the cells from excel, without opening it in openoffice or gnumeric. The only nasty thing is that the last column gets an additional square character.

-- Laura

Tables using EPS

In OpenOffice, it is possible to export tables as EPS and include it into Lyx with all the formatting (color, fonts, borders etc) exactly like in OO Calc

Follow these steps:

  1. Open the spreadheet, select and copy the region of interest.
  2. Select File->New->Drawing.
  3. Right click somewhere on the drawing page and Paste.
  4. Select File->Export now to get the EPS. (Note the selection only option on the file dialog, if you export more than the selection the bounding box will be too big)

See WinGraphics for more EPS related exports

Tables using Calc2Latex

Calc2LaTeX is an OpenOffice macro to convert OOCalc tables to LaTeX. It works well and is easy to use. You can paste the result in a LaTeX file and then import it in LyX.

-- Charles

Tables using Gnumeric

Gnumeric is a spread-sheet program with a good LaTeX export. Follow these steps:

  • Design in Gnumeric your table. You can make the complete layout in Gnumeric. Writing emphasis-styles as bold, small caps or italic are taken over, likewise the table lines. Thick lines are converted in double lines.
  • Go to File -> Save As... and store the table as a *.tex-file.
  • Open the *.tex-file in any text editor. Read the instruction in the first comment box.
  • Start LyX. Open the dialog box Document -> Preferences -> LaTeX Preamble.
  • Change to the text editor. Copy the commands for the LaTeX preamble.
  • Change to LyX. Insert the commands into the array "LaTeX Preamble". Remove the comment symbols. Write the following command into a ERT box at the beginning of your LyX document:
\def\inputGnumericTable{}
  • Now the table can be inserted into the LyX document over Insert -> File -> Subdocument.

Notes:

  • Self-evident the *.tex-file can be user-defined edited. In this way you can also realize formatting, which are not possible in Gnumeric themselves. For example you can insert mathematical formulas between two dollar characters ("$...$").
  • If you insert the table into a float, you must the following command add in the text editor into the *.tex-file:
\addtocounter{table}{-1}
Otherwise the numbering of the tables is not correct.
  • If in Gnumeric numbers with the euro-symbol were formatted, a question mark ("?") appears in the *.tex-file. In the text editor you must replace the question marks by a LaTeX coding for the euro-symbol over "Find And Replace". A quite good euro-symbol offers the package marvosym. In the *.tex-file then should stand the character string "\EURtm" instead of the question mark. In LyX you should add the following command in the dialog box "LaTeX Preamble":
\usepackage{marvosym}

--Marcus

Tips

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2007-09-14 18:27 CEST