Django: Как загрузить данные в excel из фронтенда
У нас есть HTML страница, где данные заполняются в таблице. Данные в таблицу поступают из ответа API. Эти API вызываются с помощью Django. Файл view.py возвращает данные на веб-страницу HTML.
Я ищу решение, когда клиент нажимает на кнопку загрузки, то данные, которые отображаются в таблице, должны загружаться в файл excel.
Здесь "transaction" содержит данные, возвращенные API, которые пользователь хотел бы загрузить
<div class="card-header-left">
<i class="fa fa-print" style="font-size:22px;color:#c30038;margin-left: -3px;"></i>
<i class="fa fa-download" style="font-size:22px;color:#c30038;margin-left: 40px;"></i>
</div>
<div class="card-block p-b-0">
<div class="table-responsive">
<div id="table-wrapper">
<div id="table-scroll">
<table class="table table-hover m-b-0">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Mobile</th>
<th>Email</th>
<th>Id</th>
</tr>
</thead>
<tbody>
{% load tag_filter %}
{% for i in transaction %}
<tr>
<td class="{% if forloop.counter|divisibleby:2 %}list{% endif %}">{{i.name|slice:"0:20"}}</td>
<td class="{% if forloop.counter|divisibleby:2 %}list{% endif %}">{{i.age }}</td>
<td class="{% if forloop.counter|divisibleby:2 %}list{% endif %}">{{i.mobile}}</td>
<td class="{% if forloop.counter|divisibleby:2 %}list{% endif %}">{{i.email}}</td>
<td class="{% if forloop.counter|divisibleby:2 %}list{% endif %}">{{i.id}}</td>
</tr>
{% endfor %}