Added 'excelexporters.spaceoutput.export()' method

pull/4/head
YangZhang-GitHub 2021-03-04 20:34:03 +08:00
parent 7796eeed5f
commit 22ba6615f4
1 changed files with 15 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import config
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from core import utilities from core import utilities
from decimal import Decimal from decimal import Decimal
import excelexporters.spaceoutput
class Reporting: class Reporting:
@ -545,4 +546,11 @@ class Reporting:
result['child_space']['subtotals_array'].append( result['child_space']['subtotals_array'].append(
child_space_data[energy_category_id]['subtotals']) child_space_data[energy_category_id]['subtotals'])
# export result to Excel file and then encode the file to base64 string
result['excel_bytes_base64'] = excelexporters.spaceoutput.export(result,
space['name'],
reporting_start_datetime_local,
reporting_end_datetime_local,
period_type)
resp.body = json.dumps(result) resp.body = json.dumps(result)