- Shipped With wxPython
- Unofficial Widgets
If you have any request, or you would like to know how I built some of these software and interfaces, please feel free to drop me an e-mail.
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.
On Windows, it is **strongly** recommended to install Mark Hammonds' `pywin32` package:
This will allow you to perfectly reproduce the appearance of the Excel worksheet in your instance of XLSGrid.
If Mark Hammonds' `pywin32` package is not available, the formatting capabilities of XLSGrid are severely limited; for instance, you won't probably get the exact WYSIWYG between the Excel spreadsheet and XLSGrid.
XLSGrid can only read Excel `.xls` files, not the newer versions `.xlsx` generated by Office 2007/2010. If you have a `.xlsx` file, you will need to save it in 1997-2003 Office compatibility mode.
Currently this class provides a read-only subclass of `wx.grid.Grid`, with the following formatting features already implemented:
- Cell background: support for any cell background colour and fill pattern (hatching) in the Excel default set. There currently is no support for gradient shading inside a cell as `xlrd` doesn't report this information.
- Cell borders: support for all the border types and colours exposed by Excel (left, top, bottom, right and diagonal borders, thin, double, thick, ect... line styles).
- Cell text: support for all kind of
strike-through, but this is a bug in wxWidgets), and font colours. As a
subset of text/font capabilities, XLSGrid supports the following
features found in Excel:
- Horizontal alignment: left, right, centered, left-indented;
- Vertical alignment: left, right, centered;
- Text direction: left-to-right or right-to-left;
- Text-wrapping: wrapping long texts inside a grid cell;
- Shrink-to-fit: text font is reduced until the text can fit in a one-line inside the grid cell;
- Text rotation: text can be rotated from +90 to -90 degrees.
- Cell text appearance: if you are using Mark Hammonds' `pywin32` package, the text displayed in the XLSGrid cells has exactly the same appearance as in the Excel spreadsheet.
- Cell comments (notes): if you are using Mark Hammonds' `pywin32` package, cell comments (notes) are extracted and you will see a small red triangle at the top-right corner of any cell containing a comment. Hovering with the mouse on that cell will pop-up a "comment-window" displaying the comment text (the comment window is based on wx.lib.agw.supertooltip).
- Cell hyperlinks: starting from version 0.7.2 (SVN), `xlrd` is capable of extracting hyperlinks from Excel cells. This will be appropriately displayed in XLSGrid with a cursor changing and a tooltip on that cell.
- Cell merging: merged cells in the Excel spreadsheet will be correctly handled by XLSGrid.
- Columns and rows sizes: XLSGrid calculates the correct rows and columns sizes based on the Excel reported values in characters. The calculations are 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).