AGW Logo

agw_title XLSGrid

XLSGrid is a class based on wx.grid.Grid that can be used to faithfully reproduce the appearance of a Microsoft Excel spreadsheet (one worksheet per every instance of XLSGrid).

XLSGrid is a completely owner-drawn control, and it relies on the power of wx.grid.PyGridTableBase and wx.grid.PyGridCellRenderer to draw the cell content. For this reasons (and for some others, see the TODOs section), it will work efficiently only for relatively small Excel files.

hierarchy Inheritance Diagram

Inheritance diagram for: XLSGrid

Inheritance diagram of XLSGrid


appearance Control Appearance


XLSGrid

XLSGrid


method_summary Methods Summary

__init__Default class constructor.
DestroyTipIf a comment window or a tooltip over a hyperlink have been created, this
FormatCellProcesses the creation of a single cell (an instance of XLSCell).
GetDefaultFontDataReturns suitable width and height (in pixels) starting from Excel’s own
InstallGridHintAuxiliary method used to bind a wx.EVT_MOTION event to XLSGrid.
PopulateGridThis is the main method of this class, and it is used to actually create the cells, size the columns and rows, merging cells, etc...

API Class API

class XLSGrid(gridlib.Grid)[source]

XLSGrid is a class based on wx.grid.Grid that can be used to faithfully reproduce the appearance of a Microsoft Excel spreadsheet (one worksheet per every instance of XLSGrid).

XLSGrid is a completely owner-drawn control, and it relies on the power of wx.grid.PyGridTableBase and wx.grid.PyGridCellRenderer to draw the cell content. For this reasons (and for some others, see the TODOs section), it will work efficiently only for relatively small Excel files.



__init__(parent)[source]

Default class constructor.

Parameters:parent – the grid parent window. Must not be None.


DestroyTip()[source]

If a comment window or a tooltip over a hyperlink have been created, this method destroys them.



FormatCell(book, sheet, row, col, display_texts, comments, hyperlink, rich_text, default_width, default_colour)[source]

Processes the creation of a single cell (an instance of XLSCell).

Parameters:
  • book – an instance of the xlrd.Book class;
  • sheet – an instance of the xlrd.sheet class;
  • row – the row in which this cell lives;
  • col – the column in which this cell lives;
  • display_texts – if Mark Hammonds’ pywin32 package is available, this is the WYSIWYG cell content for all the cells in the Excel worksheet;
  • comments – if Mark Hammonds’ pywin32 package is available, this is a nested list of cell comments (notes) for all the cells in the Excel worksheet;
  • hyperlink – if this cell contains a hyperlink, it will be displayed accordingly;
  • rich_text – if this cell contains text in rich text format, XLSGrid will do its best to render the text as rich text;
  • default_width – this is the default width of the text in 1/256 of the width of the zero character, using default Excel font (first FONT record in the Excel file);
  • default_colour – the “magic” colour used by Excel to draw non-custom border lines.

Note

If you are using version 0.7.1 or lower for xlrd, the hyperlink parameter will always be None as this feature is available only in xlrd 0.7.2 (SVN).

Note

If you are using version 0.7.1 or lower for xlrd, the rich_text parameter will always be None as this feature is available only in xlrd 0.7.2 (SVN).

Note

If Mark Hammonds’ pywin32 package is not available, the display_texts and comments parameter will be two empty nested lists.



GetDefaultFontData(book)[source]

Returns suitable width and height (in pixels) starting from Excel’s own measurements (in characters, whatever that means).

Parameters:book – an instance of the xlrd.Book class.
Returns:a default_width and default_height in pixels, based on the default width of the text in 1/256 of the width of the zero character, using default Excel font (first FONT record in the Excel file).


InstallGridHint()[source]

Auxiliary method used to bind a wx.EVT_MOTION event to XLSGrid.



PopulateGrid(book, sheet, display_texts, comments)[source]

This is the main method of this class, and it is used to actually create the cells, size the columns and rows, merging cells, etc...

Parameters:
  • book – an instance of the xlrd.Book class;
  • sheet – an instance of the xlrd.sheet class;
  • display_texts – if Mark Hammonds’ pywin32 package is available, this is the WYSIWYG cell content for all the cells in the Excel worksheet;
  • comments – if Mark Hammonds’ pywin32 package is available, this is a nested list of cell comments (notes) for all the cells in the Excel worksheet.
Tree

Table Of Contents

Previous topic

XLSComment

Next topic

XLSRenderer