Я хочу раскрасить строку, которую я вывожу. Как я могу добавить свойства в эту строку. Как будто я хочу раскрасить этот ряд. Как я могу добавить цвет к этой строке в файле csv. Как можно добавить такие свойства, как центр, жирный шрифт.
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






CSV не может этого сделать.
Вам нужен богатый формат таблицы, такой как тот, что открытый офис использует
Или тот, что Эксель использует
Возможный дубликат Записать файл csv с цветовым кодом