IWorksheet Methods |
The IWorksheet type exposes the following members.
Name | Description | |
---|---|---|
![]() |
Activate |
Makes the current sheet the active sheet. Equivalent to clicking the
sheet's tab.
(Inherited from
ITabSheet
.)
|
![]() ![]() |
AutoFitColumn |
Autofits specified column.
![]()
The following code illustrates how to Auto-fit the column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Sample text in cell";</para><para>//Set auto fit</para><para>worksheet.AutoFitColumn(1);</para><para>//Save to file</para><para>workbook.SaveToFile("AutoFitColumn.xlsx");</para>
|
![]() ![]() |
AutoFitRow |
Autofits specified row.
![]()
The following code illustrates how to Auto-fit the row:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Value = "Sample text";</para><para>//Set Style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>IFont font = style.Font;</para><para>font.Size = 18;</para><para>worksheet["C2"].Style = style;</para><para>//Set auto fit</para><para>worksheet.AutoFitRow(2);</para><para>//Save to file</para><para>workbook.SaveToFile("AutoFitRow.xlsx");</para>
|
![]() ![]() |
CheckExistence |
Indicates whether a cell was initialized or accessed by the user.
![]()
The following code illustrates if the cells was initialized or accessed by the user:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet.Range["A1"].Text = "Hello";</para><para>//Check the cell.Output will be true.</para><para>Console.Write(worksheet.CheckExistence(1, 1));</para><para>//Save to file</para><para>workbook.SaveToFile("CheckExistence.xlsx");</para>
|
![]() |
Clear |
Clears worksheet data. Removes all formatting and merges.
|
![]() |
ClearData |
Clears worksheet. Only the data is removed from each cell.
|
![]() |
ColumnWidthToPixels |
Converts column width into pixels.
|
![]() |
CopyToClipboard |
Copies worksheet into the clipboard.
|
![]() |
CreateNamedRanges |
Creates object that can be used for template markers processing.
Names to createRefers to rangeTrue if the named range values are vertically placed in the sheet.
|
![]() |
DeleteColumn |
Removes specified column (with formulas update).
|
![]() |
DeleteRow |
Removes specified row (with formulas update).
|
![]() |
GetBoolean |
Gets bool value from cell.
|
![]() ![]() |
GetColumnWidthPixels |
Returns width in pixels from ColumnInfoRecord if there is corresponding ColumnInfoRecord
or StandardWidth if not.
![]()
The following code illustrates how to get the column width for a particular column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["A1"].Text = "Sample text in cell";</para><para>//Set auto fit</para><para>worksheet.AutoFitColumn(1);</para><para>//Get column width</para><para>Console.WriteLine(worksheet.GetColumnWidthPixels(1));</para><para>//Save to file</para><para>workbook.SaveToFile("UsedRange.xlsx");</para>
|
![]() ![]() |
GetDefaultColumnStyle |
Returns default column style.
![]()
The following code illustrates how to get default column style:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultColumnStyle(2,style);</para><para>//Get default style</para><para>CellStyle defaultStyle = worksheet.GetDefaultColumnStyle(2);</para><para>//Set color</para><para>defaultStyle.Color = Color.Blue;</para><para>worksheet.SetDefaultColumnStyle(3, defaultStyle);</para><para>//Save to file</para><para>workbook.SaveToFile("GetDefaultColumnStyle.xlsx");</para>
|
![]() ![]() |
GetDefaultRowStyle |
Returns default row style.
![]()
The following code illustrates how to get default row style:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultRowStyle(2,style);</para><para>//Get default style</para><para>CellStyle defaultStyle = worksheet.GetDefaultRowStyle(2);</para><para>//Set color</para><para>defaultStyle.Color = Color.Blue;</para><para>worksheet.SetDefaultRowStyle(3, defaultStyle);</para><para>//Save to file</para><para>workbook.SaveToFile("GetDefaultColumnStyle.xlsx");</para>
|
![]() |
GetError |
Gets error value from cell.
|
![]() |
GetFormula |
Returns formula value corresponding to the cell.
|
![]() |
GetFormulaBoolValue |
Gets formula bool value from cell.
|
![]() |
GetFormulaErrorValue |
Gets formula error value from cell.
|
![]() |
GetFormulaNumberValue |
Returns formula number value corresponding to the cell.
|
![]() |
GetFormulaStringValue |
Returns formula string value corresponding to the cell.
|
![]() |
GetNumber |
Returns number value corresponding to the cell.
|
![]() ![]() |
GetRowHeightPixels |
Returns height from RowRecord if there is a corresponding RowRecord.
Otherwise returns StandardHeight.
![]()
The following code illustrates how to get the row height for a particular row:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set text</para><para>worksheet["C2"].Text = "Sample text";</para><para>worksheet["C2"].Style.Font.Size = 18;</para><para>//Set auto fit</para><para>worksheet.AutoFitRow(2);</para><para>//Get row height</para><para>Console.WriteLine(worksheet.GetRowHeightPixels(2));</para><para>//Save to file</para><para>workbook.SaveToFile("UsedRange.xlsx");</para>
|
![]() |
GetText |
Returns string value corresponding to the cell.
|
![]() ![]() |
InsertArray( Object , Int32, Int32) |
Imports an array of objects into a worksheet.
![]()
The following code illustrates how to Imports a two-dimensional array of Object into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the Object Array</para><para>object[,] arrayTwoDimen = new object[3, 2] { { "AND", "OR" }, { "NAND", "XOR" },{ "NOR", "NOT" } };</para><para>//Insert the Object Array to Sheet</para><para>worksheet.InsertArray(arrayTwoDimen, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertArray( DateTime , Int32, Int32, Boolean) |
Imports an array of DateTimes into worksheet.
![]()
The following code illustrates how to Imports an array of DateTime values into a worksheet with the specified row and colum:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the DateTime Array</para><para>DateTime[] arrayDate = new DateTime[4] { DateTime.Parse("06:45"), DateTime.Parse("08:30"), DateTime.Parse("09:40"), DateTime.Parse("10:30") };</para><para>//Insert the DateTime Array to Sheet</para><para>worksheet.InsertArray(arrayDate, 1, 1, true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertArray( Double , Int32, Int32, Boolean) |
Imports an array of doubles into a worksheet.
![]()
The following code illustrates how to Imports an array of Double values into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the double Array</para><para>double[] arrayDouble = new double[4] { 344.0045, 345.0045, 346.0045, 347.0045 };</para><para>//Insert the double Array to Sheet</para><para>worksheet.InsertArray(arrayDouble, 1, 1, true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertArray( Int32 , Int32, Int32, Boolean) |
Imports an array of integers into a worksheet.
![]()
The following code illustrates how to Imports an array of integer values into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the integer Array</para><para>int[] arrayInt = new int[4] {1000, 2000, 3000, 4000};</para><para>//Insert the integer Array to Sheet</para><para>worksheet.InsertArray(arrayInt, 1, 1, true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertArray( Object , Int32, Int32, Boolean) |
Imports an array of objects into a worksheet.
![]()
The following code illustrates how to Imports an array of Object into a worksheet with specified alignment:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the Object Array</para><para>object[] array = new object[4] { "Total Income", "Actual Expense", "Expected Expenses", "Profit" };</para><para>//Insert the Object Array to Sheet</para><para>worksheet.InsertArray(array, 1, 1, true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertArray( String , Int32, Int32, Boolean) |
Imports an array of strings into a worksheet.
![]()
The following code illustrates how to Imports an array of String into a worksheet with specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Initialize the string Array</para><para>string[] arrayString = new string[4] { "Total Income", "Actual Expense", "Expected Expenses", "Profit" };</para><para>//Insert the string Array to Sheet</para><para>worksheet.InsertArray(arrayString, 1, 1, true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertArray.xlsx");</para>
|
![]() ![]() |
InsertDataColumn |
Imports data from a DataColumn into worksheet.
![]()
The following code illustrates how to Imports data from a DataColumn into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Insert the DataColumn to worksheet</para><para>System.Data.DataColumn column = table.Columns[2];</para><para>worksheet.InsertDataColumn(column, true, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataColumn.xlsx");</para> |
![]() ![]() |
InsertDataTable(DataTable, Boolean, Int32, Int32) |
Imports data from a DataTable into worksheet.
![]()
The following code illustrates how to Imports data from a DataTable into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Insert the DataTable to worksheet</para><para>worksheet.InsertDataTable(table, true, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataTable.xlsx");</para> |
![]() ![]() |
InsertDataTable(DataTable, Boolean, Int32, Int32, Boolean) |
Imports data from a DataTable into worksheet.
![]()
The following code illustrates how to Imports data from a DataTable into a worksheet with the specified row and column along with the preserve type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Insert the DataTable to worksheet</para><para>worksheet.InsertDataTable(table, true, 1, 1 , true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataTable.xlsx");</para> |
![]() ![]() |
InsertDataTable(DataTable, Boolean, Int32, Int32, Int32, Int32) |
Imports data from a DataTable into worksheet.
![]()
The following code illustrates how to Imports data from a DataTable into a worksheet with the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Insert the DataTable to worksheet</para><para>worksheet.InsertDataTable(table, true, 1 , 1 , 2 , 2);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataTable.xlsx");</para> |
![]() ![]() |
InsertDataTable(DataTable, Boolean, Int32, Int32, Int32, Int32, Boolean) |
Imports data from a DataTable into worksheet.
![]()
The following code illustrates how to Imports data from a DataTable into a worksheet with specified range along with preserve type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Insert the DataTable to worksheet</para><para>worksheet.InsertDataTable(table, true, 1 , 1 , 2 , 2 , true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataTable.xlsx");</para> |
![]() ![]() |
InsertDataView(DataView, Boolean, Int32, Int32) |
Imports data from a DataView into worksheet.
![]()
The following code illustrates how to Imports data from a DataView into a worksheet with the specified row and column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Initialize dataview of datatable</para><para>System.Data.DataView view = table.DefaultView;</para><para>//Import data from DataView</para><para>worksheet.InsertDataView(view, true, 1, 1);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataView.xlsx");</para> |
![]() ![]() |
InsertDataView(DataView, Boolean, Int32, Int32, Boolean) |
Imports data from a DataView into worksheet.
![]()
The following code illustrates how to Imports data from a DataView into a worksheet with the specified specified row and column along with preserve type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Initialize dataview of datatable</para><para>System.Data.DataView view = table.DefaultView;</para><para>//Import data from DataView</para><para>worksheet.InsertDataView(view, true, 1, 1 , true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataView.xlsx");</para> |
![]() ![]() |
InsertDataView(DataView, Boolean, Int32, Int32, Int32, Int32) |
Imports data from a DataView into worksheet.
![]()
The following code illustrates how to Imports data from a DataView into a worksheet with the specified range:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Initialize dataview of datatable</para><para>System.Data.DataView view = table.DefaultView;</para><para>//Import data from DataView</para><para>worksheet.InsertDataView(view, true, 1, 1 , 2 , 2);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataView.xlsx");</para> |
![]() ![]() |
InsertDataView(DataView, Boolean, Int32, Int32, Int32, Int32, Boolean) |
Imports data from a DataView into worksheet.
![]()
The following code illustrates how to Imports data from a DataView into a worksheet with the specified range along with preserve type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create a DataTable</para><para>System.Data.DataTable table = new System.Data.DataTable();</para><para>table.Columns.Add("ID", typeof(int)); table.Columns.Add("Item", typeof(string)); table.Columns.Add("Name", typeof(string));</para><para>table.Rows.Add(1, "Soap", "David"); table.Rows.Add(2, "Paste", "Sam"); table.Rows.Add(3, "Cream", "Christoff");</para><para>//Initialize dataview of datatable</para><para>System.Data.DataView view = table.DefaultView;</para><para>//Import data from DataView</para><para>worksheet.InsertDataView(view, true, 1, 1 , 2 , 2 , true);</para><para>//Save to file</para><para>workbook.SaveToFile(InsertDataView.xlsx");</para> |
![]() |
IsColumnVisible |
Method check is Column with specifed index visible to end user or not.
|
![]() |
IsRowVisible |
Method check is Row with specifed index visible to user or not.
|
![]() |
MoveWorksheet |
Moves worksheet.
|
![]() |
PixelsToColumnWidth |
Converts pixels into column width (in characters).
|
![]() ![]() |
Protect(String) |
Protects worksheet's content with password.
![]()
The following code illustrates how to protect the sheet except select lock/unlock cells:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Protects the first worksheet's content with password</para><para>worksheet.Protect("123456");</para><para>//Save to file</para><para>workbook.SaveToFile("Protect.xlsx");</para>
|
![]() |
Protect(String, SheetProtectionType) |
Protects current worksheet.
(Inherited from
ITabSheet
.)
|
![]() |
Remove |
Removes worksheet from parent worksheets collection.
|
![]() |
RemovePanes |
Removes panes from a worksheet.
|
![]() ![]() |
Replace(String, DateTime) |
Replaces specified string by specified value.
![]()
The following code illustrates how to replace the string value with datetime:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Replace the oldValue by dateTime</para><para>string oldValue = "Find";</para><para>DateTime dateTime = DateTime.Now;</para><para>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Replace the oldValue by double</para><para>string oldValue = "Ten";</para><para>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Replace the oldValue by newValue</para><para>string oldValue = "Find";</para><para>string newValue = "NewValue";</para><para>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</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>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</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>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</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>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Replace the oldValue by array of int values</para><para>string oldValue = "Find";</para><para>int[] newValues = { 1, 2 };</para><para>worksheet.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 worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</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>worksheet.Replace(oldValue, newValues , true);</para><para>//Save to file</para><para>workbook.SaveToFile("Replace.xlsx");</para>
|
![]() ![]() |
SaveToFile |
Save tabsheet using separator.
|
![]() ![]() |
SaveToHtml(Stream) |
Save to HTML stream.
![]()
The following code snippets illustrates how to save as html as stream:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Creat stream</para><para>Stream stream = new MemoryStream();</para><para>//Save to HTML stream</para><para>worksheet.SaveToHtml(stream);</para>
|
![]() ![]() |
SaveToHtml(String) |
Saves worksheet with specified filename.
![]()
The following code snippets illustrates how to save as html to the specified file name:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Save to HTML file</para><para>worksheet.SaveToHtml("Output.html");</para>
|
![]() ![]() |
SaveToHtml(Stream, HTMLOptions) |
Saves work sheet to HTML.
![]()
The following code snippets illustrates how to save as html as stream with Save option:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Creat stream</para><para>Stream stream = new MemoryStream();</para><para>//Save to HTML stream</para><para>worksheet.SaveToHtml(stream, Spire.Xls.Core.Spreadsheet.HTMLOptions.Default);</para>
|
![]() ![]() |
SaveToHtml(String, HTMLOptions) |
Saves as HTML.
![]()
The following code snippets illustrates how to save as html to the specified file name and save option:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Save to HTML file</para><para>worksheet.SaveToHtml("Sample.html" , Spire.Xls.Core.Spreadsheet.HTMLOptions.Default);</para>
|
![]() |
SaveToImage(Int32, Int32, Int32, Int32) |
Converts range into image (Bitmap).
|
![]() ![]() |
SaveToImage(Stream, Int32, Int32, Int32, Int32, ImageType) |
Converts range into image.
![]()
The following code illustrates how to convert the specified range into image with the specified type:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Creat stream</para><para>Stream stream = new MemoryStream();</para><para>//Save to image</para><para>System.Drawing.Image image = worksheet.SaveToImage(stream,1, 1, 10, 20, Spire.Xls.ImageType.Bitmap);</para><para>image.Save("Sample.png", System.Drawing.Imaging.ImageFormat.Png);</para>
|
![]() |
SaveToImage(Stream, Int32, Int32, Int32, Int32, EmfType) |
Converts range into metafile image.
|
![]() |
SaveToImage(Stream, Int32, Int32, Int32, Int32, ImageType, EmfType) |
Converts range into image.
|
![]() ![]() |
SaveToStream |
Save tabsheet using separator.
![]()
The following code illustrates how to saves the worksheet as stream with separator:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>workbook.LoadFromFile("Sample.xlsx");</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create stream</para><para>Stream stream = new MemoryStream();</para><para>//Save to stream</para><para>worksheet.SaveToStream(stream , ",");</para>
|
![]() |
Select |
Selects current tab sheet.
(Inherited from
ITabSheet
.)
|
![]() |
SetBlank |
Sets blank in specified cell.
|
![]() |
SetBoolean |
Sets value in the specified cell.
|
![]() ![]() |
SetColumnWidthInPixels |
Sets column width in pixels.
![]()
The following code illustrates how to set width for a column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set column width</para><para>worksheet.SetColumnWidthInPixels(2, 160);</para><para>//Save to file</para><para>workbook.SaveToFile("SetColumnWidthInPixels.xlsx");</para>
|
![]() ![]() |
SetDefaultColumnStyle(Int32, IStyle) |
Sets by column index default style for column.
![]()
The following code illustrates how to set the default style for a column:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultColumnStyle(2, style);</para><para>//Save to file</para><para>workbook.SaveToFile("SetDefaultColumnStyle.xlsx");</para>
|
![]() ![]() |
SetDefaultColumnStyle(Int32, Int32, IStyle) |
Sets by column index default style for column.
![]()
The following code illustrates how to set the default style for columns:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultColumnStyle(2, 5, style);</para><para>//Save to file</para><para>workbook.SaveToFile("SetDefaultColumnStyle.xlsx");</para>
|
![]() ![]() |
SetDefaultRowStyle(Int32, IStyle) |
Sets by column index default style for row.
![]()
The following code illustrates how to set the default style for a row:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultRowStyle(2, style);</para><para>//Save to file</para><para>workbook.SaveToFile("SetDefaultRowStyle.xlsx");</para>
|
![]() ![]() |
SetDefaultRowStyle(Int32, Int32, IStyle) |
Sets by column index default style for row.
![]()
The following code illustrates how to set the default style for rows:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Create style</para><para>CellStyle style = workbook.Styles.Add("CustomStyle");</para><para>//Set Color</para><para>style.Color = Color.Red;</para><para>//Set default style</para><para>worksheet.SetDefaultRowStyle(2, 5, style);</para><para>//Save to file</para><para>workbook.SaveToFile("SetDefaultRowStyle.xlsx");</para>
|
![]() |
SetError |
Sets error in the specified cell.
|
![]() |
SetFormula |
Sets formula in the specified cell.
|
![]() |
SetFormulaBoolValue |
Sets formula bool value.
|
![]() |
SetFormulaErrorValue |
Sets formula error value.
|
![]() |
SetFormulaNumberValue |
Sets formula number value.
|
![]() |
SetFormulaStringValue |
Sets formula string value.
|
![]() |
SetNumber |
Sets value in the specified cell.
|
![]() ![]() |
SetRowHeightPixels |
Sets row height in pixels.
![]()
The following code illustrates how to set height for a row:
<para>//Create worksheet</para><para>Workbook workbook = new Workbook();</para><para>Worksheet worksheet = workbook.Worksheets[0];</para><para>//Set row height</para><para>worksheet.SetRowHeightPixels(3, 150);</para><para>//Save to file</para><para>workbook.SaveToFile("SetRowHeightPixels.xlsx");</para>
|
![]() |
SetText |
Sets text in the specified cell.
|
![]() |
SetValue |
Sets value in the specified cell.
|
![]() |
Unprotect |
Unprotects worksheet's content with password.
|
![]() |
Unselect |
Unselects current tab sheet.
(Inherited from
ITabSheet
.)
|