0

I would like to know if there is a way, some package, to directly call my spreadsheets directly in a latex document, just as it is done with images. This would be very useful. That way, any data changes could be made directly in the spreadsheet file.

Update 1

I tried pgfplotstable:

\documentclass{standalone}

\usepackage{pgfplotstable} \usepackage{booktabs}

\begin{document}

\pgfplotstabletypeset[
    every head row/.style={ before row=\toprule,after row=\midrule},
    every last row/.style={after row=\bottomrule},
    columns/Fruit/.style={string type},
    columns/Animal/.style={string type}
    ]
    {   
        Number Fruit Animal
        1.23456 Banana Dog
        2.871 Orange Cat
        3.141592 Apple Bear
    } % A file can be called here too 

\end{document}

I took the PgfplotsTable package manual as a reference (http://linorg.usp.br/CTAN/graphics/pgf/contrib/pgfplots/doc/pgfplotstable.pdf).

I put the table as plain text, but a CSV file can be called as well.

It works fine!

  • 2
    it’s possible to export spreadsheet data as a CSV and read that as text, or to export it as an image and include that. If I understand you correctly. Could you be more specific? – Davislor Dec 29 '20 at 13:44
  • Thank you for the replay @Davislor. Imagine a document that you need to update frequently. The document presents some parameters through tables. Usually, these tables are built in advance using an application such as excel, libre-office or google sheet. In a conventional workflow, I have to convert these tables to latex or turn them into images to insert into the document. I wanted something that imports the tables directly from the files. Something like \inputspreadsheet{table.xlsx}{"A1:B5"}. – Felipe Pfirmer Dec 29 '20 at 14:09
  • You might export to CSV and read that in with pgfplotstable, datatool or direct Lua. – Davislor Dec 29 '20 at 14:19
  • Thank you again @Davislor! I will try these tools and post the result here. – Felipe Pfirmer Dec 29 '20 at 14:43

1 Answers1

1

TeX is Turing-complete so anything computable can be done with it, but it's probably easiest to use LuaLaTeX to accomplish the task. This answer at the main StackExchange site goes into how to use Lua to read an Excel file. As far as I know, there is no package which wraps up this functionality nicely.

Other solutions require an export step from the Excel (whether writing to CSV or using a tool like excel2latex which is an .xla plugin which will write LaTeX directly from Excel.

Don Hosek
  • 14,078