I want to color a row with i am outputting. How can i add properties to that row. Like i want to color that row. How can i add color to that row in csv file. How can add properties like center, bold.
import csv
from django.http import HttpResponse
def GenerateCompanyCSV(request):
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="Company_Report-%s.csv"' % datetime.date.today()
query_set = Company.objects.exclude(id=1).exclude(
company_is_deleted=True
).annotate(
number_of_company_users=Count('userprofile')
)
output = []
for query in query_set:
output.append([
query.company_name,
query.company_email,
query.number_of_company_users,
query.company_created,
query.company_monthly_payment,
query.company_tab_opts,
query.company_status,
])
writer = csv.writer(response)
# Output Color for this row
writer.writerow(['Company Name', 'Company Email', 'Count Of Total Users', 'Created Date', 'Current Monthly Payment', 'Is TABopts Customer', 'Status'])
#CSV Data
writer.writerows(output)
return response