How to use the pyexcelerate.Range.Range function in PyExcelerate

To help you get started, we’ve selected a few PyExcelerate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kz26 / PyExcelerate / pyexcelerate / Range.py View on Github external
def coordinate_to_string(coord):
        if coord[1] == float('inf'):
            return 'IV%s' % str(coord[0])

        # convert an integer to base-26 name
        y = coord[1] - 1
        s = ''
        while y >= 0:
            d, m = divmod(y, 26)
            s = chr(m + Range.A) + s
            y = d - 1
        return s + str(coord[0])
github kz26 / PyExcelerate / pyexcelerate / Worksheet.py View on Github external
def range(self, start, end):
        # convenience method
        return Range.Range(start, end, self)
github kz26 / PyExcelerate / pyexcelerate / Range.py View on Github external
def intersection(self, range):
        """
		Calculates the intersection with another range object
		"""
        if self.worksheet != range.worksheet:
            # Different worksheet
            return None
        start = (max(self._start[0], range._start[0]),
                 max(self._start[1], range._start[1]))
        end = (min(self._end[0], range._end[0]),
               min(self._end[1], range._end[1]))
        if end[0] < start[0] or end[1] < start[1]:
            return None
        return Range(start, end, self.worksheet, validate=False)
github kz26 / PyExcelerate / pyexcelerate / Worksheet.py View on Github external
def __getitem__(self, key):
        if isinstance(key, slice):
            if key.step is not None and key.step > 1:
                raise Exception(
                    "PyExcelerate doesn't support slicing with steps")
            else:
                return Range.Range((key.start or 1, 1),
                                   (key.stop or float('inf'), float('inf')),
                                   self)
        else:
            return Range.Range((key, 1), (key, float('inf')),
                               self)  # return a row range
github kz26 / PyExcelerate / pyexcelerate / Range.py View on Github external
def __init__(self, start, end, worksheet, validate=True):
        self._start = (Range.string_to_coordinate(start) if validate
                       and isinstance(start, six.string_types) else start)
        self._end = (Range.string_to_coordinate(end) if validate
                     and isinstance(end, six.string_types) else end)
        # Following http://office.microsoft.com/en-ca/excel-help/excel-specifications-and-limits-HA103980614.aspx
        if (not (1 <= self._start[0] <= 1048576) and self._start[0] != float('inf')) \
         or (not (1 <= self._end[0] <= 1048576) and self._end[0] != float('inf')):
            raise IndexError("Row index out of bounds")
        if (not (1 <= self._start[1] <= 16384) and self._start[1] != float('inf')) \
         or (not (1 <= self._end[1] <= 16384) and self._end[1] != float('inf')):
            raise IndexError("Column index out of bounds")
        self.worksheet = worksheet
        self.is_cell = (self._start == self._end)

        self.is_row = (self._end[1] == float('inf')
                       and self._start[0] == self._end[0]
                       and self._start[1] == 1)
github kz26 / PyExcelerate / pyexcelerate / Range.py View on Github external
def string_to_coordinate(s):
        # Convert a base-26 name to integer
        y = 0
        l = len(s)
        for index, c in enumerate(s):
            if ord(c) < Range.A or ord(c) > Range.Z:
                s = s[index:]
                break
            y *= 26
            y += ord(c) - Range.A + 1
        if len(s) == l:
            return y
        else:
            return (int(s), y)
github kz26 / PyExcelerate / pyexcelerate / Worksheet.py View on Github external
def __getitem__(self, key):
        if isinstance(key, slice):
            if key.step is not None and key.step > 1:
                raise Exception(
                    "PyExcelerate doesn't support slicing with steps")
            else:
                return Range.Range((key.start or 1, 1),
                                   (key.stop or float('inf'), float('inf')),
                                   self)
        else:
            return Range.Range((key, 1), (key, float('inf')),
                               self)  # return a row range
github kz26 / PyExcelerate / pyexcelerate / Range.py View on Github external
def style(self):
        if self.is_row:
            return self.__get_attr(self.worksheet.get_cell_style,
                                   Range.AttributeInterceptor(
                                       self.worksheet.get_row_style(self.x),
                                       ''))
        return self.__get_attr(self.worksheet.get_cell_style,
                               Range.AttributeInterceptor(self, 'style'))