#NEWLINE# def import_book( dbook , in_stream , headers = True ) : #NEWLINE# #INDENT# 'Returns databook from XLS stream.' #NEWLINE# dbook . wipe ( ) #NEWLINE# xls_book = openpyxl . reader . excel . load_workbook ( BytesIO ( in_stream ) ) #NEWLINE# for sheet in xls_book . worksheets : #NEWLINE# #INDENT# data = tablib . Dataset ( ) #NEWLINE# data . title = sheet . title #NEWLINE# for ( i , row ) in enumerate ( sheet . rows ) : #NEWLINE# #INDENT# row_vals = [ c . value for c in row ] #NEWLINE# if ( ( i == 0 ) and headers ) : #NEWLINE# #INDENT# data . headers = row_vals #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data . append ( row_vals ) #NEWLINE# #UNINDENT# #UNINDENT# dbook . add_sheet ( data )