comet.CExcelBook ******************************************************************************* .. py:class:: comet.CExcelBook This section describes all functions for the comet.CExcelBook class. .. seealso:: Module :py:mod:`comet.excel` Accessor and utility functions for excel files. CExcelBook represents an opened Excel file in memory. This class can be used to query the Excel sheets for information and content. .. container:: priint-block **Important**: When querying cell attributed like border styles etc..., you have to fetch them from the actual indices and not the anchor cell.\n e.g. When trying to determine the right border of a cell merged from column 0-1, you have to query the right border color at column 1. Methods =============================================================================== .. automethod:: comet.CExcelBook.getSheetCount .. automethod:: comet.CExcelBook.getSheetName .. automethod:: comet.CExcelBook.getFirstRow .. automethod:: comet.CExcelBook.getLastRow .. automethod:: comet.CExcelBook.getFirstColumn .. automethod:: comet.CExcelBook.getLastColumn .. automethod:: comet.CExcelBook.getCellType .. automethod:: comet.CExcelBook.getCellFormula .. automethod:: comet.CExcelBook.getCellFormat .. automethod:: comet.CExcelBook.getCellFormatTags .. automethod:: comet.CExcelBook.getCellArea .. automethod:: comet.CExcelBook.getRowHeight .. automethod:: comet.CExcelBook.getColumnWidth .. automethod:: comet.CExcelBook.getColor .. automethod:: comet.CExcelBook.getBorderStyle .. automethod:: comet.CExcelBook.getFontFamily .. automethod:: comet.CExcelBook.getFontFace .. automethod:: comet.CExcelBook.getFontSize .. automethod:: comet.CExcelBook.getFontColor .. automethod:: comet.CExcelBook.getFontStrikeThrough .. automethod:: comet.CExcelBook.getFontUnderline .. automethod:: comet.CExcelBook.getFontPosition .. automethod:: comet.CExcelBook.getFontWeight .. automethod:: comet.CExcelBook.getFontItalic .. automethod:: comet.CExcelBook.getCellContent .. automethod:: comet.CExcelBook.setCellContent .. automethod:: comet.CExcelBook.save .. automethod:: comet.CExcelBook.close Special methods =============================================================================== .. automethod:: comet.CExcelBook.__repr__ Examples =============================================================================== .. code-block:: python :caption: Open an excel file and fetch all cell data as HTML #!py #pragma plain import comet import datetime import time def getCellStyle(book: comet.CExcelBook, sheet, column, row): #Get the cell style information as HTML by querying cell format #attributes and translating them to CSS tags openTag = '{formatStr}' except: pass #Retrieve cell formula if available try: formula = ebook.getCellFormula(sheet, column, row) if formula: cellValue += f' {formula}' except: pass cellValue += closeTag completeData += cellValue completeData += '
' completeData += '
' #Log and update the output frame comet.wlog(completeData) comet.gFrame.replace(completeData) #Close the Excel file ebook.close() return 0