Excel-Export by Script

Hello there,

our customers need to create an current excel file of their Stock Items every day. We have HTML in our descriptions, so we can’t use CSV.

We need a filter to only output items, which are on stock.

How can we realize this?

Thank you in advance.

Use a python library like xlsx (?)

@rmehta Thank you. The demo script works on my server and creates a Excel File by running python hello.py

But I can’t even import it in ERPNext. When I run my script in erpnext, I see the following error:

Traceback (innermost last):
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py", line 57, in application
    response = frappe.handler.handle()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py", line 30, in execute_cmd
    method = get_attr(cmd)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py", line 114, in get_attr
    method = frappe.get_attr(cmd)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 789, in get_attr
    return getattr(get_module(modulename), methodname)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 599, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
  File "/home/ubuntu/frappe-bench/apps/ci_excel/ci_excel/ci_excel/doctype/exportieren/exportieren.py", line 39, in 
    import xlsxwriter
 ImportError: No module named xlsxwriter

This seems to be a ERPNext / Frappe problem, or not?

Fixed by doing the following:

import sys

Maybe it helps someone

1 Like