Не удается экспортировать данные в исходном формате с помощью библиотеки xlwt(django)

Когда я экспортирую данные sql-запроса в excel с помощью xlwt в django, NULL преобразуются в пробелы, а булевы значения - в True и False. Но я хочу, чтобы данные экспортировались как есть.

views.py

def download_consolidatedsheet(request):
    if request.method=='POST':
        form= ConsolidatedSheetDownloadForm(request.POST)
        if form.is_valid():
            countries=form.cleaned_data.get('countries')
            output=BytesIO()
            data = get_consolidated_data(countries)
            with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
                data.to_excel(writer, sheet_name="ConsolidatedData", index=False)
                writer.save()
                filename = f"consolidated_data.xlsx"
                res = HttpResponse(
                output.getvalue(),
                content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                    )
                res['Content-Disposition'] = f'attachment; filename={filename}'
                return res
        # else:
        #     messages.error(request, 'Invalid form submission.')
        #     messages.error(request, form.errors)
    else:
        form = ConsolidatedSheetDownloadForm()
    
    return render(request, 'admin/consolidated_sheet_download.html',{'form':form})

controller.py

def get_consolidated_data(country):

    cursor = connection.cursor()

    query = f"""    
            @sql_query@
           """
    
    #print (query)
    result_data=cursor.execute(query)
    result=dictfetchall(result_data)
    df=pd.DataFrame(result)
    
    return df
Вернуться на верх