title: Python - Converting XLSX to PDF
body: <p>I have always used <code>win32com</code> module in my development server to easily convert from <code>xlsx</code> to <code>pdf</code>:</p>
  
  <pre><code>o = win32com.client.Dispatch("Excel.Application")
  o.Visible = False
  o.DisplayAlerts = False
  wb = o.Workbooks.Open("test.xlsx")))
  wb.WorkSheets("sheet1").Select()
  wb.ActiveSheet.ExportAsFixedFormat(0, "test.pdf")
  o.Quit()
  </code></pre>
  
  <p>However, I have deployed my <code>Django</code> app in production server where I don't have Excel application installed and it raises the following error:</p>
  
  <pre><code>File "C:\virtualenvs\structuraldb\lib\site-packages\win32com\client\__init__.p
  y", line 95, in Dispatch
      dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
  lsctx)
    File "C:\virtualenvs\structuraldb\lib\site-packages\win32com\client\dynamic.py
  ", line 114, in _GetGoodDispatchAndUserName
      return (_GetGoodDispatch(IDispatch, clsctx), userName)
    File "C:\virtualenvs\structuraldb\lib\site-packages\win32com\client\dynamic.py
  ", line 91, in _GetGoodDispatch
      IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
  D_IDispatch)
  com_error: (-2147221005, 'Invalid class string', None, None)
  </code></pre>
  
  <p>Is there any good alternative to convert from <code>xlsx</code> to <code>PDF</code> in Python?</p>
  
  <p>I have tested xtopdf with PDFWriter, but with this solution you need to read and iterate the range and write lines one by one. I wonder if there is a more direct solution similar to win32com.client.</p>
  
  <p>Thanks!</p>