[]
Represents an IWorkbook object.
public interface IWorkbook
Returns an object that represents the active sheet (the sheet on top) in the active workbook or in the specified window or workbook. Returns null if no sheet is active (read-only).
IWorksheet ActiveSheet { get; }
Gets or sets whether allow dynamic array formula.
bool AllowDynamicArray { get; set; }
Determines whether to automatically parse when setting a range value to a string value.
bool AutoParse { get; set; }
Determines whether to round the number to 15 significant figures when getting the value.
bool AutoRoundValue { get; set; }
Returns an object that represents the view settings of this workbook(read-only).
IWorkbookView BookView { get; }
Gets a collection that represents all the built-in document properties of the workbook.
IBuiltInDocumentPropertyCollection BuiltInDocumentProperties { get; }
[Init-only] Gets or sets culture for the workbook. The culture must contain both country/region and language.
CultureInfo Culture { get; set; }
This property must be set within the initialization expression of the workbook instance.
Gets a collection that represents all the custom document properties of the workbook.
ICustomDocumentPropertyCollection CustomDocumentProperties { get; }
Gets the custom views of the workbook.
ICustomViews CustomViews { get; }
Specifies the table style name from the ITableStyleCollection collection that is used as the default TableStyle (read/write).
string DefaultTableStyle { get; set; }
Gets or sets whether update the dirty state of the formula cells immediately when changing the value of a cell.
bool DeferUpdateDirtyState { get; set; }
Gets or sets whether the calculation engine is valid.
bool EnableCalculation { get; set; }
Returns the name of the workbook, including its path on disk.
string FullName { get; }
Provides graphics information. If this property doesn't have value, the workbook will use built-in graphic information.
IGraphicsInfo GraphicsInfo { get; set; }
Gets or sets a string value that represents the name of the workbook.
string Name { get; set; }
Returns the INames collection that represents the workbook-specified names. This is a read-only INames object.
INames Names { get; }
Returns the IExcelOptions object that represents some settings to control workbook behavior.
IExcelOptions Options { get; }
Gets or sets a string that represents the path to the workbook file that this workbook object represents.
string Path { get; set; }
Returns the IPivotCaches collection that represents all the IPivotTable caches in the specified workbook (read-only).
IPivotCaches PivotCaches { get; }
True if the order of the sheets in the workbook is protected. Read-only Boolean.
bool ProtectStructure { get; }
True if the windows of the workbook are protected. Read-only Boolean.
bool ProtectWindows { get; }
Gets or sets the reference style.
ReferenceStyle ReferenceStyle { get; set; }
Determines whether to reset adjacent range's border when setting border for a range. The default value of this property is true.
bool ResetAdjacentRangeBorder { get; set; }
Returns a IWorksheets collection that represents all the selected sheets in the specified workbook.
IWorksheets SelectedSheets { get; }
Gets a collection of Signature objects that correspond to the digital signature attached to a document.
ISignatureSet Signatures { get; }
Gets the ISlicerCaches object associated with the workbook.
ISlicerCaches SlicerCaches { get; }
Returns the IStyleCollection collection that represents all the styles in the specified workbook (read-only).
IStyleCollection Styles { get; }
Returns the ITableStyleCollection collection object for the current workbook that refers to the styles used in the current workbook (read-only).
ITableStyleCollection TableStyles { get; }
Returns or sets the theme applied to the current workbook.
ITheme Theme { get; set; }
Returns the IWorksheets collection that represents all the worksheets in the specified workbook. This is a read-only Sheets object.
IWorksheets Worksheets { get; }
Provides access to the workbook write protection options.
WriteProtection WriteProtection { get; }
Add data source for template.
void AddDataSource(string name, object dataSource)
name
stringthe alias name of the data source.
dataSource
objectCan be object of DataSet, DataTable, Custom object and variable.
Calculates formulas of the workbook as needed.
void Calculate()
Convert the calculated barcodes to pictures and place them in their respective positions.
The original barcode formulas will be cleared.
Not support EMF and WMF image types.
void ConvertBarcodeToPicture(ImageType imageType = ImageType.SVG)
Designates all the formulas of the workbook to be recalculated when the next calculation occurs.
void Dirty()
Generates a workbook from a JSON stream.
IList<JsonError> FromJson(Stream stream, DeserializationOptions deserializationOptions = null)
stream
System.IO.StreamThe stream
deserializationOptions
DeserializationOptionsThe DeserializationOptions object.
The errors in the JSON.
Generates a workbook from a JSON string.
IList<JsonError> FromJson(string json, DeserializationOptions deserializationOptions = null)
json
stringThe JSON
deserializationOptions
DeserializationOptionsThe DeserializationOptions object.
The errors in the JSON.
Generates a workbook from a JSON stream containing the contents of .sjs file format.
void FromSjsJson(Stream stream, SjsOpenOptions openOptions)
stream
System.IO.StreamThe JSON stream.
openOptions
SjsOpenOptionsThe open options for opening SpreadJS .sjs file.
Generates a workbook from a JSON stream containing the contents of .sjs file format.
void FromSjsJson(Stream stream)
stream
System.IO.StreamThe JSON stream.
Generates a workbook from a JSON string containing the contents of .sjs file format.
void FromSjsJson(string json, SjsOpenOptions openOptions)
json
stringThe JSON string.
openOptions
SjsOpenOptionsThe open options for opening SpreadJS .sjs file.
Generates a workbook from a JSON string containing the contents of .sjs file format.
void FromSjsJson(string json)
json
stringThe JSON string.
Process the template and return the instance of report workbook.
IWorkbook GenerateReport()
Process the template and return the instance of report workbook.
IWorkbook GenerateReport(params IWorksheet[] worksheets)
worksheets
IWorksheet[]IWorksheet collection that need to be processed.
Returns the names of the linked excel documents.
IEnumerable<string> GetExcelLinkSources()
Gets all fonts information that used on workbook.
IEnumerable<FontInfo> GetUsedFonts()
Specifies whether the file is password protected.
bool IsEncryptedFile(Stream fileStream)
fileStream
System.IO.StreamThe file stream.
True if the file is encrypted, false otherwise.
Specifies whether the file is password protected.
bool IsEncryptedFile(string fileName)
fileName
stringThe file name.
True if the file is encrypted, false otherwise.
Opens the specified format file stream.
void Open(Stream fileStream, OpenFileFormat fileFormat)
fileStream
System.IO.StreamThe specified file stream.
fileFormat
OpenFileFormatThe format of the file stream.
Opens the stream with specified options.
void Open(Stream fileStream, OpenOptionsBase options)
fileStream
System.IO.StreamThe file stream.
options
OpenOptionsBaseThe format of opening the file stream. Possible types:
Opens the specified excel file stream.
void Open(Stream fileStream, string password = null, OpenOptions openOptions = null)
fileStream
System.IO.StreamThe file stream.
password
stringThe password of the file.
openOptions
OpenOptionsOptions for opening.
This method is now obsolete.
Opens the file stream.
void Open(Stream fileStream)
fileStream
System.IO.StreamThe specified file stream.
Opens the JSON file.
IList<JsonError> Open(string fileName, DeserializationOptions deserializationOptions)
fileName
stringThe specified JSON file.
deserializationOptions
DeserializationOptionsThe JSON deserialization options.
The error list of the JSON.
Opens the specified format file.
void Open(string fileName, OpenFileFormat fileFormat)
fileName
stringThe specified file.
fileFormat
OpenFileFormatThe format of the file.
Opens the file with specified options.
void Open(string fileName, OpenOptionsBase options)
fileName
stringThe excel file.
options
OpenOptionsBaseThe options of opening the file. Possible types:
Opens the specified excel file.
void Open(string fileName, string password = null, OpenOptions openOptions = null)
fileName
stringThe excel file.
password
stringThe password of the file.
openOptions
OpenOptionsOptions for opening.
This method is now obsolete.
Opens the file.
void Open(string fileName)
fileName
stringThe specified file.
Prints the workbook.
void PrintOut(PrintOutOptions options = null)
options
PrintOutOptionsOptions for printing the workbook.
Start to process the template
void ProcessTemplate()
Start to process the template with global options and cancellation support.
void ProcessTemplate(CancellationToken cancellationToken)
cancellationToken
System.Threading.CancellationTokenThe token to monitor for cancellation requests.
The caller must decide whether to accept the partially expanded template or revert to the previous state. If the caller needs to revert to the previous state, it must serialize the workbook before calling this method, then deserialize the workbook after canceling the operation.
Throws when the System.Threading.CancellationToken was canceled.
Protects a workbook so that it cannot be modified.
void Protect(bool structure = true, bool windows = false)
structure
boolTrue to protect the structure of the workbook (To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets). The default value is true.
windows
boolTrue to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.
Protects a workbook so that it cannot be modified.
void Protect(string password, bool structure = true, bool windows = false)
password
stringPassword to protect the workbook.
structure
boolTrue to protect the structure of the workbook (To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets).
windows
boolTrue to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.
Saves the specified format file stream.
void Save(Stream fileStream, SaveFileFormat fileFormat)
fileStream
System.IO.StreamThe specified file stream.
fileFormat
SaveFileFormatThe format of the file stream.
Saves workbook to stream with specified options.
void Save(Stream fileStream, SaveOptionsBase options)
fileStream
System.IO.StreamThe specified file stream.
options
SaveOptionsBaseThe options of saving the file stream. Possible types:
Saves data to the specified excel file stream.
void Save(Stream fileStream, string password = null, SaveOptions saveOptions = null)
fileStream
System.IO.StreamThe file stream.
password
stringThe password of the file.
saveOptions
SaveOptionsOptions for saving.
Saves the workbook to the stream.
void Save(Stream fileStream)
fileStream
System.IO.StreamThe file stream.
Saves the specified format file.
void Save(string fileName, SaveFileFormat fileFormat)
fileName
stringThe specified file.
fileFormat
SaveFileFormatThe format of the file.
Saves workbook to file with specified options.
void Save(string fileName, SaveOptionsBase options)
fileName
stringThe specified file.
options
SaveOptionsBaseThe options of saving the file. Possible types:
Saves data to the specified excel file.
void Save(string fileName, string password = null, SaveOptions saveOptions = null)
fileName
stringThe excel file.
password
stringThe password of the file.
saveOptions
SaveOptionsOptions for saving.
Saves the workbook to the disk.
void Save(string fileName)
fileName
stringThe file name.
Generates a JSON string from a workbook.
string ToJson(SerializationOptions serializationOptions = null)
serializationOptions
SerializationOptionsThe SerializationOptions object.
The JSON string.
Generates a JSON stream from a workbook.
void ToJson(Stream stream, SerializationOptions serializationOptions = null)
stream
System.IO.StreamThe specified JSON stream.
serializationOptions
SerializationOptionsThe SerializationOptions object.
Generates a JSON string from a workbook. It integrates all JSON files from the SJS file into a single string.
string ToSjsJson()
Json data.
Generates a JSON string from a workbook. It integrates all JSON files from the SJS file into a single string.
string ToSjsJson(SjsSaveOptions options)
options
SjsSaveOptionsOption for saving sjs file.
Json data.
Integrates all JSON files from the SJS file into a single string, then put the string into the stream.
void ToSjsJson(Stream stream, SjsSaveOptions options)
stream
System.IO.StreamThe specified file stream.
options
SjsSaveOptionsOption for saving sjs file.
Integrates all JSON files from the SJS file into a single string, then put the string into the stream.
void ToSjsJson(Stream stream)
stream
System.IO.StreamThe specified file stream.
Removes protection from the workbook.
void Unprotect(string password = null)
password
stringPassword to protect the workbook.
Updates a excel link.
void UpdateExcelLink(string name, IWorkbook sourceWorkbook)
name
stringthe link name.
sourceWorkbook
IWorkbookthe workbook instance for the link.
Updates a excel link.
void UpdateExcelLink(string name)
name
stringthe link name.
Updates all the excel links.
void UpdateExcelLinks()
Waits for all calculation to complete, including asynchronous calculations. This method blocks the current thread until all calculations have finished. Users can call this method to ensure that all necessary computations have been performed before proceeding with any other operations that depend on the calculation results.
void WaitForCalculationToFinish()
Occurs after the workbook is saved.
event EventHandler AfterSave
Occurs before the workbook is saved.
event EventHandler BeforeSave
Occurs when a new sheet is created in the workbook.
event EventHandler<SheetEventArgs> NewSheet
Occurs when the workbook is opened.
event EventHandler Opened
Occurs when a sheet is activate.
event EventHandler<SheetEventArgs> SheetActivate
Occurs before a sheet is deleted.
event EventHandler<SheetEventArgs> SheetBeforeDelete
Occurs when something changes in the cells of a sheet.
event EventHandler<RangeEventArgs> SheetChange
Occurs when a sheet is deactivated.
event EventHandler<SheetEventArgs> SheetDeactivate
Occurs when the selection changes on a sheet.
event EventHandler<RangeEventArgs> SheetSelectionChange