unwanted conversion from string to numeric
Created originally on Bitbucket by robfelty
I just ran into an issue where I had a cell with the value "0900". I was surprised to find that this was automatically converted to a numeric type of 900. I tried explicitly setting it to be a string, which did successfully change the cell.data_type to string, but the value was now "900" instead of "0900". The only way I could figure out to fix it was to modify the openpyxl code in cell.py
Would it be possible to create an option or something so that this sort of type conversion is not done automatically?
Thanks for all your great work on this project. It is much appreciated!
{{{ #!python def data_type_for_value(self, value): """Given a value, infer the correct data type""" if value is None: data_type = self.TYPE_NULL elif value is True or value is False: data_type = self.TYPE_BOOL elif isinstance(value, NUMERIC_TYPES): data_type = self.TYPE_NUMERIC elif not value: data_type = self.TYPE_STRING elif isinstance(value, (datetime.datetime, datetime.date)): data_type = self.TYPE_NUMERIC elif isinstance(value, basestring) and value[0] == '=': data_type = self.TYPE_FORMULA #elif self.RE_PATTERNS['numeric'].match(value): # data_type = self.TYPE_NUMERIC elif value.strip() in self.ERROR_CODES: data_type = self.TYPE_ERROR else: data_type = self.TYPE_STRING return data_type }}}