Represents a Microsoft Excel workbook.

Inheritance

object

constructor

public Workbook()

Returns Workbook

constructor

public Workbook(WorkbookFormat format)

Returns Workbook

Gets or sets the value which indicates how a formula will be recalculated when a referenced value changes.

public CalculationMode CalculationMode { get; set; }

Gets or sets the value which indicates the way cells in the workbook are referenced.

public CellReferenceMode CellReferenceMode { get; set; }

Gets or sets the culture to use as the current culture for the workbook when doing any culture-aware conversions or comparisons.

public CultureInfo Culture { get; set; }

Gets the current format of the workbook. This is the format which will be used when saving and imposing format restrictions.

public WorkbookFormat CurrentFormat { get; }

Gets the collection of custom table styles in the workbook.

public CustomTableStyleCollection CustomTableStyles { get; }

Gets the collection of custom views for the workbook.

public CustomViewCollection CustomViews { get; }

Gets or sets the date system used internally by Microsoft Excel.

public DateSystem DateSystem { get; set; }

Gets or sets the default style for tables in the workbook.

public WorksheetTableStyle DefaultTableStyle { get; set; }

Gets the properties associated with the workbook document.

public DocumentProperties DocumentProperties { get; }

The editing culture affects certain language specific features such as formatting of dates. or comparisons.

public CultureInfo EditingCulture { get; set; }

Gets the name of the user who initially added file write protection to the document.

public string FileWriteProtectedBy { get; }

Gets the value indicating whether the has a file write protection password that will be used to protect saved files or streams.

public bool HasFileWriteProtectionPassword { get; }

Gets the value indicating whether the has an open password and will therefore be encrypted on subsequent saves.

public bool HasOpenPassword { get; }

Returns a boolean indicating if the Workbook has been protected with a password.

public bool HasProtectionPassword { get; }

Provides the in process runtime that the workbook can use to perform operations in javascript.

public static IJSInProcessRuntime InProcessRuntime { get; set; }

Gets the value indicating whether the was loaded with file write protection and the correct password has not yet been provided to ValidateFileWriteProtectionPassword.

public bool IsFileWriteProtected { get; }

Returns a boolean indicating if the Workbook has been protected.

public bool IsProtected { get; }

Gets or sets the value which indicates whether iterations are allowed while calculating formulas containing circular references.

public bool IterativeCalculationsEnabled { get; set; }

Gets or sets the maximum change of the values in a formula between iterations which will exit from iteration.

public double MaxChangeInIteration { get; set; }

Gets the maximum number of columns allowed in each worksheet based on the .

public int MaxColumnCount { get; }

Gets or sets the maximum number of times formulas should be iteratively calculated.

public int MaxRecursionIterations { get; set; }

Gets the maximum number of rows allowed in each worksheet based on the .

public int MaxRowCount { get; }

Gets the collection of named references in the workbook.

public NamedReferenceCollection NamedReferences { get; }

Gets the color palette used when the saved file is opened in Microsoft Excel 2003 and earlier versions.

public WorkbookColorPalette Palette { get; }

Gets or sets the precision to use when obtaining a cell's value.

public Precision Precision { get; set; }

Gets or sets the value which indicates whether the workbook is protected.

[Obsolete("The Protected property has been deprecated. The IsProtected property will return the current protected state. The Protect and Unprotect methods are used to change the protection state.")]
public bool Protected { get; set; }

Returns an object that provides information used when the Workbook has been protected.

public WorkbookProtection Protection { get; }

Gets or sets the value which indicates whether the workbook should recalculate all formulas before saving.

public bool RecalculateBeforeSave { get; set; }

Gets or sets the value which indicates whether to save values linked from external workbooks.

public bool SaveExternalLinkedValues { get; set; }

Gets or sets the Dpi to use when calculating row and column sizes for the workbook. If empty, the system Dpi will be used.

public Size ScreenDpi { get; set; }

Gets the collection of sheets in the workbook.

public SheetCollection Sheets { get; }

Gets or sets the value which indicates whether carriage return characters should be removed from string values in cells when the workbook is saved to an Excel file.

public bool ShouldRemoveCarriageReturnsOnSave { get; set; }

Gets the read-only collection of preset table styles in the workbook.

public StandardTableStyleCollection StandardTableStyles { get; }

Gets the collection of custom styles in the workbook.

public WorkbookStyleCollection Styles { get; }

Gets or sets the default Dpi to use when calculating row and column sizes for the workbook. If empty, the resolved system Dpi will be used.

public static Size SystemDpi { get; set; }

Gets or sets the value indicating whether the format strings should be validated when they are set.

public bool ValidateFormatStrings { get; set; }

Gets the options which control various workbook level display properties.

public WorkbookWindowOptions WindowOptions { get; }

Gets the collection of worksheets in the workbook.

public WorksheetCollection Worksheets { get; }

Maximum number of distinct cell formats in the workbook allowed by the Excel 2007 file format.

public const int MaxExcel2007CellFormatCount = 64000

Maximum number of columns in the worksheet allowed by the Excel 2007 file format.

public const int MaxExcel2007ColumnCount = 16384

Maximum number of rows in the worksheet allowed by the Excel 2007 file format.

public const int MaxExcel2007RowCount = 1048576

Maximum number of distinct cell formats in the workbook allowed by the Excel 97-2003 file format.

public const int MaxExcelCellFormatCount = 4000

Maximum number of columns in the worksheet allowed by the Excel 97-2003 file format.

public const int MaxExcelColumnCount = 256

Maximum number of rows in the worksheet allowed by the Excel 97-2003 file format.

public const int MaxExcelRowCount = 65536

Maximum number fonts in a workbook allowed by Excel.

public const int MaxExcelWorkbookFonts = 512

CharacterWidth256thsToPixels(double)

Section titled "CharacterWidth256thsToPixels(double)"

Converts units of 1/256s of the average character width to pixels.

public double CharacterWidth256thsToPixels(double characterWidth256ths)

Parameters

  • characterWidth256ths: double

Returns any

Clears all external data connections from the .

public void ClearConnectionData()

Returns any

Clears all pivot tables and associated slicers from the .

public void ClearPivotTableData()

Returns any

Clears all vba information from the .

public void ClearVbaData()

Returns any

Factory method which creates new workbook font.

public IWorkbookFont CreateNewWorkbookFont()

Returns any

Creates new worksheet cell format.

public IWorksheetCellFormat CreateNewWorksheetCellFormat()

Returns any

Returns the number of columns that are supported by the specified format.

public static int GetMaxColumnCount(WorkbookFormat format)

Parameters

  • format: WorkbookFormat

Returns any

Returns the number of rows that are supported by the specified format.

public static int GetMaxRowCount(WorkbookFormat format)

Parameters

  • format: WorkbookFormat

Returns any

Gets the table with the specified name.

public WorksheetTable GetTable(string name)

Parameters

  • name: string

Returns any

Returns the WorkbookFormat based on the file extension of the specified file.

public static WorkbookFormat? GetWorkbookFormat(string fileName)

Parameters

  • fileName: string

Returns any

Gets a value indicating whether the specified function will be recognized and solved by Microsoft Excel when the workbook is saved out.

public bool IsValidFunctionName(string functionName)

Parameters

  • functionName: string

Returns any

Determines whether the workbook in the specified stream is encrypted with an open password.

public static bool IsWorkbookEncrypted(Stream stream)

Parameters

  • stream: Stream

Returns any

Reads a workbook from a stream.

public static Workbook Load(Stream stream, WorkbookLoadOptions loadOptions = null)

Parameters

  • stream: Stream
  • loadOptions: WorkbookLoadOptions

Returns any

PixelsToCharacterWidth256ths(double)

Section titled "PixelsToCharacterWidth256ths(double)"

Converts pixels to units of 1/256s of the average character width.

public double PixelsToCharacterWidth256ths(double pixels)

Parameters

  • pixels: double

Returns any

Protects the Workbook without a password.

public void Protect(bool allowEditStructure = false, bool allowEditWindows = true)

Parameters

  • allowEditStructure: bool
  • allowEditWindows: bool

Returns any

Protects the worksheet with the specified password.

public void Protect(SecureString password, bool allowEditStructure = false, bool allowEditWindows = true)

Parameters

  • password: SecureString
  • allowEditStructure: bool
  • allowEditWindows: bool

Returns any

Protects the worksheet with the specified password.

public void Protect(string password, bool allowEditStructure = false, bool allowEditWindows = true)

Parameters

  • password: string
  • allowEditStructure: bool
  • allowEditWindows: bool

Returns any

Recalculates all dirty formulas pending a calculation on the workbook.

public void Recalculate()

Returns any

Recalculates all formulas on the workbook.

public void Recalculate(bool includeNonDirtyFormulas)

Parameters

  • includeNonDirtyFormulas: bool

Returns any

RegisterUserDefinedFunction(ExcelCalcFunction)

Section titled "RegisterUserDefinedFunction(ExcelCalcFunction)"

Registers a single instance.

public bool RegisterUserDefinedFunction(ExcelCalcFunction userDefinedFunction)

Parameters

  • userDefinedFunction: ExcelCalcFunction

Returns any

RegisterUserDefinedFunctionLibrary(Assembly)

Section titled "RegisterUserDefinedFunctionLibrary(Assembly)"

Registers an assembly containing derived types.

public bool RegisterUserDefinedFunctionLibrary(Assembly assembly)

Parameters

  • assembly: Assembly

Returns any

Resumes the calculation of formulas.

public void ResumeCalculations()

Returns any

Writes the workbook to a stream.

public void Save(Stream stream, IPackageFactory packageFactory)

Parameters

  • stream: Stream
  • packageFactory: IPackageFactory

Returns any

Writes the workbook to a stream.

public void Save(Stream stream, WorkbookSaveOptions saveOptions = null)

Parameters

  • stream: Stream
  • saveOptions: WorkbookSaveOptions

Returns any

Sets the current format of the workbook.

public void SetCurrentFormat(WorkbookFormat format)

Parameters

  • format: WorkbookFormat

Returns any

SetEncryptionMode(WorkbookEncryptionMode)

Section titled "SetEncryptionMode(WorkbookEncryptionMode)"

Sets the encryption modes to use to encrypt documents saved in the 2007 file formats and later.

public void SetEncryptionMode(WorkbookEncryptionMode encryptionMode)

Parameters

  • encryptionMode: WorkbookEncryptionMode

Returns any

SetFileWriteProtectionPassword(SecureString, string)

Section titled "SetFileWriteProtectionPassword(SecureString, string)"

Sets the password used to protect the file from automatic writes.

public void SetFileWriteProtectionPassword(SecureString password, string userName = null)

Parameters

  • password: SecureString
  • userName: string

Returns any

SetFileWriteProtectionPassword(string, string)

Section titled "SetFileWriteProtectionPassword(string, string)"

Sets the password used to protect the file from automatic writes.

public void SetFileWriteProtectionPassword(string password, string userName = null)

Parameters

  • password: string
  • userName: string

Returns any

Sets the password used to encrypt the document on subsequent saves.

public void SetOpenPassword(SecureString password)

Parameters

  • password: SecureString

Returns any

Sets the password used to encrypt the document on subsequent saves.

public void SetOpenPassword(string password)

Parameters

  • password: string

Returns any

Temporarily suspends the calculation of formulas.

public void SuspendCalculations()

Returns any

Removes the Workbook protection.

public void Unprotect()

Returns any

Attempts to use the specified password to remove the Worksheet protection currently in place.

public void Unprotect(SecureString password)

Parameters

  • password: SecureString

Returns any

Attempts to use the specified password to remove the Worksheet protection currently in place.

public void Unprotect(string password)

Parameters

  • password: string

Returns any

ValidateFileWriteProtectionPassword(SecureString)

Section titled "ValidateFileWriteProtectionPassword(SecureString)"

Validates the password for a loaded with file write protection. and returns the value indicating whether the protection was successfully disabled.

public bool ValidateFileWriteProtectionPassword(SecureString password)

Parameters

  • password: SecureString

Returns any

ValidateFileWriteProtectionPassword(string)

Section titled "ValidateFileWriteProtectionPassword(string)"

Validates the password for a loaded with file write protection. and returns the value indicating whether the protection was successfully disabled.

public bool ValidateFileWriteProtectionPassword(string password)

Parameters

  • password: string

Returns any