Esempio n. 1
0
def xlsxify(rows):
    '''Expects a list of dictionaries and returns an xlsx response.'''
    sfp = StringIO()
    with xlsxwriter.Workbook(sfp) as workbook:
        # create a single worksheet for the provided rows
        add_worksheet(workbook, 'worksheet', rows)
    sfp.seek(0)
    return send_file(sfp, mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
Esempio n. 2
0
def xlsx():
    '''Returns an xlsx file containing the entire dataset for the current
    workspace.'''
    sfp = StringIO()
    with xlsxwriter.Workbook(sfp) as workbook:
        # create a worksheet for each table in the current workspace
        for table in [t['name'] for t in get_tables()]:
            rows = query('SELECT * FROM {}'.format(table))
            add_worksheet(workbook, table, rows)
    sfp.seek(0)
    return send_file(sfp, mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
Esempio n. 3
0
def xlsxify(rows):
    '''Expects a list of dictionaries and returns an xlsx response.'''
    sfp = BytesIO()
    with xlsxwriter.Workbook(sfp) as workbook:
        # create a single worksheet for the provided rows
        add_worksheet(workbook, 'worksheet', rows)
    sfp.seek(0)
    return send_file(
        sfp,
        mimetype=
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
Esempio n. 4
0
def xlsx():
    '''Returns an xlsx file containing the entire dataset for the current
    workspace.'''
    sfp = BytesIO()
    with xlsxwriter.Workbook(sfp) as workbook:
        # create a worksheet for each table in the current workspace
        for table in [t['name'] for t in get_tables()]:
            rows = query(f"SELECT * FROM {table}")
            add_worksheet(workbook, table, rows)
    sfp.seek(0)
    return send_file(
        sfp,
        mimetype=
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
Esempio n. 5
0
def xlsx():
    '''Returns an xlsx file containing the entire dataset for the current
    workspace.'''
    sfp = BytesIO()
    with xlsxwriter.Workbook(sfp) as workbook:
        # create a worksheet for each table in the current workspace
        for table in recon.get_tables():
            rows = recon.query(f"SELECT * FROM {table}", include_header=True)
            columns = rows.pop(0)
            rows = columnize(columns, rows)
            add_worksheet(workbook, table, rows)
    sfp.seek(0)
    return send_file(
        sfp,
        mimetype=
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        as_attachment=True,
        attachment_filename=f"{current_app.config['WORKSPACE']}.xlsx")