使用html表单读取Django中上传的Excel文件

使用html表单读取Django中上传的Excel文件,html,django,excel,python-3.x,web,Html,Django,Excel,Python 3.x,Web,我正在学习django框架并尝试阅读excel文件 我想使用html表单(POST方法)上传文件,并想读取python中的计算结果,所以我应该怎么做? 代码在这里 form.html <form method="POST" action="minmax_ans.html">{% csrf_tocken %} {{form.as_p}} <p><b><h2>Upload File</h2></b><p>

我正在学习django框架并尝试阅读excel文件

我想使用html表单(POST方法)上传文件,并想读取python中的计算结果,所以我应该怎么做? 代码在这里 form.html

<form method="POST" action="minmax_ans.html">{% csrf_tocken %}
   {{form.as_p}}
   <p><b><h2>Upload File</h2></b><p>
   <input type="file" name="file" value="{{ source.title }}">
   <input type="submit">
</form>

如果文件是excel文件,我想使用通过html表单上传的文件中的数据进行一些计算,并在result.html上显示结果,我还没有创建result.html,因为我无法读取文件

可能我会先阅读Django文档:

要读取excel文件,可以使用
pandas


我可能会从阅读Django文档开始:

要读取excel文件,可以使用
pandas


你可以这样做

import pandas as pd
def handle_uploaded_file(f):
    pd.read_excel(f, index_col=0)

Pandas read\u excel接受str、ExcelFile、xlrd.Book、path对象或类似文件的对象中的参数io。

您可以这样做

import pandas as pd
def handle_uploaded_file(f):
    pd.read_excel(f, index_col=0)

Pandas read_excel接受str、ExcelFile、xlrd.Book、path对象或类文件对象中的参数io。

请显示您尝试过的内容和不适用的内容。请展示你已经尝试过的和不适合你的。