Workbook class
Workbook class
Represents a root object to create an Excel spreadsheet.
The Workbook type exposes the following members:
Constructors
Constructor | Description |
---|---|
init | Initializes a new instance of the Workbook class. |
init | Initializes a new instance of the Workbook class. |
init | Initializes a new instance of the Workbook class and open a file. |
init | Initializes a new instance of the Workbook class and open a stream. |
init | Initializes a new instance of the Workbook class and open a file. |
init | Initializes a new instance of the Workbook class and open stream. |
Properties
Property | Description |
---|---|
settings | Represents the workbook settings. |
worksheets | Gets the WorksheetCollection collection in the spreadsheet. |
is_licensed | Indicates whether license is set. |
colors | Returns colors in the palette for the spreadsheet. |
count_of_styles_in_pool | Gets number of the styles in the style pool. |
default_style | Gets or sets the default Style object of the workbook. |
is_digitally_signed | Indicates if this spreadsheet is digitally signed. |
is_workbook_protected_with_password | Indicates whether structure or window is protected with password. |
vba_project | Gets the Workbook.vba_project in a spreadsheet. |
has_macro | Indicates if this spreadsheet contains macro/VBA. |
has_revisions | Gets if the workbook has any tracked changes |
file_name | Gets and sets the current file name. |
cells_data_table_factory | Gets the factory for building ICellsDataTable from custom objects |
data_sorter | Gets a DataSorter object to sort data. |
theme | Gets the theme name. |
built_in_document_properties | Returns a DocumentProperty collection that represents all the built-in document properties of the spreadsheet. |
custom_document_properties | Returns a DocumentProperty collection that represents all the custom document properties of the spreadsheet. |
file_format | Gets and sets the file format. |
interrupt_monitor | Gets and sets the interrupt monitor. |
content_type_properties | Gets the list of ContentTypeProperty objects in the workbook. |
custom_xml_parts | Represents a Custom XML Data Storage Part (custom XML data within a package). |
data_mashup | Gets mashup data. |
ribbon_xml | Gets and sets the XML file that defines the Ribbon UI. |
absolute_path | Gets and sets the absolute path of the file. |
data_connections | Gets the ExternalConnection collection. |
data_model | Gets data model in the workbook. |
Methods
Method | Description |
---|---|
save | Saves the workbook to the disk. |
save | Save the workbook to the disk. |
save | Saves the workbook to the disk. |
save | Saves the workbook to the stream. |
save | Saves the workbook to the stream. |
replace | Replaces a cell’s value with a new string. |
replace | Replaces a cell’s value with a new integer. |
replace | Replaces a cell’s value with a new double. |
replace | Replaces a cell’s value with a new string array. |
replace | Replaces cells’ values with an integer array. |
replace | Replaces cells’ values with a double array. |
replace | Replaces cells’ values with new data. |
replace | Replaces cells’ values with new data. |
replace | Replaces a cell’s value with a new string. |
copy | Copies another Workbook object. |
copy | Copies data from a source Workbook object. |
calculate_formula | Calculates the result of formulas. |
calculate_formula | Calculates the result of formulas. |
calculate_formula | Calculating formulas in this workbook. |
refresh_dynamic_array_formulas | Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) Other formulas in the workbook will not be calculated recursively even if they were used by dynamic array formulas. |
refresh_dynamic_array_formulas | Refreshes dynamic array formulas(spill into new range of neighboring cells according to current data) |
import_xml | Imports/Updates an XML data file into the workbook. |
import_xml | Imports/Updates an XML data file into the workbook. |
export_xml | Export XML data linked by the specified XML map. |
export_xml | Export XML data. |
parse_formulas | Parses all formulas which have not been parsed when they were loaded from template file or set to a cell. |
start_access_cache | Starts the session that uses caches to access data. |
close_access_cache | Closes the session that uses caches to access data. |
remove_unused_styles | Remove all unused styles. |
create_style | Creates a new style. |
create_builtin_style | Creates built-in style by given type. |
create_cells_color | Creates a CellsColor object. |
combine | Combines another Workbook object. |
get_style_in_pool | Gets the style in the style pool. All styles in the workbook will be gathered into a pool. There is only a simple reference index in the cells. |
get_fonts | Gets all fonts in the style pool. |
get_named_style | Gets the named style in the style pool. |
change_palette | Changes the palette for the spreadsheet in the specified index. |
is_color_in_palette | Checks if a color is in the palette for the spreadsheet. |
get_matching_color | Find best matching Color in current palette. |
set_encryption_options | Set Encryption Options. |
protect | Protects a workbook. |
protect_shared_workbook | Protects a shared workbook. |
unprotect | Unprotects a workbook. |
unprotect_shared_workbook | Unprotects a shared workbook. |
remove_macro | Removes VBA/macro from this spreadsheet. |
remove_digital_signature | Removes digital signature from this spreadsheet. |
accept_all_revisions | Accepts all tracked changes in the workbook. |
remove_external_links | Removes all external links in the workbook. |
get_theme_color | Gets theme color. |
set_theme_color | Sets the theme color |
custom_theme | Customs the theme. |
copy_theme | Copies the theme from another workbook. |
has_exernal_links | Indicates whether this workbook contains external links to other data sources. |
update_custom_function_definition | Updates definition of custom functions. |
update_linked_data_source | If this workbook contains external links to other data source, Aspose.Cells will attempt to retrieve the latest data from give sources. |
set_digital_signature | Sets digital signature to an spreadsheet file (Excel2007 and later). |
add_digital_signature | Adds digital signature to an OOXML spreadsheet file (Excel2007 and later). |
get_digital_signature | Gets digital signature from file. |
remove_personal_information | Removes personal information. |
Remarks
The Workbook class denotes an Excel spreadsheet. Each spreadsheet can contain multiple worksheets. The basic feature of the class is to open and save native excel files. The class has some advanced features like copying data from other Workbooks, combining two Workbooks, converting Excel to PDF, rendering Excel to image and protecting the Excel spreadsheet.
Example
The following example loads a Workbook from an Excel file named designer.xls and makes the horizontal and vertical scroll bars invisible. It then replaces two string values with an Integer value and string value respectively within the spreadsheet and finally save the workbook as Excel xlsx file.
from aspose.cells import Workbook
# Open a designer file
designerFile = "designer.xls"
workbook = Workbook(designerFile)
# Set scroll bars
workbook.settings.is_h_scroll_bar_visible = False
workbook.settings.is_v_scroll_bar_visible = False
# Replace the placeholder string with new values
newInt = 100
workbook.replace("OldInt", newInt)
newString = "Hello!"
workbook.replace("OldString", newString)
workbook.save("result.xlsx")
See Also
- module
aspose.cells
- class
CellsColor
- class
ContentTypeProperty
- class
DocumentProperty
- class
ExternalConnection
- class
Style
- class
Workbook
- class
WorksheetCollection