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
+12-4Lines changed: 12 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -67,13 +67,17 @@ Then run the test application::
67
67
Quit the server with CTRL-BREAK.
68
68
69
69
70
-
Handle excel file upload
71
-
+++++++++++++++++++++++++
70
+
Handle excel file upload and download
71
+
++++++++++++++++++++++++++++++++++++++
72
72
73
-
If you open your browser and visit http://localhost:8000/upload, you shall see this upload form:
73
+
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:
74
74
75
75
.. image :: upload-form.png
76
76
77
+
Choose an excel sheet, for example an xls file, and press "Submit". You will get a csv file for download.
78
+
79
+
.. image :: download-file.png
80
+
77
81
Please open the file **polls/views.py** and focus on the following code section::
78
82
79
83
class UploadFileForm(forms.Form):
@@ -90,10 +94,12 @@ Please open the file **polls/views.py** and focus on the following code section:
**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.
97
+
**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.:meth:`~django_excel.make_response` converts :class:`~pyexcel.Sheet` instance obtained via :meth:`~django_excel.ExcelMixin.get_sheet` into a csv file for download. Please feel free to change those functions according to :ref:`the mapping table <data-types-and-its-conversion-funcs>`.
0 commit comments