def export(self): """ Excel 模板下载 :return: """ excel_data = { 'heroes': [['name']], 'quotations': [['content', 'audio_url', 'hero_name']] } book = pyexcel.get_book(bookdict=excel_data) return excel.make_response(book, file_type='xls', file_name='data_template')
def upload_array(struct_type): if struct_type == "array": array = request.get_array(field_name='file') return excel.make_response_from_array(array, 'xls', sheet_name='test_array') elif struct_type == "dict": adict = request.get_dict(field_name='file') return excel.make_response_from_dict(adict, 'xls', sheet_name='test_array') elif struct_type == "records": records = request.get_records(field_name='file') return excel.make_response_from_records(records, 'xls', sheet_name='test_array') elif struct_type == "book": book = request.get_book(field_name='file') return excel.make_response(book, 'xls') elif struct_type == "book_dict": book_dict = request.get_book_dict(field_name='file') return excel.make_response_from_book_dict(book_dict, 'xls')
def swtich_file_name(file_type, file_name): return excel.make_response(pe.Sheet([["a", "b", "c"]]), file_type, file_name=file_name)
def switch(file_type): try: sheet = request.get_sheet(field_name='file') return excel.make_response(sheet, file_type) except IOError: abort(400)