I created a .xlsx file using the python module Xlsxwriter.
Works well but any cells that contain formula will show up as empty or 0 when I run
unoconv -f pdf spreadsheet.xlsx
How do I force the unoconv autocalculate the values before converting to pdf?
As of this writing, apparently unoconv is purposely not doing any recalculation because it can cause errors. See Issue 97. The relevant part of unoconv's source code is commented out.
So one thing you could try is to go into your copy of unoconv and uncomment those lines (make them active again). You may get errors or you may be fine.
Another thing you could try, if your formulas are simple, is to calculate them using Python and write the results along with the formulas using XlsxWriter. Notice that the
worksheet.write_formula()
method has an optionalvalue
parameter. Quoting from the official docs:Note that if the formulas are such that you can calculate them with Python, and you only care about the final PDF (no one is going to use the spreadsheet, and after you convert it to PDF you just throw it away anyway), then you could write the values directly, without the formulas at all.