#26 Annual conservation report

* adds first try for excel file downloading (WIP)
This commit is contained in:
2021-10-20 15:25:08 +02:00
parent e22e390040
commit 419a48cff1
4 changed files with 69 additions and 24 deletions

View File

@@ -5,10 +5,13 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 18.10.21
"""
from tempfile import NamedTemporaryFile
from django.contrib.gis.db.models import MultiPolygonField
from django.contrib.gis.db.models.functions import NumGeometries
from django.db.models import Count, Sum, Q
from django.db.models.functions import Cast
from openpyxl import Workbook
from analysis.settings import LKOMPVZVO_PUBLISH_DATE
from codelist.models import KonovaCode
@@ -16,6 +19,7 @@ from codelist.settings import CODELIST_LAW_ID
from compensation.models import Compensation, Payment, EcoAccountDeduction, EcoAccount
from intervention.models import Intervention
from konova.models import Geometry
from konova.utils.generators import generate_random_string
class TimespanReport:
@@ -363,3 +367,12 @@ class TimespanReport:
self.compensation_report = self.CompensationReport(self.office_id, date_from, date_to)
self.eco_account_report = self.EcoAccountReport(self.office_id, date_from, date_to)
self.old_intervention_report = self.OldInterventionReport(self.office_id, date_from, date_to)
def to_excel_file(self):
workbook = Workbook()
tmp_file = NamedTemporaryFile()
ws = workbook.active
ws["A1"] = "TEST"
workbook.save(tmp_file.name)
tmp_file.seek(0)
return tmp_file