def _create_excel_workbook(self, columns, submission_list, submission_type):
        file_name = export_filename(submission_type, self.project_name)
        workbook_file = AdvancedQuestionnaireSubmissionExporter(self.form_model, columns, self.local_time_delta,
                                                                self.preferences).create_excel(submission_list, self.is_single_sheet)
        workbook_file.close()

        return file_name, workbook_file
    def _create_response(self, columns, submission_list, submission_type, hide_codes_sheet=False):
        file_name = slugify(export_filename(submission_type, self.project_name))
        workbook_file = AdvancedQuestionnaireSubmissionExporter(self.form_model, columns,
                                                                self.local_time_delta, self.preferences).create_excel(submission_list, self.is_single_sheet)

        workbook_file.seek(0)
        response = HttpResponse(FileWrapper(workbook_file),
                                mimetype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

        response['Content-Disposition'] = "attachment; filename=%s.xlsx" % file_name
        return response
Пример #3
0
    def create_excel_response(self, submission_type, query_params):
        columns = SubmissionExcelHeader(self.form_model, submission_type).get_columns()


        entity_headers, paginated_query, query_with_criteria = SubmissionQuery(self.form_model,
                                                                               query_params).query_to_be_paginated(
                                                                                self.form_model.id,
                                                                                self.user)
        submission_list = query_with_criteria.values_dict(tuple(entity_headers))

        header_list, formatted_values = SubmissionFormatter(columns).format_tabular_data(submission_list)
        return create_excel_response(header_list, formatted_values, export_filename(submission_type, self.project_name))
Пример #4
0
 def _create_response(self,
                      columns,
                      submission_list,
                      submission_type,
                      hide_codes_sheet=False):
     header_list, submission_formatter = self._get_header_list(columns)
     return export_to_new_excel(header_list,
                                submission_list,
                                export_filename(submission_type,
                                                self.project_name),
                                submission_formatter,
                                hide_codes_sheet,
                                questionnaire=self.form_model)
Пример #5
0
 def _create_response(self, columns, submission_list, submission_type):
     header_list, submission_formatter = self._get_header_list(columns)
     return export_to_new_excel(header_list, submission_list, export_filename(submission_type, self.project_name),
                                submission_formatter)