fastpyxl.workbook.workbook module

Workbook is the top-level container for all document information.

class fastpyxl.workbook.workbook.Workbook(write_only=False, iso_dates=False)[source]

Bases: object

Workbook is the container for all other parts of the document.

property active

Get the currently active sheet or None

Type:

fastpyxl.worksheet.worksheet.Worksheet

add_named_style(style)[source]

Add a named style

property chartsheets

A list of Chartsheets in this workbook

Type:

list of fastpyxl.chartsheet.chartsheet.Chartsheet

close()[source]

Close workbook file if open. Only affects read-only and write-only modes.

copy_worksheet(from_worksheet)[source]

Copy an existing worksheet in the current workbook

Warning

This function cannot copy worksheets between workbooks. worksheets can only be copied within the workbook that they belong

Parameters:

from_worksheet – the worksheet to be copied from

Returns:

copy of the initial worksheet

create_chartsheet(title=None, index=None)[source]
create_named_range(name, worksheet=None, value=None, scope=None)[source]

Create a new named_range on a worksheet

Note

Deprecated: Assign scoped named ranges directly to worksheets or global ones to the workbook. Deprecated in 3.1

create_sheet(title=None, index=None)[source]

Create a worksheet (at an optional index).

Parameters:
  • title (str) – optional title of the sheet

  • index (int) – optional position at which the sheet will be inserted

property data_only
property epoch
property excel_base_date
get_index(worksheet)[source]

Return the index of the worksheet.

Note

Deprecated: Use wb.index(worksheet)

get_sheet_by_name(name)[source]

Returns a worksheet by its name.

param name:

the name of the worksheet to look for

type name:

string

Note

Deprecated: Use wb[sheetname]

get_sheet_names()[source]

Note

Deprecated: Use wb.sheetnames

index(worksheet)[source]

Return the index of a worksheet.

materialize_pending_style_components(styleable) None[source]

Register shared style parts for styleable from deferred assignments.

Styling attributes on cells and dimensions defer pushing fonts, fills, borders, number formats, alignments, protections, and named styles into the workbook until this method runs or until style_id is read.

Saving a workbook calls this automatically for every standard worksheet, in the same order as sheet XML serialization, so shared-table indices stay stable. Write-only streams still resolve styles when each row is written.

property mime_type

The mime type is determined by whether a workbook is a template or not and whether it contains macros or not. Excel requires the file extension to match but fastpyxl does not enforce this.

move_sheet(sheet, offset=0)[source]

Move a sheet or sheetname

property named_styles

List available named styles

path = '/xl/workbook.xml'
property read_only
remove(worksheet)[source]

Remove worksheet from this workbook.

remove_sheet(worksheet)[source]

Remove worksheet from this workbook.

Note

Deprecated: Use wb.remove(worksheet) or del wb[sheetname]

save(filename)[source]

Save the current workbook under the given filename. Use this function instead of using an ExcelWriter.

Warning

When creating your workbook using write_only set to True, you will only be able to call this function once. Subsequent attempts to modify or save the file will raise an fastpyxl.shared.exc.WorkbookAlreadySaved exception.

property sheetnames

Returns the list of the names of worksheets in this workbook.

Names are returned in the worksheets order.

Type:

list of strings

property style_names

List of named styles

template = False
property worksheets

A list of sheets in this workbook

Type:

list of fastpyxl.worksheet.worksheet.Worksheet

property write_only