openpyxl.workbook.workbook module¶
-
class
openpyxl.workbook.workbook.Workbook(write_only=False)[source]¶ Bases:
objectWorkbook is the container for all other parts of the document.
-
active¶ Get the currently active sheet or None
-
chartsheets¶
-
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_named_range(name, worksheet=None, value=None, scope=None)[source]¶ Create a new named_range on a worksheet
-
create_sheet(title=None, index=None)[source]¶ Create a worksheet (at an optional index).
Parameters: - title – optional title of the sheet
- index (int) – optional position at which the sheet will be inserted
-
data_only¶
-
get_sheet_by_name(*args, **kwargs)[source]¶ Returns a worksheet by its name.
Parameters: name (string) – the name of the worksheet to look for
-
keep_links¶
-
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 openpyxl does not enforce this.
-
named_styles¶ List available named styles
-
path= '/xl/workbook.xml'¶
-
read_only¶
-
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. Subsequents attempts to modify or save the file will raise an
openpyxl.shared.exc.WorkbookAlreadySavedexception.
-
sheetnames¶ Returns the list of the names of worksheets in the workbook.
Names are returned in the worksheets order.
Return type: list of strings
-
style_names¶ List of named styles
-
template= False¶
-
worksheets¶
-
write_only¶
-