[Tex/LaTex] Getting data dynamically into LaTeX from a spreadsheet

excelimport

Is it possible to access to data from spreadsheets (i.e. excel spreadsheets) and include them dynamically into a LaTeX document?

We need to compile each month a lot of factsheets and therefore want to do it dynamically and not just convert the data one time into a useful format. It is important for us to have access to single cells of different spreadsheets in the same LaTeX document.

Already explored exceltex from this post, but we need the solution on windows systems.

Best Answer

This answer is probably long past being needed but for any future users who are looking to do this. I've used PerlTeX to get the values from the .xlsx file and found a very simple solution. All that will have to be called in the LaTeX document is a simple \getValue{B7} or whatever cell you want to access.

Things that need to be installed;

  • Strawberry Perl
  • Spreadsheet::Read module (Perl)
  • Spreadsheet::XLSX module (Perl)
  • PerlTex (You can do this through the MikTex package manager (or whatever compiler you're using))

Okay, once you've done that you can simply add the function within your LaTeX docuemnt

\perlnewcommand{\getValue}[1]{

#use Text::Template;
use Spreadsheet::Read;
use Spreadsheet::XLSX;

$data = ReadData ("FileName.xlsx");

$Output = $data->[1]{$_[0]}; #Where the [1] is the sheet, not the input

return $Output

}

You'll need to compile the document with perltex but that's not too hard. I've set up a simple batch file that does it all for me.

perltex --nosafe --latex=pdflatex filename.tex

Here is the code anyway if you guys need it. Feel free to message or comment if you need any help, or I've not provided the right information. I just thought I'd get all this down before I forget to contribute to this thread that has helped me.