def __read_cell(self, cell): cell_type = cell.getAttrNS(OFFICENS, "value-type") value_token = service.VALUE_TOKEN.get(cell_type, "value") ret = None if cell_type == "string": text_content = self.__read_text_cell(cell) ret = text_content elif cell_type == "currency": value = cell.getAttrNS(OFFICENS, value_token) currency = cell.getAttrNS(OFFICENS, cell_type) if currency: ret = value + " " + currency else: ret = value else: if cell_type in service.VALUE_CONVERTERS: value = cell.getAttrNS(OFFICENS, value_token) n_value = service.VALUE_CONVERTERS[cell_type](value) if cell_type == "float" and self.__auto_detect_int: if service.has_no_digits_in_float(n_value): n_value = int(n_value) ret = n_value else: text_content = self.__read_text_cell(cell) ret = text_content return ret
def cell_value(self, row, column): """ Random access to the xls cells """ if self._keywords.get('skip_hidden_row_and_column') is True: row, column = self._offset_hidden_indices(row, column) cell_type = self._native_sheet.cell_type(row, column) value = self._native_sheet.cell_value(row, column) if cell_type == xlrd.XL_CELL_DATE: value = xldate_to_python_date(value, self._book_date_mode) elif cell_type == xlrd.XL_CELL_NUMBER and self.__auto_detect_int: if has_no_digits_in_float(value): value = int(value) elif cell_type == xlrd.XL_CELL_ERROR: value = DEFAULT_ERROR_VALUE if self.__merged_cells: merged_cell = self.__merged_cells.get("%s-%s" % (row, column)) if merged_cell: if merged_cell.value: value = merged_cell.value else: merged_cell.value = value return value
def __convert_cell(self, cell): ret = None if cell[1] in service.VALUE_CONVERTERS: n_value = service.VALUE_CONVERTERS[cell[1]](cell[0]) if cell[1] == "float" and self.__auto_detect_int: if service.has_no_digits_in_float(n_value): n_value = int(n_value) ret = n_value else: ret = cell[0] return ret
def cell_value(self, row, column): """ Random access to the xls cells """ cell_type = self._native_sheet.cell_type(row, column) value = self._native_sheet.cell_value(row, column) if cell_type == xlrd.XL_CELL_DATE: value = xldate_to_python_date(value) elif cell_type == xlrd.XL_CELL_NUMBER and self.__auto_detect_int: if has_no_digits_in_float(value): value = int(value) return value
def cell_value(self, row, column): cell = self._native_sheet.get_cell((row, column)) cell_type = cell.value_type ret = None if cell_type == 'currency': cell_value = cell.value if service.has_no_digits_in_float(cell_value): cell_value = int(cell_value) ret = str(cell_value) + ' ' + cell.currency elif cell_type in service.ODS_FORMAT_CONVERSION: value = cell.value n_value = service.VALUE_CONVERTERS[cell_type](value) if cell_type == 'float' and self.auto_detect_int: if service.has_no_digits_in_float(n_value): n_value = int(n_value) ret = n_value else: if cell.value is None: ret = "" else: ret = cell.value return ret
def cell_value(self, row, column): cell = self._native_sheet.get_cell((row, column)) cell_type = cell.value_type ret = None if cell_type == "currency": cell_value = cell.value if service.has_no_digits_in_float(cell_value): cell_value = int(cell_value) ret = str(cell_value) + " " + cell.currency elif cell_type in service.ODS_FORMAT_CONVERSION: value = cell.value n_value = service.VALUE_CONVERTERS[cell_type](value) if cell_type == "float" and self.auto_detect_int: if service.has_no_digits_in_float(n_value): n_value = int(n_value) ret = n_value else: if cell.value is None: ret = "" else: ret = cell.value return ret