def _write_content_types_file(self): # Write the ContentTypes.xml file. content = ContentTypes() content._add_image_types(self.workbook.image_types) worksheet_index = 1 chartsheet_index = 1 for worksheet in self.workbook.worksheets(): if worksheet.is_chartsheet: content._add_chartsheet_name('sheet' + str(chartsheet_index)) chartsheet_index += 1 else: content._add_worksheet_name('sheet' + str(worksheet_index)) worksheet_index += 1 for i in range(1, self.chart_count + 1): content._add_chart_name('chart' + str(i)) for i in range(1, self.drawing_count + 1): content._add_drawing_name('drawing' + str(i)) if self.num_vml_files: content._add_vml_name() for i in range(1, self.table_count + 1): content._add_table_name('table' + str(i)) for i in range(1, self.num_comment_files + 1): content._add_comment_name('comments' + str(i)) # Add the sharedString rel if there is string data in the workbook. if self.workbook.str_table.count: content._add_shared_strings() # Add vbaProject if present. if self.workbook.vba_project: content._add_vba_project() content._set_xml_writer(self._filename('[Content_Types].xml')) content._assemble_xml_file()