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
Copy file name to clipboardExpand all lines: doc/source/index.rst
+52-32Lines changed: 52 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ Then run the test application::
99
99
Handle excel file upload and download
100
100
++++++++++++++++++++++++++++++++++++++
101
101
102
-
This example shows how to process uploaded excel file and how to make data download as an excel file. Open your browser and visit http://localhost:8000/upload, you shall see this upload form:
102
+
This example shows how to process uploaded excel file and how to make data download as an excel file. Open your browser and visit http://localhost:8000/polls/upload, you shall see this upload form:
103
103
104
104
.. image :: upload-form.png
105
105
@@ -125,7 +125,7 @@ Please open the file `polls/views.py <https://github.com/chfw/django-excel/blob/
125
125
126
126
**UploadFileForm** is html widget for file upload form in the html page. Then look down at **filehandle**. It is an instance of either ExcelInMemoryUploadedFile or TemporaryUploadedExcelFile, which inherit ExcelMixin and hence have a list of conversion methods to call, such as get_sheet, get_array, etc.
127
127
128
-
For the response, :meth:`~django_excel.make_response` converts :class:`~pyexcel.Sheet` instance obtained via :meth:`~django_excel.ExcelMixin.get_sheet` into a csv file for download.
128
+
For the response, :meth:`~django_excel.make_response` converts :class:`pyexcel.Sheet` instance obtained via :meth:`~django_excel.ExcelMixin.get_sheet` into a csv file for download.
129
129
130
130
Please feel free to change those functions according to :ref:`the mapping table <data-types-and-its-conversion-funcs>`.
131
131
@@ -173,7 +173,7 @@ into the following data models::
173
173
.. note::
174
174
Except the added "slug" field, **Question** and **Choice** are copied from Django tutoial part 1.
175
175
176
-
Please visit this link http://localhost:8000/import/, you shall see this upload form:
176
+
Please visit this link http://localhost:8000/polls/import/, you shall see this upload form:
177
177
178
178
.. image:: import-page.png
179
179
@@ -236,7 +236,7 @@ The custom formatting function is needed when the data from the excel sheet need
236
236
Handle data export
237
237
++++++++++++++++++++++++++++++
238
238
239
-
This section shows how to export the data in your models as an excel file. After you have completed the previous section, you can visit http://localhost:8000/export/book and you shall get a file download dialog:
239
+
This section shows how to export the data in your models as an excel file. After you have completed the previous section, you can visit http://localhost:8000/polls/export/book and you shall get a file download dialog:
240
240
241
241
.. image:: download-dialog.png
242
242
@@ -253,7 +253,24 @@ Now let's examine the code behind this in `polls/views.py <https://github.com/ch
:meth:`~django_excel.make_response_from_tables` does all what is needed: read out the data, convert them into xls and give it the browser. And what you need to do is to give a list of models to be exported and a file type. As you have noticed, you can visit http://localhost:8000/exportsheet and will get **Question** exported as a single sheet file.
256
+
:meth:`~django_excel.make_response_from_tables` does all what is needed: read out the data, convert them into xls and give it the browser. And what you need to do is to give a list of models to be exported and a file type. As you have noticed, you can visit http://localhost:8000/polls/export/sheet and will get **Question** exported as a single sheet file.
257
+
258
+
Handle custom data export
259
+
+++++++++++++++++++++++++++++++
260
+
261
+
It is also quite common to download a portion of the data in a database table, for example the result of a search query. With version 0.0.2, you can pass on a query sets to to :meth:`~django_excel.make_response_from_query_sets` and generate an excel sheet from it::
:param tables: a list of database tables or tuples which have this sequence (table, table_init_func, mapdict, name_columns_by_row, name_rows_by_column), see :meth:`~ExcelMixin.save_to_database`
346
-
:param keywords: additional keywords to pyexcel library
0 commit comments