<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def run(self, output):
        '''Generate the report to the given output.

        :param output: writable file-like object or file path
        '''
        # Ensure folder exists.
        if self.folder_id not in self.folders.folders(self.user):
            print("E: folder not found: %s" % self.folder_name,
                  file=sys.stderr)
            return

        # Create workbook.
        wb = self.workbook = xlsxwriter.Workbook(output)

        # Create the different styles used by this report generator.
        self.formats['title'] = wb.add_format({'font_size': '18',
                                               'bold': True})

        self.formats['default'] = wb.add_format({'align': 'top'})
        self.formats['bold'] = wb.add_format({'bold': True})

        self.formats['header'] = wb.add_format({
            'bold': True,
            'align': 'center',
            'valign': 'top',
            'font_size': '14',
            'font_color': '#506050',
            'bg_color': '#f5f5f5',
            'right': 1,
            'border_color': 'white'})

        self.formats['pre'] = wb.add_format({'font_name': 'Courier',
                                             'valign': 'top'})

        self.formats['link'] = wb.add_format({'valign': 'top',
                                              'font_color': 'blue',
                                              'underline': True})

        self.formats['type_text'] = wb.add_format({
            'font_color': '#BF8645',
            'valign': 'top',
            'align': 'center'})

        self.formats['type_image'] = wb.add_format({
            'font_color': '#84BF45',
            'valign': 'top',
            'align': 'center'})

        # Generate report for a specific subfolder or *all* subfolders of
        # self.folder .
        if self.subfolder_id is None:
            self._generate_report_all()
        else:
            self._generate_report_single(self.subfolder_id)

        # done and outta here
        self.workbook.close()