mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Provide Performance Platform report as Excel file
This is the format we need to upload it in, so this means not having to manually re-save it as Excel.
This commit is contained in:
17
app/utils.py
17
app/utils.py
@@ -4,7 +4,7 @@ import re
|
||||
import unicodedata
|
||||
from datetime import datetime, time, timedelta, timezone
|
||||
from functools import wraps
|
||||
from io import StringIO
|
||||
from io import BytesIO, StringIO
|
||||
from itertools import chain
|
||||
from os import path
|
||||
from urllib.parse import urlparse
|
||||
@@ -12,6 +12,7 @@ from urllib.parse import urlparse
|
||||
import ago
|
||||
import dateutil
|
||||
import pyexcel
|
||||
import pyexcel_xlsx
|
||||
import yaml
|
||||
from flask import abort, current_app, redirect, request, session, url_for
|
||||
from flask_login import current_user
|
||||
@@ -278,6 +279,20 @@ class Spreadsheet():
|
||||
pyexcel.free_resources()
|
||||
return instance
|
||||
|
||||
@property
|
||||
def as_rows(self):
|
||||
return list(csv.reader(
|
||||
self.as_csv_data.strip().splitlines(),
|
||||
quoting=csv.QUOTE_MINIMAL,
|
||||
skipinitialspace=True,
|
||||
))
|
||||
|
||||
@property
|
||||
def as_excel_file(self):
|
||||
io = BytesIO()
|
||||
pyexcel_xlsx.save_data(io, {'Sheet 1': self.as_rows})
|
||||
return io.getvalue()
|
||||
|
||||
|
||||
def get_help_argument():
|
||||
return request.args.get('help') if request.args.get('help') in ('1', '2', '3') else None
|
||||
|
||||
Reference in New Issue
Block a user