pythonvbaopenpyxlvalueerrorxlsm

openpyxl error raise ValueError('Min value is {0}'.format(self.min)) in opening heavy file with formatting


I'm trying to use openpyxl for the first time on a very heavy file, that happens to be over 20 500 Ko, has a lot of formatting and a VBA macro.

My code keeps returning the following error:

File " \Anaconda3\lib\site-packages\openpyxl\styles\alignment.py", line 52, in __init__
    self.relativeIndent = relativeIndent
 
  File " \Anaconda3\lib\site-packages\openpyxl\descriptors\base.py", line 107, in __set__
    raise ValueError('Min value is {0}'.format(self.min))
 
ValueError: Min value is 0

Would anyone know what the problem is / how to access the file despite it? I'm trying to post data into an existent Excel file to simplify processes and replace a heavy VBA code. So I can't just post it into a different xlsx file and call it using a VBA code (that would defeat the purpose).

Thanks a lot!

Here is my code :

wb = load_workbook(filename='C:/dev/CodeRep/ProjectName/MainFile 2021_01.xlsm', read_only = False, keep_vba = True)

Solution

  • I had the same issue — the file wasn't accepted by Openpyxl.

    I just opened the file in MS Excel and saved it to a new file. And it worked after that.