xlwt set style making error: More than 4094 XFs (styles)

前端 未结 3 722
梦毁少年i
梦毁少年i 2021-01-02 02:58

I use Xlwt for writing an excel file. it\'s cells has some style (color, alignment ,borders , ... )

when i use XFStyle and set borders and other attr of style, in s

3条回答
  •  暖寄归人
    2021-01-02 03:44

    So, for future generations, whoever you are searching for answer, you do something wrong in your code.

    Basically, what happens with your code is that you generated over 4094 different styles instances (Important, not different styles, it is enough if you create new instances of style).

    In our case we had something like:

    for i, row in enumerate(rows):
        workbook.write(i, 0, row, currency_formatter(row))
    

    Where currency formatter was created new style for each row.

    What we had to do, was to cache style per each currency if style was the same.

    So, correct fix is not to create so many styles!

    Cheers, Mike.

提交回复
热议问题