def simple_export2xlsx(filename, titles, qs, func_data):
    """
    export as excel
    filename: file name
    titles: title for this table
    qs: queryset to export
    func_data: a function to format object to list. ex: `lambda o: [o.pk, o.name]`
    """
    output = BytesIO()
    wb = xlwt.Workbook(output)
    ws = wb.add_worksheet(filename)
    header_fmt = wb.add_format()
    header_fmt.set_bg_color('#C4D89E')
    row_idx = 0
    row_idx = xlsw_write_row(ws, row_idx, titles, header_fmt)
    for o in qs:
        row_idx = xlsw_write_row(ws, row_idx, func_data(o))
    fn = '%s-%s.xlsx' % (filename, datetime.now())
    return export_xlsx(wb, output, fn)
def simple_export2xlsx ( filename , titles , qs , func_data ) : output = BytesIO ( ) wb = xlwt . Workbook ( output ) ws = wb . add_worksheet ( filename ) header_fmt = wb . add_format ( ) header_fmt . set_bg_color ( '#C4D89E' ) row_idx = 0 row_idx = xlsw_write_row ( ws , row_idx , titles , header_fmt ) for o in qs : row_idx = xlsw_write_row ( ws , row_idx , func_data ( o ) ) fn = '%s-%s.xlsx' % ( filename , datetime . now ( ) ) return export_xlsx ( wb , output , fn )
export as excel
    filename: file name
    titles: title for this table
    qs: queryset to export
    func_data: a function to format object to list. ex: `lambda o: [o.pk, o.name]`