AGW Logo

agw_title XLSText

This is a class which holds information about the cell content, in terms of actual cell value, font, text colour, alignment and formatting.

hierarchy Inheritance Diagram

Inheritance diagram for: XLSText

Inheritance diagram of XLSText


subclasses Known Subclasses


method_summary Methods Summary

__init__Default class constructor.
CombineAttrCombines the input attribute attr with the features of the XLSText class.
CreateAlignmentCreates a suitable wxPython alignment flag for the text starting from a
CreateFontCreates a suitable wxPython font starting from an Excel font.
CreateFormatThis method tries to guess the best format to apply to the current text value.
CreateTextColourCreates a suitable wxPython colour for the text starting from a xlrd
DrawActually draws the text value on a grid cell.
FormatStringThis method tries to guess the best format to apply to the current text value.
GetValueReturns the string representation of the cell text value.
IsHyperLinkReturns whether the cell text is representing a hyperlink.
SetupHyperlinkSets up the cell text value in case it represents a hyperlink.

API Class API

class XLSText(object)[source]

This is a class which holds information about the cell content, in terms of actual cell value, font, text colour, alignment and formatting.



__init__(book, cell, xf_index, display_text=None, hyperlink=None, default_width=10)[source]

Default class constructor.

Parameters:
  • book – an instance of the xlrd.Book class;
  • cell – an instance of xlrd.sheet.Cell class;
  • xf_index – an index into xlrd.Book.xf_list, which holds a reference to the xlrd.sheet.Cell class (the actual cell for xlrd);
  • display_text – if Mark Hammonds’ pywin32 package is available, this is the WYSIWYG cell content;
  • hyperlink – if this cell contains a hyperlink, it will be displayed accordingly;
  • 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).

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).



CombineAttr(attr)[source]

Combines the input attribute attr with the features of the XLSText class.

Parameters:attr – an instance of wx.grid.GridCellAttr.


CreateAlignment(alignment, default_width)[source]

Creates a suitable wxPython alignment flag for the text starting from a xlrd class representing this alignment.

Parameters:
  • alignment – an instance of xlrd.formatting.XFAlignment class;
  • 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).


CreateFont(font)[source]

Creates a suitable wxPython font starting from an Excel font.

Parameters:font – an instance of xlrd.formatting.Font class.

Note

There is currently no support for strikethrough fonts, although xlrd correctly reports this format. The issue is a bug in wxWidgets itself which doesn’t allow the creation of strikethrough fonts. See (http://trac.wxwidgets.org/ticket/9907).



CreateFormat(format, cell, datemode)[source]

This method tries to guess the best format to apply to the current text value.

Parameters:
  • format – an instance of xlrd.formatting.Format class;
  • cell – an instance of xlrd.sheet.Cell class;
  • datemode – the datemode associated with this Excel workbook.

Note

This method is used only if Mark Hammonds’ pywin32 package is not available to try and format the cell text in an intelligent way.

Warning

The formatting applied by this method is severely limited; for instance, you won’t probably get the exact WYSIWYG between the Excel spreadsheet and XLSGrid.



CreateTextColour(text_colour)[source]

Creates a suitable wxPython colour for the text starting from a xlrd tuple representing this colour.

Parameters:text_colour – a tuple representing the RGB components of the colour. If text_colour is None, use the default wx.SYS_COLOUR_WINDOWTEXT.


Draw(dc, rect)[source]

Actually draws the text value on a grid cell.

Parameters:
  • dc – an instance of wx.DC;
  • rect – an instance of wx.Rect, representing the cell rectangle.


FormatString(value, isDate, format_str)[source]

This method tries to guess the best format to apply to the current text value.

Parameters:
  • value – the actual raw cell text value;
  • isDateTrue if this value represents a xlrd date object, False otherwise;
  • format_str – the actual formatting string as extracted from Excel.

Note

This method is used only if Mark Hammonds’ pywin32 package is not available to try and format the cell text in an intelligent way.

Warning

The formatting applied by this method is severely limited; for instance, you won’t probably get the exact WYSIWYG between the Excel spreadsheet and XLSGrid.



GetValue()[source]

Returns the string representation of the cell text value.



Returns whether the cell text is representing a hyperlink.

Returns:True if the cell text represents a hyperlink, False otherwise.


Sets up the cell text value in case it represents a hyperlink.

Parameters:hyperlink – an instance of xlrd.sheet.hyperlink.

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).

Tree

Table Of Contents

Previous topic

XLSTable

Next topic

xlsgrid functions