# -*- coding: utf-8 -*- """ Tablib - XLS Support. """ import sys from tablib.compat import BytesIO, xlwt, xlrd, XLRDError, xrange import tablib title = 'xls' extensions = ('xls', ) # special styles wrap = xlwt.easyxf("alignment: wrap on") bold = xlwt.easyxf("font: bold on") def detect(stream): """Returns True if given stream is a readable excel file.""" try: xlrd.open_workbook(file_contents=stream) return True except (TypeError, XLRDError): pass try: xlrd.open_workbook(file_contents=stream.read()) return True except (AttributeError, XLRDError): pass try: xlrd.open_workbook(filename=stream)
# -*- coding: utf-8 -*- """ Tablib - XLS Support. """ import sys from tablib.compat import BytesIO, xlwt, xlrd, XLRDError import tablib title = 'xls' extensions = ('xls',) # special styles wrap = xlwt.easyxf("alignment: wrap on") bold = xlwt.easyxf("font: bold on") def detect(stream): """Returns True if given stream is a readable excel file.""" try: xlrd.open_workbook(file_contents=stream) return True except (TypeError, XLRDError): pass try: xlrd.open_workbook(file_contents=stream.read()) return True except (AttributeError, XLRDError): pass try: