def __call__(self, *args, **kwargs): response = self.request.RESPONSE header = export.get_header(self.context) data = export.get_data(self.context) excel_response = export.create_xlsx(header, data) filename = 'export_%s.xlsx' % self.context.getId() response.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) response.setHeader( 'Content-disposition', 'attachment; filename={0}'.format(filename) ) return excel_response.read()
def get_files(self, path_prefix=u"", recursive=True, toplevel=True): """ Returns a list of two-value-tuples having the following values: - a relative path under which the file should show up in the zip - the data as either a file or a stream """ header = get_header(self.context) data = get_data(self.context) xlsx = create_xlsx(header, data) filename = '{0}.xlsx'.format(self.context.getId()) yield (u'{0}/{1}'.format(safe_unicode(path_prefix), safe_unicode(filename)), xlsx) # Recursively export folder contents. folder_contents = super(TicketBoxZipRepresentation, self).get_files( path_prefix, recursive, toplevel) for item in folder_contents: yield item