Click or drag to resize

Workbook Class

Represents a workbook.
Inheritance Hierarchy
System Object
Spire.Xls Workbook

Namespace: Spire.Xls
Assembly: Spire.XLS (in Spire.XLS.dll) Version: 15.4.0.0 (15.4.0.5046)
Syntax
public sealed class Workbook : IDisposable

The Workbook type exposes the following members.

Constructors
Name Description
Public method Workbook
Create a new instance of workbook.
Top
Properties
Name Description
Public property ActiveSheet
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.
Public property ActiveSheetIndex
Gets or sets index of the active worksheet.
Public property AddInFunctions
Returns collection of add-in functions.
Public property Static member AIHelper
helper for call AI.
Public property Allow3DRangesInDataValidation
Indicates whether to allow usage of 3D ranges in DataValidation list property (MS Excel doesn't allow).
Public property CalculationMode
Get or set calculation mode.
Public property Charts
Returns a Sheets collection that represents all the chart sheets in the specified workbook. Read-only.
Public property Chartsheets
Gets a list of chartsheets in the Excel workbook.
Public property CheckComptiliblity
Indicates whether check comptiliblity when saving workbook.
Public property CodeName
Name which used by macros to access to workbook items.
Public property Code example Colors
Returns colors in the palette for the workbook. The palette has 56 entries, each represented by an RGB value. Read/write Object.
Examples
The following code illustrates how to access the default colors of excel color palette:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get colors</para><para>System.Drawing.Color[] colors = workbook.Colors;</para><para>//Get color</para><para>System.Drawing.Color color = colors[2];</para><para>//Set color</para><para>worksheet["B2"].Style.Color = color;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public property ConverterSetting
Gets or sets the converter settings for the Excel workbook.
Public property CultureInfo
Gets or sets the culture information used for formatting and parsing. This setting is equivalent to setting the editing language of Excel.
Public property Code example CustomDocumentProperties
Returns collection that represents all the custom document properties for the specified workbook. Read-only.
Examples
The following code snippet illustrates how to get the custom document properties:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Get the document properties</para><para>ICustomDocumentProperties documentProperties = workbook.CustomDocumentProperties;</para>
Public property CustomFontFileDirectory
Sets the custom directory of font files.
Public property CustomFontFilePaths
Returns or sets the custom path of font files.
Public property CustomTableStyles
Gets the custom table styles defined in the Excel workbook.
Public property DataConns
Gets the collection of data connections associated with the workbook.
Public property DataSorter
Gets Data sorter to sort the data..
Public property Date1904
True if the workbook uses the 1904 date system. Read/write Boolean.
Public property Code example DefaultFontName
Returns or sets the name of the default font.
Examples
The following code illustrates how to set the standard font for the workbook:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["B2"].Text = "Text";</para><para>//Set standard font</para><para>workbook.DefaultFontName = "Arial";</para><para>//Set standard font size</para><para>workbook.DefaultFontSize = 18;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public property Code example DefaultFontSize
Returns or sets the default font size.
Examples
The following code illustrates how to set the standard font size for the workbook:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["B2"].Text = "Text";</para><para>//Set standard font</para><para>workbook.DefaultFontName = "Arial";</para><para>//Set standard font size</para><para>workbook.DefaultFontSize = 18;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public property DisableMacrosStart
Allows users to disable load of macros from document.
Public property Code example DocumentProperties
Returns a BuiltInDocumentProperties collection that represents all the built-in document properties for the specified workbook. Read-only.
Examples
The following code snippet illustrates how to get the built in document properties:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Get the built in document properties</para><para>IBuiltInDocumentProperties builtInDocumentProperties = workbook.DocumentProperties;</para>
Public property ExternalLinks
Gets the collection of external links in the workbook.
Public property FileName
Gets file name.
Public property HasMacros
Indicates whether contains VBA macros.
Public property HasTrackedChanges
Indicates whether the workbook has any tracked changes
Public property IsCellProtection
Indicates whether cells are protected.
Public property IsDigitallySigned
Indicates whether this spreadsheet is digitally signed.
Public property IsHideWindow
Hide window
Public property Code example IsHScrollBarVisible
Returns or sets whether show horizontal scroll bar.
Examples
This sample shows how to hide horizontal scroll bar:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>//Hide horizontal scroll bar</para><para>workbook.IsHScrollBarVisible = false;</para><para>//Save to file</para><para>workbook.SaveToFile("IsHScrollBarVisible.xlsx");</para>
Public property IsRightToLeft
Indicates whether worksheet is displayed right to left.
Public property IsSaved
Indicates whether workbook changes have been saved.
Public property Code example IsVScrollBarVisible
Returns or sets whether show vertical scroll bar.
Examples
This sample shows how to hide vertical scroll bar:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>//Hide vertical scroll bar</para><para>workbook.IsVScrollBarVisible = false;</para><para>//Save to file</para><para>workbook.SaveToFile("IsVScrollBarVisible.xlsx");</para>
Public property IsWindowProtection
Indicates window is protected.
Public property MarkerDesigner
Gets the MarkerDesigner instance.
Public property MaxColumnCount
Returns maximum column count for each worksheet in this workbook. Read-only.
Public property MaxDigitWidth
Gets the maximum digit width in the Excel workbook.
Public property MaxRowCount
Returns maximum row count for each worksheet in this workbook. Read-only.
Public property MaxRowsOfSharedFormula
Gets or sets the maximum number of rows for shared formulas in the workbook.
Public property Code example NameRanges
Gets Names collection that represents all the names in the specified workbook.
Examples
The following code snippet illustrates how to get names:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Get names</para><para>INameRanges names = workbook.NameRanges;</para>
Public property OpenPassword
Returns or sets password to encrypt document.
Public property OptimizeImport
Indicates whether to optimize Import data. This option will take effect only on Import methods that are available with the worksheet WARNING: Setting this property to True can decrease memory significantly, but will increase the performance of data import .
Public property Code example PivotCaches
Returns pivot caches collection. Read-only.
Examples
The following code snippet illustrates how to get pivot caches:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Gets pivot caches collection</para><para>IPivotCaches pivotCaches = workbook.PivotCaches;</para>
Public property PrintDialog
Sets the print dialog for the current instance.
Public property PrintDocument
Gets the PrintDocument
Public property ProhibitDtd
prohibt dtd processing switch
Public property ReadOnly
Indicates whether the workbook has been opened as Read-only.
Public property SelectedTab
Gets or sets tab index of selected.
Public property SheetTabBarWidth
Returns or sets the width of worksheet tab bar. 1/1000 of window width.
Public property ShowTabs
Get or sets a value whether the Workbook tabs are displayed.
Public property Code example Styles
Returns a Styles collection that represents all the styles in the specified workbook. Read-only.
Examples
The following code snippet illustrates how to get the Styles:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set styles</para><para>IStyles styles = workbook.Styles;</para>
Public property TrackedChanges
Turn revision mode on or off.
Public property UseStorageMode
User Compound storage mode
Public property Version
Gets or sets the version of the Excel workbook.
Public property Worksheets
Returns a Sheets collection that represents all the worksheets in the specified workbook. Read-only Sheets object.
Public property WriteProtection
Returns options of the workbook write protection.
Top
Methods
Name Description
Public method AcceptAllTrackedChanges
Accept all tracked changes in the workbook.
Public method AddCustomFont
Adds a custom font to the PDF document.
Public method AddDigitalSignature
Add a DigitalSignature.
Public method AddPivotTableStyle
Adds a pivot table style to the workbook.
Public method CaculateFormulaValue Obsolete.
Computes the string formula
Public method CalculateAllValue
Caculate all formula for the workbook
Public method CalculateFormulaValue
Computes the string formula
Public method Code example ChangePaletteColor
Changes the palette for the spreadsheet in the specified index.
Examples
The following code snippet illustrates how to set palette color:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set palette color</para><para>workbook.ChangePaletteColor(System.Drawing.Color.Red , 10);</para><para>//Set color</para><para>worksheet["B2"].Style.Color = workbook.Colors[10];</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method ClearFontCache
Clear used fonts in cache.
Public method ColumnWidthToPixels
onverts column width in characters into column width in pixels.
Public method ContainsFont
Indicates whether the workbook contains specified font.
Public method CopyTheme
Copy the theme from source workbook
Public method CopyThemeColor
Copy the theme color from source workbook
Public method CopyToClipboard Obsolete.
Copies whole workbook to the clipboard.
Public method CopyToClipboard(Worksheet) Obsolete.
Copies the selected worksheet to clipboard.
Public method CreateEmptySheet
Create a new worksheet.
Public method CreateEmptySheet(String)
Create a new worksheet.
Public method CreateEmptySheets(Int32)
Create workbook with specified number of worksheets.
Public method CreateEmptySheets( String )
Create workbook with specified names of worksheets.
Public method Code example CreateFont
Creates a font object and add it to the workbook.
Examples
The following code illustrates how to create IFont object:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>IRichTextString richText = worksheet["B2"].RichText;</para><para>//Create font</para><para>IFont font = workbook.CreateFont();</para><para>//Set color</para><para>font.Color = Color.Red;</para><para>//Set text</para><para>richText.Text = "Sample";</para><para>//Set font</para><para>richText.SetFont(0, 5, font);</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method CreateFont(Font)
Creates a font object and add it to the workbook.
Public method CreatePivotStyle
Creates a new pivot style in the spreadsheet.
Public method Dispose
Disposes of the Excel workbook and suppresses finalization.
Public method Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object .)
Public method Code example FindAllBool
Finds the cell with the input bool.
Examples
This sample shows how to find all cells with specified bool value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cells with specified bool value</para><para>CellRange[] result = workbook.FindAllBool(true);</para>
Public method Code example FindAllDateTime
Finds the cell with the input datetime.
Examples
This sample shows how to find all cells with specified DateTime value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cells with specified DateTime value</para><para>CellRange[] result = workbook.FindAllDateTime(DateTime.Now);</para>
Public method Code example FindAllNumber
Finds the cell with the input double.
Examples
This sample shows how to find all cells with specified doulbe value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cells with specified double value</para><para>CellRange[] result = workbook.FindAllNumber(100.32 , false);</para>
Public method Code example FindAllString
Finds the cell with the input string.
Examples
This sample shows how to find all cells with specified string value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cells with specified string value</para><para>string value = "value";</para><para>CellRange[] result = workbook.FindAllString(value , false , false);</para>
Public method Code example FindAllTimeSpan
Finds the cell with the input time span.
Examples
This sample shows how to find all cells with specified TimeSpan value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cells with specified TimeSpan value</para><para>TimeSpan value = new TimeSpan(2, 30, 30);</para><para>CellRange[] result = workbook.FindAllTimeSpan(value);</para>
Public method Code example FindBool
Finds the cell with the input bool.
Examples
This sample shows how to find the first cell with specified bool value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified bool value</para><para>IXLSRange result = workbook.FindBool(true);</para>
Public method Code example FindDateTime
Finds the cell with the input datetime.
Examples
This sample shows how to find the first cell with specified DataTime value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified DataTime value</para><para>DateTime dateTime = DateTime.Now;</para><para>IXLSRange result = workbook.FindDateTime(dateTime);</para>
Public method Code example FindNumber
Finds the cell with the input number.
Examples
This sample shows how to find the first cell with specified double value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified double value</para><para>double value = 9.00;</para><para>IXLSRange result = workbook.FindNumber(value, false);</para>
Public method Code example FindString
Finds the cell with the input string.
Examples
This sample shows how to find the first cell with specified string value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified string value</para><para>string value = "value";</para><para>IXLSRange result = workbook.FindString(value, false, false);</para>
Public method Code example FindTimeSpan
Finds the cell with the input time span.
Examples
This sample shows how to find the first cell with specified TimeSpan value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified TimeSpan value</para><para>TimeSpan timeSpan = new TimeSpan(2, 30, 30);</para><para>IXLSRange result = workbook.FindTimeSpan(timeSpan);</para>
Public method GetChartSheetByName
Retrieves a ChartSheet by its name.
Public method GetCustomFontParsedResult
Get result that parse the custom path of font files
Public method GetDigitalSignatures
Get collection of DigitalSignature in this file.
Public method GetHashCode
Serves as the default hash function.
(Inherited from Object .)
Public method Code example GetMatchingColor(Color)
Find best matching Color in workbook palette.
Examples
The following code illustrates how to get the indexed color from ExcelColors for the given color from Color structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get color</para><para>ExcelColors color = workbook.GetMatchingColor(System.Drawing.Color.Red);</para><para>//Set color</para><para>worksheet["B2"].Style.KnownColor = color;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method Code example GetMatchingColor(Int32, Int32, Int32)
Find best matching Color in workbook palette.
Examples
The following code illustrates how to get the indexed color from ExcelColors for the given color from Color structure:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get color</para><para>ExcelColors color = workbook.GetMatchingColor(255, 0, 0);</para><para>//Set color</para><para>worksheet["B2"].Style.KnownColor = color;</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method GetOleSize
get the size of the visible range of cells when this workbook is displyed as an embedded obect in another document;
Public method Code example GetPaletteColor
Gets excel color from workbook palette.
Examples
The following code illustrates how to get the RGB color value for the specified color from ExcelColors enumeration:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get color</para><para>System.Drawing.Color color = workbook.GetPaletteColor(ExcelColors.Red);</para><para>//Set color</para><para>worksheet["B2"].Style.Color = workbook.Colors[10];</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method GetSafeSheetName(String)
Returns a safe sheet name by replacing invalid characters with a specified replacement character.
Public method GetSafeSheetName(String, Char)
Safely converts the input worksheet name by replacing restricted characters and truncating if necessary.
Public method GetSplitPageInfo
Retrieves the split page information for the Excel workbook based on the converter settings.
Public method GetSplitPageTable
Retrieves a DataTable containing information about the split pages in a workbook.
Public method GetThemeColor
Gets theme color.
Public method GetType
Gets the Type of the current instance.
(Inherited from Object .)
Public method InitCalcEngine
Initilize Calc engine
Public method Static member IsPasswordProtected(Stream)
Determines if a workbook is password-protected.
Public method Static member IsPasswordProtected(String)
check file is password protect
Public method LoadFromFile(String)
Loads a file and imports its data.
Public method LoadFromFile(String, ExcelVersion)
Loads a file and imports its data.
Public method LoadFromFile(String, Boolean)
Loads a file and imports its data.
Public method LoadFromFile(String, String)
Loads text files stream with user defined separator.
Public method LoadFromFile(String, String, Int32, Int32)
Loads text files with user defined separator.
Public method LoadFromFile(String, String, Int32, Int32, ExcelVersion)
Loads text files with user defined separator.
Public method LoadFromFile(String, String, Int32, Int32, ExcelVersion, Encoding)
Loads text files with user defined separator.
Public method LoadFromHtml(Stream)
Loads a html file and imports its data.
Public method LoadFromHtml(String)
Loads a html file and imports its data.
Public method LoadFromMHtml(Stream)
Loads a Mhtml file and imports its data.
Public method LoadFromMHtml(String)
Loads a Mhtml file and imports its data.
Public method LoadFromStream(Stream)
Load workbook from the stream.
Public method LoadFromStream(Stream, ExcelVersion)
Load workbook from the stream.
Public method LoadFromStream(Stream, Boolean)
Load workbook from the stream.
Public method LoadFromStream(Stream, String, Int32, Int32)
Loads text files stream with user defined separator.max row 60000.
Public method LoadFromStream(Stream, String, Int32, Int32, ExcelVersion)
Loads text files stream with user defined separator. Version2007 support 60000+ row
Public method LoadFromXml(Stream)
Loads a xml file and imports its data.
Public method LoadFromXml(String)
Loads a xml file and imports its data.
Public method LoadTemplateFromFile(String)
Load workbook from the excel template.
Public method LoadTemplateFromFile(String, Boolean)
Load workbook from the excel template.
Public method PasteFromClipboard
Copies workbook and all its worksheets from the clipboard.
Public method PixelsToColumnWidth
Converts column width in pixels into column width in characters.
Public method Protect(String)
protect file also protect workbook window and structure.
Public method Protect(String, Boolean, Boolean)
protect file,also Indicates whether protect workbook window and structure or not
Public method ProtectWorkbook
Sets protection for workbook.
Public method RejectAllTrackedChanges
Reject all tracked changes in the workbook.
Public method RemoveAllDigitalSignatures
Remove all DigitalSignature in this file.
Public method Code example Replace(String, DateTime)
Replaces cell's value by specified value.
Examples
The following code illustrates how to replace the string value with datetime:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by dateTime</para><para>string oldValue = "Find";</para><para>DateTime dateTime = DateTime.Now;</para><para>workbook.Replace(oldValue, dateTime);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, Double)
Replaces cell's value by specified value.
Examples
The following code snippet illustrates how to replace the string with double:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by double</para><para>string oldValue = "Ten";</para><para>workbook.Replace(oldValue, 10.0);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, String)
Replaces cell's value by specified value.
Examples
The following code snippet illustrates how to replace the string with another string:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by newValue</para><para>string oldValue = "Find";</para><para>string newValue = "NewValue";</para><para>workbook.Replace(oldValue, newValue);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, DataColumn, Boolean)
Replaces cell's value from data column values.
Examples
The following code snippet illustrates how to replace the string value with data column:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by data column</para><para>string oldValue = "Find";</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("Dosage", typeof(int));</para><para>table.Rows.Add(1);</para><para>System.Data.DataColumn dataColumn = table.Columns[0];</para><para>workbook.Replace(oldValue, dataColumn, true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, DataTable, Boolean)
Replaces cell's value from data table values.
Examples
The following code snippet illustrates how to replace the string value with data table:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by data table</para><para>string oldValue = "Find";</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("Dosage", typeof(int));</para><para>table.Rows.Add(1);</para><para>workbook.Replace(oldValue, table, true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, Double , Boolean)
Replaces cell's value from array.
Examples
The following code snippet illustrates how to replace the string with array of double values:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by array of double values</para><para>string oldValue = "Find";</para><para>double[] newValues = { 1.0, 2.0 };</para><para>workbook.Replace(oldValue, newValues, true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, Int32 , Boolean)
Replaces cell's value from array.
Examples
The following code snippet illustrates how to replace the string with array of int values:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by array of int values</para><para>string oldValue = "Find";</para><para>int[] newValues = { 1, 2 };</para><para>workbook.Replace(oldValue, newValues, true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example Replace(String, String , Boolean)
Replaces cell's value from array.
Examples
The following code snippet illustrates how to replace the string with array of string values:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Replace the oldValue by array of string values</para><para>string oldValue = "Find";</para><para>string[] newValues = { "X values", "Y values" };</para><para>workbook.Replace(oldValue, newValues , true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
Public method Code example ResetPalette
Resets the color palette to the default colors.
Examples
The following code snippets illustrates how to reset the palette:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Get colors</para><para>System.Drawing.Color[] colors = workbook.Colors;</para><para>//Check color</para><para>Console.WriteLine(colors[2].Name);</para><para>//Set color</para><para>colors[2] = System.Drawing.Color.Yellow;</para><para>//Reset palette</para><para>workbook.ResetPalette();</para><para>//Check color</para><para>Console.WriteLine(workbook.Colors[2].Name);</para><para>//Save to file</para><para>workbook.SaveToFile("CellFormats.xlsx");</para>
Public method Save
Saves changes to the specified workbook
Public method SaveAsImage(Single, Single)
Saves the Excel workbook as images.
Public method SaveAsImage(Int32, Single, Single)
Save workbook to image.
Public method SaveAsTemplate(String)
Save workbook as template to file.
Public method SaveAsTemplate(String, HttpResponse)
Save workbook as template to response.
Public method SaveAsXml(Stream)
Save workbook as XML format to stream.
Public method SaveAsXml(String)
Save workbook to an XML data file.
Public method SaveChartAsEmfImage(Worksheet) Obsolete.
Save chart to vector images.
Public method SaveChartAsEmfImage(Worksheet, Int32) Obsolete.
Save chart to vector image.
Public method SaveChartAsEmfImage(Worksheet, Int32, Stream)
Save chart to vector image.
Public method SaveChartAsImage(ChartSheet)
Save chart to image.
Public method SaveChartAsImage(Worksheet)
Save chart to images.
Public method SaveChartAsImage(Worksheet, Int32)
Save chart to image.
Public method SaveToFile(String)
Saves changes to the workbook in a different file
Public method SaveToFile(String, ExcelVersion)
Saves changes to the workbook in a different file
Public method SaveToFile(String, FileFormat)
Saves changes to the workbook in a different file
Public method SaveToFile(String, TextSaveOptions)
Saves changes to the workbook in a different file
Public method Code example SaveToFile(String, String)
Saves changes to the workbook in a different file.
Examples
The following code illustrates how to save the active worksheet in a different file with separator:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Save to file</para><para>workbook.SaveToFile("Result.csv" , ",");</para>
Public method SaveToFile(String, FileFormat, Boolean)
Saves changes to the workbook in a different file
Public method Code example SaveToFile(String, String, Boolean)
Saves changes to the workbook in a different file.
Examples
The following code illustrates how to save the active worksheet in a different file with separator:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Save to file</para><para>workbook.SaveToFile("Result.csv" , ",", true);</para>
Public method SaveToHtml(String)
Saves the workbook to html
Public method SaveToHtml(String, Boolean)
Saves the workbook to html
Public method SaveToHttpResponse(String, HttpResponse)
Save workbook to the http response.
Public method SaveToHttpResponse(String, HttpResponse, HttpContentType)
Save workbook to the http response.
Public method SaveToHttpResponse(String, HttpResponse, Boolean)
Save workbook to the http response.
Public method SaveToHttpResponse(String, HttpResponse, HttpContentType, FileFormat)
Save workbook to the http response.
Public method SaveToMarkdown
Saves the workbook to markdown
Public method SaveToStream(Stream)
Save workbook the stream
Public method SaveToStream(Stream, FileFormat)
Save workbook to stream.
Public method Code example SaveToStream(Stream, String)
Save workbook the stream.
Examples
The following code illustrates how to saves the active worksheet as stream with separator:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Save to stream</para><para>Stream stream = new MemoryStream();</para><para>workbook.SaveToFile(stream , ",");</para>
Public method Static member SetGlobalCustomFontsFolders
Sets the path to the folder where the global custom font is located.
Public method SetMaxDigitWidth
Sets the maximum digit width for the Excel workbook.
Public method SetOleSize
set the size of the visible range of cells when this workbook is displyed as an embedded obect in another document;
Public method SetThemeColor
Sets the theme color
Public method SetWriteProtectionPassword
Sets write protection password.
Public method SprBpcmUuRG9jLkRvY3Vt
Set internal license information(office viewer).
Public method ToString
Returns a string that represents the current object.
(Inherited from Object .)
Public method UnProtect
unprotect file also upprotect workbook window and structure
Public method UnProtect(String)
unprotect file also upprotect workbook window and structure
Public method UnProtectWorkbook
unprotect workbook window and structure
Public method XlsPageToImagedg
XLS Load Page Data Delegate Method
Top
Events
Name Description
Public event PageImagePainted
Occurs when the page image is painted.
Top
See Also