The Worksheet Class

class Worksheet(sheetname, parent_book)

This is a class representing the contents of a sheet in a workbook.

Warning

You don’t normally create instances of this class yourself. They are returned from calls to Workbook.add_sheet()

Worksheet.write(r, c, label="", style=Style.default_style)

This method is used to write a cell to a Worksheet..

Parameters:
  • r (int) – The zero-based number of the row in the worksheet to which the cell should be written.
  • c (int) – The zero-based number of the column in the worksheet to which the cell should be written.
  • label (str) – The data value to be written. An int, long, or decimal.Decimal instance is converted to float. A unicode instance is written as is. A str instance is converted to unicode using the encoding (default: ‘ascii’) specified when the Workbook instance was created. A datetime.datetime, datetime.date, or datetime.time instance is converted into Excel date format (a float representing the number of days since (typically) 1899-12-31T00:00:00, under the pretence that 1900 was a leap year). A bool instance will show up as TRUE or FALSE in Excel. None causes the cell to be blank – no data, only formatting. An Formula instance causes an Excel formula to be written.
  • style – A style – also known as an XF (extended format) – is an XFStyle object, which encapsulates the formatting applied to the cell and its contents. XFStyle objects are best set up using the easyxf() function. They may also be set up by setting attributes in Alignment, Borders, Pattern, Font and Protection objects then setting those objects and a format string as attributes of an XFStyle object.

Previous topic

The Workbook Object

This Page