Click or drag to resize

Workbook Methods

The Workbook type exposes the following members.

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
See Also