You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tiny application exposes two urls: one for file upload and the other for file download. The former url presents a simple file upload html and responds back in json with the content of the uploaded file. Here is an `example file <https://github.com/pyexcel/Flask-Excel/blob/master/examples/example_for_upload.csv>` for testing but you can upload any other excel file. The file upload handler uses `request.get_array` to parse the uploaded file and gets an array back. The parameter **file** is coded in the html form::
20
+
The tiny application exposes two urls: one for file upload and the other for
21
+
file download. The former url presents a simple file upload html and responds
22
+
back in json with the content of the uploaded file. Here is an
for testing but you can upload any other excel file. The file upload handler
25
+
uses `request.get_array` to parse the uploaded file and gets an array back.
26
+
The parameter **file** is coded in the html form::
51
27
52
28
<input ... name=file>
53
29
54
30
.. warning::
55
-
If 'field_name' was not specified, for example `request.get_array('file')` in upload_file() function, your browser would display "Bad Request: The browser (or proxy) sent a request that this server could not understand."
31
+
If 'field_name' was not specified, for example `request.get_array('file')`
32
+
in upload_file() function, your browser would display "Bad Request: The
33
+
browser (or proxy) sent a request that this server could not understand."
56
34
57
-
The latter simply throws back a csv file whenever a http request is made to http://localhost:50000/download/. `excel.make_response_from_array` takes a list of lists and a file type as parameters and sets up the mime type of the http response. If you would like to give 'tsvz' a go, please change "csv" to "tsvz".
35
+
The latter simply throws back a csv file whenever a http request is made to
36
+
http://localhost:50000/download/. `excel.make_response_from_array` takes a
37
+
list of lists and a file type as parameters and sets up the mime type of the
38
+
http response. If you would like to give 'tsvz' a go, please change "csv" to
The example application understands csv, tsv and its zipped variants: csvz and tsvz. If you would like to expand the list of supported excel file formats (see :ref:`file-format-list`) for your own application, you could include one or all of the following import lines right after **Flask-Excel** is imported::
46
+
The example application understands csv, tsv and its zipped variants: csvz and
47
+
tsvz. If you would like to expand the list of supported excel file formats
48
+
(see :ref:`file-format-list`) for your own application, you could include one
49
+
or all of the following import lines right after **Flask-Excel** is imported::
Continue with the previous example, the data import and export will be explained. You can copy the following code in their own appearing sequence and paste them after the place holder::
59
+
Continue with the previous example, the data import and export will be explained.
60
+
You can copy the following code in their own appearing sequence and paste them
61
+
after the place holder::
75
62
76
63
# insert database related code here
77
64
78
-
Alternatively, you can find the complete example on `github <https://github.com/pyexcel/Flask-Excel/blob/master/examples/database_example.py>`_
65
+
Alternatively, you can find the complete example on
Then run the example again. Visit http://localhost:5000/import and upload `sample-data.xls <https://github.com/pyexcel/Flask-Excel/blob/master/sample-data.xls>`_ . Then visit http://localhost:5000/export to download the data back.
Previous example shows you how to dump one or more tables over http protocol. Hereby, let's look at how to turn a query sets into an excel sheet. You can
172
-
pass a query sets and an array of selected column names to :meth:`~flask_excel.make_response_from_query_sets` and generate an excel sheet from it::
112
+
Previous example shows you how to dump one or more tables over http protocol.
113
+
Hereby, let's look at how to turn a query sets into an excel sheet. You can
114
+
pass a query sets and an array of selected column names to
115
+
:meth:`~flask_excel.make_response_from_query_sets` and generate an excel sheet from it:
0 commit comments