XLSX saved with a lot of empty columns

Issue #801 invalid
Michał Bultrowicz
created an issue

Openpyxl shouldn't save large fields of empty (None) cells, right? At least that's what I've read in some conversation about deprecating Worksheet.garbage_collect.

Anyway, on to my problem: with Libre Calc I deleted two columns in a small file created with Excel. I'm reading this file with openpyxl (attached). Before, the row length was 16, now it's 1024.

I know this is Libre's fault, but I was expecting that after I modify and save it with openpyxl, the size would go down, gut it isn't so.

Comments (5)

  1. Michał Bultrowicz reporter

    I got around that by forcefully deleting the cells, but it's a real dirty hack:

    cells_to_delete = [(y, x) for y, x in sheet._cells if x > 13]
        for cell_location in cells_to_delete:
            del sheet._cells[cell_location]
    
  2. CharlieC

    What do you want openpyxl to do? The worksheet definitely contains the cells. File a bug report with LibreOffice if you think there is a problem (Excel certainly thinks there is).

    <x:c r="AMH1" s="0" />
    <x:c r="AMI1" s="0" />
    <x:c r="AMJ1" s="0" />
    
  3. Log in to comment