AGW Logo

agw_title Excel

A simple class that holds a COM interface to Excel.

By using the win32com module from Mark Hammonds’ pywin32 package, we can manipulate various workbook/worksheet methods inside this class.

hierarchy Inheritance Diagram

Inheritance diagram for: Excel

Inheritance diagram of Excel


method_summary Methods Summary

__init__Default class constructor.
CloseCloses the Excel workbook, interrupting the COM interface.
GetCommentsRangeReturns a range of cells containing comments, using the VBA API.
GetTextReturns the WYSIWYG text contained in a cell.

API Class API

class Excel(object)[source]

A simple class that holds a COM interface to Excel.

By using the win32com module from Mark Hammonds’ pywin32 package, we can manipulate various workbook/worksheet methods inside this class.



__init__(filename, sheetname)[source]

Default class constructor.

Parameters:
  • filename – a valid Excel xls filename;
  • sheetname – the worksheet name inside the Excel file (i.e., the label on the workbook tab at the bottom of the workbook).


Close(save=False)[source]

Closes the Excel workbook, interrupting the COM interface.

Parameters:saveTrue to save the changes you made to the workbook, False otherwise.


GetCommentsRange()[source]

Returns a range of cells containing comments, using the VBA API.



GetText(row, col)[source]

Returns the WYSIWYG text contained in a cell.

Parameters:
  • row – the row in which the cell lives;
  • col – the column in which the cell lives.

Note

The row and col parameters are not real Python index, as they use the Excel indexing mode (i.e., first index is 1 and not 0).

Tree

Table Of Contents

Previous topic

xlsgrid

Next topic

TransientPopup