This patch lets LyX 2.0 use spreadsheets as external insets: * gnumeric spreadsheets * openoffice spreadsheets * excel spreadhsheets
This is done using the "ssconvert" utility that comes with gnumeric, so it is necessary to have gnumeric even if the spreadsheets used are made with openoffice/excel. The ssconvert utility does not execute macros, so there should be no new risk of macro viruses. Spreadsheets are imported as longtables, so a spreadsheet longer than a page will still work fine. PDF created with patched LyX 2.0, with included spreadsheets: http://www.aitel.hist.no/~helgehaf/sw/lyxsheet/sheet.pdf The .lyx file (only works with patched LyX 2.0): http://www.aitel.hist.no/~helgehaf/sw/lyxsheet/sheet.lyx The included spreadsheets: http://www.aitel.hist.no/~helgehaf/sw/lyxsheet/sheet.gnumeric http://www.aitel.hist.no/~helgehaf/sw/lyxsheet/sheet.ods http://www.aitel.hist.no/~helgehaf/sw/lyxsheet/sheet.xls The patch touches 3 files: src/LaTeXFeatures.cpp The hhline latex package is necessary lib/external_templates The external inset itself lib/configure.py So Tools->Reconfigure will check for gnumeric Use "Insert->File->External Material", then select GnumericSpreadsheet to insert a spreadsheet into a document. I hope this can be useful for LyX 2.0, spreadsheets are requested now and then on the user list. Helge Hafting
Index: src/LaTeXFeatures.cpp =================================================================== --- src/LaTeXFeatures.cpp (revisjon 36773) +++ src/LaTeXFeatures.cpp (arbeidskopi) @@ -588,6 +588,7 @@ "csquotes", "enumitem", "endnotes", + "hhline", "ifthen", "amsthm", // listings is handled in BufferParams.cpp Index: lib/external_templates =================================================================== --- lib/external_templates (revisjon 36773) +++ lib/external_templates (arbeidskopi) @@ -33,6 +33,45 @@ \IfFileExists{#1}{\input{#1}}{\warnNotFound{#1}}} PreambleDefEnd +Template GnumericSpreadsheet + GuiName "Spreadsheet" + HelpText + A spreadsheet made with gnumeric, openoffice or excel. + It imports as a long table, so any length + is ok. Excessive width could be a problem. + The gnumeric software is necessary for conversion, + both for gnumeric and excel files. + HelpTextEnd + InputFormat "gnumeric" + FileFilter "*.{gnumeric,ods,xls}" + AutomaticProduction true + Format LaTeX + Product "\\def\\inputGnumericTable{}\\input{$$AbsOrRelPathMaster$$Basename.tex}" + UpdateFormat latex + UpdateResult "$$AbsPath$$Basename.tex" + Requirement "color" + Requirement "array" + Requirement "longtable" + Requirement "calc" + Requirement "multirow" + Requirement "hhline" + Requirement "ifthen" + ReferencedFile latex "$$AbsOrRelPathMaster$$Basename.tex" + FormatEnd + Format PDFLaTeX + Product "\\def\\inputGnumericTable{}\\input{$$AbsOrRelPathMaster$$Basename.tex}" + UpdateFormat latex + UpdateResult "$$AbsPath$$Basename.tex" + Requirement "color" + Requirement "array" + Requirement "longtable" + Requirement "calc" + Requirement "multirow" + Requirement "hhline" + Requirement "ifthen" + ReferencedFile latex "$$AbsOrRelPathMaster$$Basename.tex" + FormatEnd +TemplateEnd Template RasterImage # By default, InsetExternal is displayed as a grey button Index: lib/configure.py =================================================================== --- lib/configure.py (revisjon 36773) +++ lib/configure.py (arbeidskopi) @@ -515,6 +515,11 @@ \Format text3 txt "Plain text (ps2ascii)" "" "" "%%" "document" \Format text4 txt "Plain text (catdvi)" "" "" "%%" "document" \Format textparagraph txt "Plain Text, Join Lines" "" "" "%%" "document"''' ]) + #Spreadsheets using ssconvert from gnumeric + checkViewer('gnumeric spreadsheet software', ['gnumeric'], + rc_entry = [r'''\Format gnumeric gnumeric "Gnumeric spreadsheet" "" "" "%%" "document" +\Format excel xls "Excel spreadsheet" "" "" "%%" "document" +\Format oocalc ods "OpenOffice spreadsheet" "" "" "%%" "document"''']) # path, xhtmlview = checkViewer('an HTML previewer', ['firefox', 'mozilla file://$$p$$i', 'netscape'], rc_entry = [r'\Format xhtml xhtml "LyXHTML" y "%%" "" "document"']) @@ -805,6 +810,13 @@ rc_entry = [ r'\converter svg png "%%" ""']) # + # gnumeric/xls/ods to tex + checkProg('a spreadsheet -> latex converter', ['ssconvert'], + rc_entry = [ r'''\converter gnumeric latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" "" +\converter ods latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" "" +\converter xls latex "ssconvert --export-type=Gnumeric_html:latex $$i $$o" ""''', +'']) + path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond']) if (lilypond != ''): version_string = cmdOutput("lilypond --version")