IWorkbook Methods |
The IWorkbook type exposes the following members.
Name | Description | |
---|---|---|
![]() |
Activate |
Activates the first window associated with the workbook.
|
![]() |
AddFont |
Adds font to the inner fonts collection and makes this font read-only.
|
![]() |
Clone |
Creates copy of the current instance.
|
![]() |
Close |
Closes the object without saving.
|
![]() |
Close(Boolean) |
Closes the object.
|
![]() |
Close(String) |
Closes the object and saves changes into specified file.
|
![]() |
Close(Boolean, String) |
Closes the object.
|
![]() |
CopyToClipboard |
Copies workbook to the clipboard.
|
![]() ![]() |
CreateFont |
Method to create a font object and register it in the workbook.
![]()
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>
|
![]() |
CreateFont(Font) |
Method creates a font object based on native font and register it in the workbook.
|
![]() |
CreateFont(IFont) |
Method that creates font object based on another font object
and registers it in the workbook.
|
![]() |
CreateTemplateMarkersProcessor |
Creates object that can be used for template markers processing.
|
![]() ![]() |
FindAll(Boolean) |
This method seraches for the all cells with specified bool value.
![]()
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>
|
![]() ![]() |
FindAll(DateTime) |
This method seraches for the all cells with specified DateTime value.
![]()
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>
|
![]() ![]() |
FindAll(TimeSpan) |
This method seraches for the all cells with specified TimeSpan value.
![]()
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>
|
![]() ![]() |
FindAll(Double, FindType) |
This method seraches for the all cells with specified double value.
![]()
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>
|
![]() ![]() |
FindAll(String, FindType) |
This method seraches for the all cells with specified string value.
![]()
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>
|
![]() ![]() |
FindOne(Boolean) |
This method seraches for the first cell with specified bool value.
![]()
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>
|
![]() ![]() |
FindOne(DateTime) |
This method seraches for the first cell with specified DateTime value.
![]()
This sample shows how to find the first cell with specified DateTime value:
<para>//Create workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Find cell with specified DateTime value</para><para>DateTime dateTime = DateTime.Now;</para><para>IXLSRange result = workbook.FindDateTime(dateTime);</para>
|
![]() ![]() |
FindOne(TimeSpan) |
This method seraches for the first cell with specified TimeSpan value.
![]()
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>
|
![]() ![]() |
FindOne(Double, FindType) |
This method seraches for the first cell with specified double value.
![]()
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>
|
![]() ![]() |
FindOne(String, FindType) |
This method seraches for the first cell with specified string value.
![]()
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>
|
![]() ![]() |
GetNearestColor(Color) |
Gets the nearest color to the specified Color structure
from Workbook palette.
![]()
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>
|
![]() ![]() |
GetNearestColor(Int32, Int32, Int32) |
Gets the nearest color to the specified by red, green, and blue
values color from Workbook palette.
![]()
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>
|
![]() ![]() |
GetPaletteColor |
Method return Color object from workbook palette by its index.
![]()
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>
|
![]() |
Protect |
Sets protection for workbook.
|
![]() ![]() |
Replace(String, DateTime) |
Replaces specified string by specified value.
![]()
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>
|
![]() ![]() |
Replace(String, Double) |
Replaces specified string by specified value.
![]()
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>
|
![]() ![]() |
Replace(String, String) |
Replaces specified string by specified value.
![]()
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>
|
![]() ![]() |
Replace(String, DataColumn, Boolean) |
Replaces specified string by data column values.
![]()
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>
|
![]() ![]() |
Replace(String, DataTable, Boolean) |
Replaces specified string by data table values.
![]()
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>
|
![]() ![]() |
Replace(String, Double , Boolean) |
Replaces specified string by data from array.
![]()
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>
|
![]() ![]() |
Replace(String, Int32 , Boolean) |
Replaces specified string by data from array.
![]()
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>
|
![]() ![]() |
Replace(String, String , Boolean) |
Replaces specified string by data from array.
![]()
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>
|
![]() ![]() |
ResetPalette |
Recover palette to default values.
![]()
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>
|
![]() ![]() |
Save |
Saves changes to the specified workbook.
![]()
This sample shows how to save changes to the specified workbook:
<para>//Load workbook</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>//Save to file</para><para>workbook.Save();</para>
|
![]() |
SaveAs(Stream) |
Saves changes to the specified stream.
|
![]() |
SaveAs(String) |
Short variant of SaveAs method.
|
![]() |
SaveAs(Stream, ExcelSaveType) |
Saves changes to the specified stream.
|
![]() ![]() |
SaveAs(Stream, String) |
Save active WorkSheet using separator.
![]()
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>
|
![]() |
SaveAs(String, ExcelSaveType) |
Short variant of SaveAs method.
|
![]() ![]() |
SaveAs(String, String) |
Save active WorkSheet using separator.
![]()
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>
|
![]() |
SaveAs(String, HttpResponse) |
Saves changes to the specified HttpResponse.
|
![]() |
SaveAs(String, ExcelSaveType, HttpResponse) |
Saves changes to the specified HttpResponse.
|
![]() |
SaveAsHtml |
Saves changes to the specified stream.
|
![]() |
SetColorOrGetNearest(Color) |
If there is at least one free color, define a new color;
if not, search for the closest one.
|
![]() |
SetColorOrGetNearest(Int32, Int32, Int32) |
If there is at least one free color, define a new color;
if not, search for the closest one.
|
![]() ![]() |
SetPaletteColor |
Set user color for specified element in Color table.
![]()
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>
|
![]() |
SetSeparators |
Sets separators for formula parsing.
|
![]() |
SetWriteProtectionPassword |
This method sets write protection password.
|
![]() |
Unprotect |
Unprotects workbook.
|