Workbook is the top-level container for all document information.
openpyxl.workbook.workbook.
Workbook
(
write_only=False
,
iso_dates=False
)
[source]
¶
Bases:
object
Workbook is the container for all other parts of the document.
active
¶
Get the currently active sheet or None
| 类型: |
openpyxl.worksheet.worksheet.Worksheet
|
|---|
add_named_range
(
named_range
)
[source]
¶
Add an existing named_range to the list of named_ranges.
注意
Deprecated: Use workbook.defined_names.append
chartsheets
¶
A list of Chartsheets in this workbook
| 类型: |
list of
openpyxl.chartsheet.chartsheet.Chartsheet
|
|---|
copy_worksheet
(
from_worksheet
)
[source]
¶
Copy an existing worksheet in the current workbook
警告
This function cannot copy worksheets between workbooks. worksheets can only be copied within the workbook that they belong
| 参数: | from_worksheet – the worksheet to be copied from |
|---|---|
| 返回: | 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).
| 参数: |
|
|---|
data_only
¶
epoch
¶
excel_base_date
¶
get_index
(
worksheet
)
[source]
¶
Return the index of the worksheet.
注意
Deprecated: Use wb.index(worksheet)
get_named_range
(
name
)
[source]
¶
Return the range specified by name.
注意
Deprecated: Use workbook.defined_names[name]
get_named_ranges
(
)
[source]
¶
Return all named ranges
注意
Deprecated: Use workbook.defined_names.definedName
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 |
注意
Deprecated: Use wb[sheetname]
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
¶
remove_named_range
(
named_range
)
[source]
¶
Remove a named_range from this workbook.
注意
Deprecated: Use del workbook.defined_names[name]
remove_sheet
(
worksheet
)
[source]
¶
移除 worksheet from this workbook.
注意
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 .
警告
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.WorkbookAlreadySaved
异常。
sheetnames
¶
Returns the list of the names of worksheets in this workbook.
Names are returned in the worksheets order.
| 类型: | 字符串列表 |
|---|
style_names
¶
List of named styles
template
= False
¶
worksheets
¶
A list of sheets in this workbook
| 类型: |
list of
openpyxl.worksheet.worksheet.Worksheet
|
|---|
write_only
¶