pyexcel-xlsx icon indicating copy to clipboard operation
pyexcel-xlsx copied to clipboard

Possible incomplete hidden columns detection

Open Pymancer opened this issue 5 years ago • 0 comments

If we have multiple hidden columns in a row only first column letter will be stored in column_dimensions by openpyxl, and pyexcel checks the hidden column state by it's letter, thus skipping the subsequent columns: https://github.com/pyexcel/pyexcel-xlsx/blob/b7e4e62e6ed07c0b3858979d754b865d93bba5d0/pyexcel_xlsx/xlsxr.py#L101 Shouldn't they also be checked for hidden state with something like:

    def is_column_hidden(self, column_index):
        letter = openpyxl.utils.get_column_letter(column_index)
        for l, d in self._native_sheet.column_dimensions.items():
            if l > letter:
                break
            if d.hidden is True and (l == letter or (column_index >= d.min and column_index <= d.max)):
                return True

        return False

? Then https://github.com/pyexcel/pyexcel-xlsx/blob/b7e4e62e6ed07c0b3858979d754b865d93bba5d0/pyexcel_xlsx/xlsxr.py#L101 can be replaced with

if not self.is_column_hidden(column_index):

Pymancer avatar Jun 04 '20 09:06 Pymancer