Issue When Opening Document From Acumatica

595 views
Skip to first unread message

brandon...@gmail.com

unread,
Jun 6, 2018, 1:17:24 PM6/6/18
to openpyxl-users
Hello!

Just discovered openpyxl and have mostly gotten everything working with test worksheets, but when I download a sheet from Acumatica directly, it gives me a few errors. The errors I'm getting are: 
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert
    value = expected_type(value)
TypeError: object() takes no parameters

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\brandon\Downloads\Inventory_Updater\Inventory_Update.py", line 18, in <module>
    wb = openpyxl.load_workbook(excelFile)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\reader\excel.py", line 223, in load_workbook
    apply_stylesheet(archive, wb) # bind styles to workbook
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\styles\stylesheet.py", line 178, in apply_stylesheet
    stylesheet = Stylesheet.from_tree(node)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\styles\stylesheet.py", line 100, in from_tree
    return super(Stylesheet, cls).from_tree(node)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\descriptors\serialisable.py", line 100, in from_tree
    return cls(**attrib)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\styles\stylesheet.py", line 71, in __init__
    self.fills = fills
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\descriptors\sequence.py", line 27, in __set__
    seq = [_convert(self.expected_type, value) for value in seq]
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\descriptors\sequence.py", line 27, in <listcomp>
    seq = [_convert(self.expected_type, value) for value in seq]
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert
    raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'openpyxl.styles.fills.Fill'>

The code I'm using for this is:
#Import different packages for compatibility
import datetime
import requests
import openpyxl

# Set date for correct filename as it will change each day
now = datetime.datetime.now()
currentDate = now.strftime("%Y-%m-%d")

# Set the correct Excel filename
excelFile = "Inventory Balance (%s).xlsx" % (currentDate)

# Open the appropriate Excel inventory file and set it to active worksheet
wb = openpyxl.load_workbook(excelFile)
ws = wb.active


Here's the kicker -- If I open the downloaded inventory report from Acumatica, make zero changes, but press the save button, then the script works perfectly and gives me an output based on my loop showing the inventory SKU and the inventory quantity. However, I need this to work off of a direct download from Acumatica (it downloads in .xlsx format)

If anyone has any ideas on this, some help would be greatly appreciated.

Charlie Clark

unread,
Jun 7, 2018, 3:44:04 AM6/7/18
to openpyx...@googlegroups.com
Am .06.2018, 19:17 Uhr, schrieb <brandon...@gmail.com>:

> Here's the kicker -- If I open the downloaded inventory report from
> Acumatica, make zero changes, but press the save button, then the script
> works perfectly and gives me an output based on my loop showing the
> inventory SKU and the inventory quantity. However, I need this to work
> off of a direct download from Acumatica (it downloads in .xlsx format)

I've no idea what Acumatica is but from the traceback and this note I
suspect that the source file contains invalid fill definitions, presumably
an empty fill element. Excel tends to be quite forgiving in such cases and
silently fixes the issue but we always raise an exception as early as
possible, which is particularly when you're processing files
automatically. Can't say more without a file.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

brandon...@gmail.com

unread,
Jun 7, 2018, 8:37:07 AM6/7/18
to openpyxl-users
Hey Charlie,

Thanks for the reply. Acumatica is a cloud ERP system that provides companies with a centralized location for sales orders, sales report, inventory reporting, and more. It's a platform that allows for direct Excel exports of different reports, such as inventory in this case. Unfortunately, I'm not able to provide a file as it contains company information. I'll take your advice, however, to see if maybe there is an issue with, as you said, one of the fill elements.

Charlie Clark

unread,
Jun 7, 2018, 9:06:12 AM6/7/18
to openpyx...@googlegroups.com
Am .06.2018, 14:37 Uhr, schrieb <brandon...@gmail.com>:

> Thanks for the reply. Acumatica is a cloud ERP system that provides
> companies with a centralized location for sales orders, sales report,
> inventory reporting, and more. It's a platform that allows for direct
> Excel exports of different reports, such as inventory in this case.
> Unfortunately, I'm not able to provide a file as it contains company
> information. I'll take your advice, however, to see if maybe there is an
> issue with, as you said, one of the fill elements.

Presumably they're using something like Apache POI to create the files and
it's creating invalid styles.

See https://bitbucket.org/openpyxl/openpyxl/issues/913/typeerror-expected

For something similar.
Reply all
Reply to author
Forward
0 new messages