IWorkbook module

class IWorkbook.IWorkbook

Bases: IExcelApplication

abstract Activate()
<summary>

Activates the first window associated with the workbook.

</summary>

abstract property ActiveSheet: IWorksheet
<summary>
Returns an object that represents the active sheet (the sheet on top)

in the active workbook or in the specified window or workbook. Returns Nothing if no sheet is active. Read-only.

</summary>

abstract property ActiveSheetIndex: int
<summary>

Gets / sets index of the active sheet.

</summary>

abstract AddFont(fontToAdd: IFont) IFont
<summary>

Adds font to the inner fonts collection and makes this font read-only.

</summary> <param name=”fontToAdd”>Font to add.</param> <returns>Added font.</returns>

abstract property AddInFunctions: IAddInFunctions
<summary>

Returns collection of all workbook’s add-in functions. Read-only.

</summary>

abstract property Allow3DRangesInDataValidation: bool
<summary>
Indicates whether to allow usage of 3D ranges in DataValidation

list property (MS Excel doesn’t allow).

</summary>

abstract property ArgumentsSeparator: str
<summary>

Formula arguments separator.

</summary>

abstract property Author: str
<summary>

Returns or sets the author of the comment. Read-only String.

</summary>

abstract property BuiltInDocumentProperties: IBuiltInDocumentProperties
<summary>
Returns collection that represents all the built-in document properties

for the specified workbook. Read-only.

<example>The following code snippet illustrates how to get the built in document properties: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Get the built in document properties IBuiltInDocumentProperties builtInDocumentProperties = workbook.DocumentProperties; </code> </example>

</summary>

abstract property Charts: ICharts
<summary>

Collection of the chart objects.

</summary>

abstract Clone() IWorkbook
<summary>

Creates copy of the current instance.

</summary> <returns>Copy of the current instance.</returns>

Close
<summary>

Closes the object.

</summary> <param name=”SaveChanges”>If True, all changes will be saved.</param> <param name=”Filename”>Name of the file.</param>

abstract property CodeName: str
<summary>

Name which is used by macros to access the workbook items.

</summary>

abstract CopyToClipboard()
<summary>

Copies workbook to the clipboard.

</summary>

CreateFont
<summary>

Method to create a font object and register it in the workbook.

<example>The following code illustrates how to create IFont object: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text IRichTextString richText = worksheet[“B2”].RichText; //Create font IFont font = workbook.CreateFont(); //Set color font.Color = Color.Red; //Set text richText.Text = “Sample”; //Set font richText.SetFont(0, 5, font); //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary> <returns>Newly created font.</returns>

abstract CreateTemplateMarkersProcessor() IMarkersDesigner
<summary>

Creates object that can be used for template markers processing.

</summary> <returns>Object that can be used for template markers processing.</returns>

abstract property CustomDocumentProperties: ICustomDocumentProperties
<summary>
Returns collection that represents all the custom document properties

for the specified workbook. Read-only.

<example>The following code snippet illustrates how to get the custom document properties: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Get the document properties ICustomDocumentProperties documentProperties = workbook.CustomDocumentProperties; </code> </example>

</summary>

abstract property Date1904: bool
<summary>

True if the workbook uses the 1904 date system. Read / write Boolean.

</summary>

abstract property DetectDateTimeInValue: bool
<summary>
Indicates whether library should try to detect string value passed to Value (and Value2)

property as DateTime. Setting this property to false can increase performance greatly for such operations especially on Framework 1.0 and 1.1. Default value is true.

</summary>

abstract property DisableMacrosStart: bool
<summary>
This Property allows users to disable load of macros from

document. Excel on file open will simply skip macros and will work as if document does not contain them. This options works only when file contains macros (HasMacros property is True).

</summary>

abstract property DisplayWorkbookTabs: bool
<summary>

Indicates whether tabs are visible.

</summary>

abstract property DisplayedTab: int
<summary>

Index of tab which will be displayed on document open.

</summary>

FindOne
<summary>

This method seraches for the first cell with specified string value.

<example>This sample shows how to find the first cell with specified string value: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Find cell with specified string value string value = “value”; IXLSRange result = workbook.FindString(value, false, false); </code> </example>

</summary> <param name=”findValue”>Value to search.</param> <param name=”flags”>Type of value to search.</param> <returns>First found cell, or Null if value was not found.</returns>

GetNearestColor
<summary>
Gets the nearest color to the specified Color structure

from Workbook palette.

<example>The following code illustrates how to get the indexed color from ExcelColors for the given color from Color structure: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Get color ExcelColors color = workbook.GetMatchingColor(System.Drawing.Color.Red); //Set color worksheet[“B2”].Style.KnownColor = color; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary> <param name=”color”>System color.</param> <returns>Color index from workbook palette.</returns>

abstract GetPaletteColor(color: ExcelColors) Color
<summary>

Method return Color object from workbook palette by its index.

<example>The following code illustrates how to get the RGB color value for the specified color from ExcelColors enumeration: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Get color System.Drawing.Color color = workbook.GetPaletteColor(ExcelColors.Red); //Set color worksheet[“B2”].Style.Color = workbook.Colors[10]; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary> <param name=”color”>Index from palette array.</param> <returns>RGB Color.</returns>

abstract property HasMacros: bool
<summary>

True indicate that opened workbook contains VBA macros.

</summary>

abstract property IsCellProtection: bool
<summary>

True if cell is protected.

</summary>

abstract property IsDisplayPrecision: bool
<summary>

True if cell is protected.

</summary>

abstract property IsHScrollBarVisible: bool
<summary>

Gets or sets a value indicating whether to display horizontal scroll bar.

<example>This sample shows how to hide horizontal scroll bar: <code> //Create workbook Workbook workbook = new Workbook(); //Hide horizontal scroll bar workbook.IsHScrollBarVisible = false; //Save to file workbook.SaveToFile(“IsHScrollBarVisible.xlsx”); </code> </example>

</summary>

abstract property IsRightToLeft: bool
<summary>

Indicates whether worksheet is displayed right to left.

</summary>

abstract property IsVScrollBarVisible: bool
<summary>

Gets or sets a value indicating whether to display vertical scroll bar.

<example>This sample shows how to hide vertical scroll bar: <code> //Create workbook Workbook workbook = new Workbook(); //Hide vertical scroll bar workbook.IsVScrollBarVisible = false; //Save to file workbook.SaveToFile(“IsVScrollBarVisible.xlsx”); </code> </example>

</summary>

abstract property IsWindowProtection: bool
<summary>

True if window is protected.

</summary>

abstract property MaxColumnCount: int
<summary>

Returns maximum column count for each worksheet in this workbook. Read-only.

</summary>

abstract property MaxRowCount: int
<summary>

Returns maximum row count for each worksheet in this workbook. Read-only.

</summary>

abstract property Names: INameRanges
<summary>
For an ReservedHandle object, returns a Names collection that represents

all the names in the active workbook. For a Workbook object, returns a Names collection that represents all the names in the specified workbook (including all worksheet-specific names).

<example>The following code snippet illustrates how to get names: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Get names INameRanges names = workbook.NameRanges; </code> </example>

</summary>

abstract property Palette: List[Color]
<summary>
Get Palette of colors which an Excel document can have.

Here is a table of color indexes to places in the color tool box provided by Excel application: ——————————————– | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | —+—————————————- |1 | 00 | 51 | 50 | 49 | 47 | 10 | 53 | 54 | |2 | 08 | 45 | 11 | 09 | 13 | 04 | 46 | 15 | |3 | 02 | 44 | 42 | 48 | 41 | 40 | 12 | 55 | |4 | 06 | 43 | 05 | 03 | 07 | 32 | 52 | 14 | |5 | 37 | 39 | 35 | 34 | 33 | 36 | 38 | 01 | —+—————————————- |6 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | |7 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ——————————————–

<example>The following code illustrates how to access the default colors of excel color palette: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Get colors System.Drawing.Color[] colors = workbook.Colors; //Get color System.Drawing.Color color = colors[2]; //Set color worksheet[“B2”].Style.Color = color; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary>

abstract property PasswordToOpen: str
<summary>

Gets / sets password to encrypt document.

</summary>

abstract property PivotCaches: XlsPivotCachesCollection
<summary>
Returns pivot caches collection. Read-only.

<example>The following code snippet illustrates how to get pivot caches: <code>

//Load workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Gets pivot caches collection IPivotCaches pivotCaches = workbook.PivotCaches; </code> </example>

</summary>

abstract Protect(bIsProtectWindow: bool, bIsProtectContent: bool)
<summary>

Sets protection for workbook.

</summary> <param name=”bIsProtectWindow”>Indicates if protect workbook window.</param> <param name=”bIsProtectContent”>Indicates if protect workbook content.</param>

abstract property ReadOnly: bool
<summary>

True if the workbook has been opened as Read-only. Read-only Boolean.

</summary>

abstract property ReadOnlyRecommended: bool
<summary>

True to display a message when the file is opened, recommending that the file be opened as read-only.

</summary>

Replace
<summary>

Replaces specified string by specified value.

<example>The following code snippet illustrates how to replace the string with another string: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Replace the oldValue by newValue string oldValue = “Find”; string newValue = “NewValue”; workbook.Replace(oldValue, newValue); //Save to file workbook.SaveToFile(“Replace.xlsx”); </code> </example>

</summary> <param name=”oldValue”>String value to replace.</param> <param name=”newValue”>New value for the range with specified string.</param>

abstract ResetPalette()
<summary>

Recover palette to default values.

<example>The following code snippets illustrates how to reset the palette: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Get colors System.Drawing.Color[] colors = workbook.Colors; //Check color Console.WriteLine(colors[2].Name); //Set color colors[2] = System.Drawing.Color.Yellow; //Reset palette workbook.ResetPalette(); //Check color Console.WriteLine(workbook.Colors[2].Name); //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary>

abstract property RowSeparator: str
<summary>

Gets / sets row separator for array parsing.

</summary>

abstract Save()
<summary>
Saves changes to the specified workbook.

<example>This sample shows how to save changes to the specified workbook: <code>

//Load workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Save to file workbook.Save(); </code> </example>

</summary>

SaveAs
<summary>

Save active WorkSheet using separator.

<example>The following code illustrates how to save the active worksheet in a different file with separator: <code> //Create workbook Workbook workbook = new Workbook(); workbook.LoadFromFile(“Sample.xlsx”); //Save to file workbook.SaveToFile(“Result.csv” , “,”); </code> </example>

</summary> <param name=”fileName”>Path to save.</param> <param name=”separator”>Current separator.</param>

abstract SaveAsHtml(filename: str, saveOptions: HTMLOptions)
<summary>

Saves changes to the specified stream.

</summary> <param name=”filename”>Name of the file.</param> <param name=”saveOptions”>Save options in html.</param>

abstract property Saved: bool
<summary>
True if no changes have been made to the specified workbook since

it was last saved. Read/write Boolean.

</summary>

SetColorOrGetNearest
<summary>
If there is at least one free color, define a new color;

if not, search for the closest one.

</summary> <param name=”color”></param> <returns>Color index from workbook palette.</returns>

abstract SetPaletteColor(index: int, color: Color)
<summary>

Set user color for specified element in Color table.

<example>The following code snippet illustrates how to set palette color: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set palette color workbook.ChangePaletteColor(System.Drawing.Color.Red , 10); //Set color worksheet[“B2”].Style.Color = workbook.Colors[10]; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary> <param name=”index”>Index of Color in array.</param> <param name=”color”>New color which must be set.</param>

abstract SetSeparators(argumentsSeparator: int, arrayRowsSeparator: int)
<summary>

Sets separators for formula parsing.

</summary> <param name=”argumentsSeparator”>Arguments separator to set.</param> <param name=”arrayRowsSeparator”>Array rows separator to set.</param>

abstract SetWriteProtectionPassword(password: str)
<summary>

This method sets write protection password.

</summary> <param name=”password”>Password to set.</param>

abstract property StandardFont: str
<summary>

Returns or sets the name of the standard font. Read/write String.

<example>The following code illustrates how to set the standard font for the workbook: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“B2”].Text = “Text”; //Set standard font workbook.DefaultFontName = “Arial”; //Set standard font size workbook.DefaultFontSize = 18; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary>

abstract property StandardFontSize: float
<summary>

Returns or sets the standard font size, in points. Read/write.

<example>The following code illustrates how to set the standard font size for the workbook: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set text worksheet[“B2”].Text = “Text”; //Set standard font workbook.DefaultFontName = “Arial”; //Set standard font size workbook.DefaultFontSize = 18; //Save to file workbook.SaveToFile(“CellFormats.xlsx”); </code> </example>

</summary>

abstract property Styles: IStyles
<summary>
Returns a Styles collection that represents all the styles

in the specified workbook. Read-only.

<example>The following code snippet illustrates how to get the Styles: <code> //Create worksheet Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets[0]; //Set styles IStyles styles = workbook.Styles; </code> </example>

</summary>

abstract property TabSheets: ITabSheets
<summary>

Returns collection of tab sheets. Read-only.

</summary>

abstract property ThrowOnUnknownNames: bool
<summary>
Indicates whether exception should be thrown when unknown

name was found in a formula.

</summary>

abstract Unprotect()
<summary>

Unprotects workbook.

</summary>

abstract property Version: ExcelVersion
<summary>

Gets / sets excel version.

</summary>

abstract property Worksheets: IWorksheets
<summary>
Returns a Sheets collection that represents all the worksheets

in the specified workbook. Read-only Sheets object.

</summary>