我是 Django 的新手,我有一个 Django 应用程序,一旦你上传了几个 excel 文件,它就会进行后台计算并将结果保存在一个 excel 文件中。我需要在 Django 主页中将那些处理最少的 excel 文件显示为数据表。我尝试使用 iframe 的 django-excel 包来执行此操作。我无法获取该页面。请提出以下代码是否需要修改。有没有其他方法可以解决这个问题?
在views.py中:
import django_excel as excel
import pyexcel as p
def show_result_files(request,foldername,outputfilenames):
file_path = path + '/Data/' + foldername
if os.path.isfile(file_path + 'Final_Results.xlsx'):
for afile in request.FILES.getlist(outputfilenames):
combined_sheet = p.get_sheet(file_path + '2020MY EWPR Combined Parts List Final.xlsx')
combined_sheet.save_as(afile.sortable.html)
from IPython.display import IFrame
IFrame("afile.sortable.html", width=600, height=500)
在 home.html 中:
<div class="inline col-md-9" id="showFinalResults">
<form method="POST" name="showCombined" action="">{% csrf_token %}
<button name="showCombined" type="submit" class="btn btn-primary">Combined Parts List</button>
</form>
</div>
<div class="inline col-md-9" id="showFinalResults">
<form method="POST" name="showCombined" enctype="multipart/form-data" action=''>{% csrf_token %}
<div class="col">
<div class="row">
<span class="btn btn-primary btn-file">
Combined Parts List <input name="SparrowFiles" id="Sparrow" type="file" multiple="">
</span>
<button name='upload_Sparrow' type="submit" class="btn btn-secondary js-upload-files" data-toggle="modal" data-target="#modal-progress_sp"">Go</button>
</div>
</div>
</form>
</div>
当单击“showCombined”按钮时,我希望在主页中显示生成的 excel 文件