def METHOD_NAME(distributed_query):
    tmp_fh, tmp_fp = tempfile.mkstemp()
    with os.fdopen(tmp_fh, "wb") as tmp_f:
        workbook = xlsxwriter.Workbook(tmp_f)
        worksheet = workbook.add_worksheet("Results")
        columns = distributed_query.result_columns()
        row_idx = col_idx = 0
        worksheet.write_string(row_idx, col_idx, "serial number")
        for column in columns:
            col_idx += 1
            worksheet.write_string(row_idx, col_idx, column)
        worksheet.freeze_panes(1, 0)
        for dqr in distributed_query.distributedqueryresult_set.iterator():
            row_idx += 1
            col_idx = 0
            worksheet.write_string(row_idx, col_idx, dqr.serial_number)
            for column in columns:
                col_idx += 1
                val = dqr.row.get(column)
                if not val:
                    worksheet.write_blank(row_idx, col_idx, "")
                elif isinstance(val, (int, float)):
                    worksheet.write_number(row_idx, col_idx, val)
                elif isinstance(val, bool):
                    worksheet.write_boolean(row_idx, col_idx, val)
                else:
                    if not isinstance(val, str):
                        val = str(val)
                    worksheet.write_string(row_idx, col_idx, val)
        workbook.close()
    return tmp_fp