Hi. I am trying to convert an .xlsx file into a .pdf on a machine running Ubuntu Server using python and calc. The problem I have is that the .xlsx file contains non-negotiable self-referencing formulas. The code I am running at the moment generates a pdf that has the cells with those formulas filled with Err:522. On my windows machine, when I open the .xlsx file using calc, the cells are again filled with Err:522, but once I enable ‘iterative references’ all is great. Therefore I need the iterative references functionality enabled.
My question is, how can I enable it on a system without GUI?
This is the code that I am using at the moment (I also tried using UNO but kept crashing when I was trying to import com.sun.star.beans so I gave up that route.):
def excel_to_pdf_with_libreoffice(excel_path, pdf_path):
try:
command = [
'soffice',
'--headless',
'--convert-to',
'pdf',
excel_path,
'--outdir',
os.path.dirname(pdf_path)
]
process = subprocess.run(command, capture_output=True, text=True, check=True)
print("Success!")
return True
except subprocess.CalledProcessError as e:
print(f"Error converting with LibreOffice: {e}")
print(f"Stdout: {e.stdout}")
print(f"Stderr: {e.stderr}")
return False
except FileNotFoundError:
print("Error: soffice command not found")
return False
except Exception as e:
print(f"Unknown error: {e}")
return False