@@ -261,162 +261,164 @@ API Reference
261261
262262**Flask-Excel ** attaches **pyexcel ** functions to **Request ** class.
263263
264- .. module :: flask_excel
264+ .. module :: flask_excel.request
265265
266266ExcelRequest
267267******************
268268
269- .. method :: get_sheet(field_name=None, sheet_name=None, **keywords)
269+ .. method :: get_sheet(field_name=None, sheet_name=None, **keywords)
270270
271- :param field_name: the file field name in the html form for file upload
272- :param sheet_name: For an excel book, there could be multiple sheets. If it is left
273- unspecified, the sheet at index 0 is loaded. For 'csv', 'tsv' file,
274- *sheet_name * should be None anyway.
275- :param keywords: additional keywords to :meth: `pyexcel.get_sheet `
276- :returns: A sheet object
271+ :param field_name: the file field name in the html form for file upload
272+ :param sheet_name: For an excel book, there could be multiple sheets. If it is left
273+ unspecified, the sheet at index 0 is loaded. For 'csv', 'tsv' file,
274+ *sheet_name * should be None anyway.
275+ :param keywords: additional keywords to :meth: `pyexcel.get_sheet `
276+ :returns: A sheet object
277277
278- The following html form, the *field_name * should be "file"::
279-
280- <!doctype html>
281- <title>Upload an excel file</title>
282- <h1>Excel file upload (csv, tsv, csvz, tsvz only)</h1>
283- <form action="" method=post enctype=multipart/form-data><p>
284- <input type=file name=file><input type=submit value=Upload>
285- </form>
278+ The following html form, the *field_name * should be "file"::
279+
280+ <!doctype html>
281+ <title>Upload an excel file</title>
282+ <h1>Excel file upload (csv, tsv, csvz, tsvz only)</h1>
283+ <form action="" method=post enctype=multipart/form-data><p>
284+ <input type=file name=file><input type=submit value=Upload>
285+ </form>
286286
287- .. method :: get_array(field_name=None, sheet_name=None, **keywords)
287+ .. method :: get_array(field_name=None, sheet_name=None, **keywords)
288288
289- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
290- :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
291- :param keywords: additional keywords to pyexcel library
292- :returns: a two dimensional array, a list of lists
289+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
290+ :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
291+ :param keywords: additional keywords to pyexcel library
292+ :returns: a two dimensional array, a list of lists
293293
294- .. method :: get_dict(field_name=None, sheet_name=None, name_columns_by_row=0, **keywords)
294+ .. method :: get_dict(field_name=None, sheet_name=None, name_columns_by_row=0, **keywords)
295295
296- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
297- :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
298- :param name_columns_by_row: uses the first row of the sheet to be column headers by default.
299- :param keywords: additional keywords to pyexcel library
300- :returns: a dictionary of the file content
296+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
297+ :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
298+ :param name_columns_by_row: uses the first row of the sheet to be column headers by default.
299+ :param keywords: additional keywords to pyexcel library
300+ :returns: a dictionary of the file content
301301
302- .. method :: get_records(field_name=None, sheet_name=None, name_columns_by_row=0, **keywords)
302+ .. method :: get_records(field_name=None, sheet_name=None, name_columns_by_row=0, **keywords)
303303
304- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
305- :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
306- :param name_columns_by_row: uses the first row of the sheet to be record field names by default.
307- :param keywords: additional keywords to pyexcel library
308- :returns: a list of dictionary of the file content
304+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
305+ :param sheet_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
306+ :param name_columns_by_row: uses the first row of the sheet to be record field names by default.
307+ :param keywords: additional keywords to pyexcel library
308+ :returns: a list of dictionary of the file content
309309
310- .. method :: get_book(field_name=None, **keywords)
310+ .. method :: get_book(field_name=None, **keywords)
311311
312- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
313- :param keywords: additional keywords to pyexcel library
314- :returns: a two dimensional array, a list of lists
312+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
313+ :param keywords: additional keywords to pyexcel library
314+ :returns: a two dimensional array, a list of lists
315315
316- .. method :: get_book_dict(field_name=None, **keywords)
316+ .. method :: get_book_dict(field_name=None, **keywords)
317317
318- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
319- :param keywords: additional keywords to pyexcel library
320- :returns: a two dimensional array, a list of lists
318+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
319+ :param keywords: additional keywords to pyexcel library
320+ :returns: a two dimensional array, a list of lists
321321
322- .. method :: save_to_database(field_name=None, session=None, table=None, initializer=None, mapdict=None **keywords)
322+ .. method :: save_to_database(field_name=None, session=None, table=None, initializer=None, mapdict=None **keywords)
323323
324- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
325- :param session: a SQLAlchemy session
326- :param table: a database table
327- :param initializer: a custom table initialization function if you have one
328- :param mapdict: the explicit table column names if your excel data do not have the exact column names
329- :param keywords: additional keywords to :meth: `pyexcel.Sheet.save_to_database `
324+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
325+ :param session: a SQLAlchemy session
326+ :param table: a database table
327+ :param initializer: a custom table initialization function if you have one
328+ :param mapdict: the explicit table column names if your excel data do not have the exact column names
329+ :param keywords: additional keywords to :meth: `pyexcel.Sheet.save_to_database `
330330
331- .. method :: save_book_to_database(field_name=None, session=None, tables=None, initializers=None, mapdicts=None, **keywords)
331+ .. method :: save_book_to_database(field_name=None, session=None, tables=None, initializers=None, mapdicts=None, **keywords)
332332
333- :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
334- :param session: a SQLAlchemy session
335- :param tables: a list of database tables
336- :param initializers: a list of model initialization functions.
337- :param mapdicts: a list of explicit table column names if your excel data sheets do not have the exact column names
338- :param keywords: additional keywords to :meth: `pyexcel.Book.save_to_database `
333+ :param field_name: same as :meth: `~flask_excel.ExcelRequest.get_sheet `
334+ :param session: a SQLAlchemy session
335+ :param tables: a list of database tables
336+ :param initializers: a list of model initialization functions.
337+ :param mapdicts: a list of explicit table column names if your excel data sheets do not have the exact column names
338+ :param keywords: additional keywords to :meth: `pyexcel.Book.save_to_database `
339339
340340
341341Response methods
342342**********************
343343
344- .. method :: make_response(pyexcel_instance, file_type, status=200, file_name=None)
345-
346- :param pyexcel_instance: :class: `pyexcel.Sheet ` or :class: `pyexcel.Book `
347- :param file_type: one of the following strings:
348-
349- * 'csv'
350- * 'tsv'
351- * 'csvz'
352- * 'tsvz'
353- * 'xls'
354- * 'xlsx'
355- * 'xlsm'
356- * 'ods'
357-
358- :param status: unless a different status is to be returned.
359- :param file_name: provide a custom file name for the response, excluding the file extension
360-
361- .. method :: make_response_from_array(array, file_type, status=200, file_name=None)
362-
363- :param array: a list of lists
364- :param file_type: same as :meth: `~flask_excel.make_response `
365- :param status: same as :meth: `~flask_excel.make_response `
366- :param file_name: same as :meth: `~flask_excel.make_response `
367-
368- .. method :: make_response_from_dict(dict, file_type, status=200, file_name=None)
369-
370- :param dict: a dictinary of lists
371- :param file_type: same as :meth: `~flask_excel.make_response `
372- :param status: same as :meth: `~flask_excel.make_response `
373- :param file_name: same as :meth: `~flask_excel.make_response `
374-
375- .. method :: make_response_from_records(records, file_type, status=200, file_name=None)
376-
377- :param records: a list of dictionaries
378- :param file_type: same as :meth: `~flask_excel.make_response `
379- :param status: same as :meth: `~flask_excel.make_response `
380- :param file_name: same as :meth: `~flask_excel.make_response `
381-
382- .. method :: make_response_from_book_dict(book_dict, file_type, status=200, file_name=None)
383-
384- :param book_dict: a dictionary of two dimensional arrays
385- :param file_type: same as :meth: `~flask_excel.make_response `
386- :param status: same as :meth: `~flask_excel.make_response `
387- :param file_name: same as :meth: `~flask_excel.make_response `
388-
389- .. method :: make_response_from_a_table(session, table, file_type status=200, file_name=None)
390-
391- Produce a single sheet Excel book of *file_type *
392-
393- :param session: SQLAlchemy session
394- :param table: a SQLAlchemy table
395- :param file_type: same as :meth: `~flask_excel.make_response `
396- :param status: same as :meth: `~flask_excel.make_response `
397- :param file_name: same as :meth: `~flask_excel.make_response `
398-
399- .. method :: make_response_from_query_sets(query_sets, column_names, file_type status=200, file_name=None)
400-
401- Produce a single sheet Excel book of *file_type * from your custom database queries
402-
403- :param query_sets: a query set
404- :param column_names: a nominated column names. It could not be None, otherwise no data is returned.
405- :param file_type: same as :meth: `~flask_excel.make_response `
406- :param status: same as :meth: `~flask_excel.make_response `
407- :param file_name: same as :meth: `~flask_excel.make_response `
408-
409- .. method :: make_response_from_tables(session, tables, file_type status=200, file_name=None)
410-
411- Produce a multiple sheet Excel book of *file_type *. It becomes the same
412- as :meth: `~flask_excel.make_response_from_a_table ` if you pass *tables *
413- with an array that has a single table
414-
415- :param session: SQLAlchemy session
416- :param tables: SQLAlchemy tables
417- :param file_type: same as :meth: `~flask_excel.make_response `
418- :param status: same as :meth: `~flask_excel.make_response `
419- :param file_name: same as :meth: `~flask_excel.make_response `
344+ .. module :: flask_excel
345+
346+ .. method :: make_response(pyexcel_instance, file_type, status=200, file_name=None)
347+
348+ :param pyexcel_instance: :class: `pyexcel.Sheet ` or :class: `pyexcel.Book `
349+ :param file_type: one of the following strings:
350+
351+ * 'csv'
352+ * 'tsv'
353+ * 'csvz'
354+ * 'tsvz'
355+ * 'xls'
356+ * 'xlsx'
357+ * 'xlsm'
358+ * 'ods'
359+
360+ :param status: unless a different status is to be returned.
361+ :param file_name: provide a custom file name for the response, excluding the file extension
362+
363+ .. method :: make_response_from_array(array, file_type, status=200, file_name=None)
364+
365+ :param array: a list of lists
366+ :param file_type: same as :meth: `~flask_excel.make_response `
367+ :param status: same as :meth: `~flask_excel.make_response `
368+ :param file_name: same as :meth: `~flask_excel.make_response `
369+
370+ .. method :: make_response_from_dict(dict, file_type, status=200, file_name=None)
371+
372+ :param dict: a dictinary of lists
373+ :param file_type: same as :meth: `~flask_excel.make_response `
374+ :param status: same as :meth: `~flask_excel.make_response `
375+ :param file_name: same as :meth: `~flask_excel.make_response `
376+
377+ .. method :: make_response_from_records(records, file_type, status=200, file_name=None)
378+
379+ :param records: a list of dictionaries
380+ :param file_type: same as :meth: `~flask_excel.make_response `
381+ :param status: same as :meth: `~flask_excel.make_response `
382+ :param file_name: same as :meth: `~flask_excel.make_response `
383+
384+ .. method :: make_response_from_book_dict(book_dict, file_type, status=200, file_name=None)
385+
386+ :param book_dict: a dictionary of two dimensional arrays
387+ :param file_type: same as :meth: `~flask_excel.make_response `
388+ :param status: same as :meth: `~flask_excel.make_response `
389+ :param file_name: same as :meth: `~flask_excel.make_response `
390+
391+ .. method :: make_response_from_a_table(session, table, file_type status=200, file_name=None)
392+
393+ Produce a single sheet Excel book of *file_type *
394+
395+ :param session: SQLAlchemy session
396+ :param table: a SQLAlchemy table
397+ :param file_type: same as :meth: `~flask_excel.make_response `
398+ :param status: same as :meth: `~flask_excel.make_response `
399+ :param file_name: same as :meth: `~flask_excel.make_response `
400+
401+ .. method :: make_response_from_query_sets(query_sets, column_names, file_type status=200, file_name=None)
402+
403+ Produce a single sheet Excel book of *file_type * from your custom database queries
404+
405+ :param query_sets: a query set
406+ :param column_names: a nominated column names. It could not be None, otherwise no data is returned.
407+ :param file_type: same as :meth: `~flask_excel.make_response `
408+ :param status: same as :meth: `~flask_excel.make_response `
409+ :param file_name: same as :meth: `~flask_excel.make_response `
410+
411+ .. method :: make_response_from_tables(session, tables, file_type status=200, file_name=None)
412+
413+ Produce a multiple sheet Excel book of *file_type *. It becomes the same
414+ as :meth: `~flask_excel.make_response_from_a_table ` if you pass *tables *
415+ with an array that has a single table
416+
417+ :param session: SQLAlchemy session
418+ :param tables: SQLAlchemy tables
419+ :param file_type: same as :meth: `~flask_excel.make_response `
420+ :param status: same as :meth: `~flask_excel.make_response `
421+ :param file_name: same as :meth: `~flask_excel.make_response `
420422
421423
422424Indices and tables
0 commit comments