working with excel files the openpyxl workbook class the key element in the openpyxl library is the workbook class this can be imported from the modulefrom openpyxl import workbook new instance of the (in memoryworkbook can be created using the workbook class (note at this point it is purely structure within the python program and must be saved before an actual excel file is createdwb workbook( the openpyxl worksheet objects workbook is always created with at least one worksheet you can get hold of the currently active worksheet using the workbook active propertyws wb active you can create additional worksheets using the workbookscreate_sheet (methodws wb create_sheet('mysheet'you can access or update the title of the worksheet using the title propertyws title 'new titlethe background colour of the tab holding this title is white by default you can change this providing an rrggbb colour code to the worksheet sheet_properties tabcolor attributefor examplews sheet_properties tabcolor " ba working with cells it is possible to access the cells within worksheet cell can be accessed directly as keys on the worksheetfor examplews[' '