I am new to Django and I have a Django application where once you upload few excel files, it does a background calculation and saves the results in an excel file. I need to show those excel files with minimal processing in the Django home page as datatable. I tried django-excel package with Iframe to do so. I am not not able to get the page. Please suggest if the code below needs to be modified. Is there any other ways to solve this problem?
In 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)
In 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>
What I want the resulting excel file displayed in the Home page when a "showCombined" button is clicked