Class XlsWorksheet
- Namespace
- Spire.Xls.Core.Spreadsheet
- Assembly
- Spire.XLS.dll
public class XlsWorksheet : XlsWorksheetBase, IDisposable, INamedObject, ICloneParent, IInternalWorksheet, IWorksheet, ITabSheet, IExcelApplication
- Inheritance
-
XlsWorksheet
- Implements
- Derived
- Inherited Members
Properties
ActivePane
Gets or sets index of the active pane.
public int ActivePane { get; set; }
Property Value
AllocatedRange
Returns a Range object that represents a cell or a range of cells.
public IXLSRange AllocatedRange { get; }
Property Value
AllocatedRangeIncludesFormatting
public bool AllocatedRangeIncludesFormatting { get; set; }
Property Value
AutoFilters
Returns collection of worksheet's autofilters. Read-only.
public IAutoFilters AutoFilters { get; }
Property Value
CellList
public List<CellRange> CellList { get; }
Property Value
Cells
Returns all used cells in the worksheet. Read-only.
[Obsolete("Please use CellList")]
public IXLSRange[] Cells { get; }
Property Value
Columns
For a Worksheet object, returns an array of Range objects that represents all the columns on the specified worksheet. Read-only Range object.
public IXLSRange[] Columns { get; }
Property Value
ConditionalFormats
Returns collection with all conditional formats in the worksheet. Read-only.
public IConditionalFormatsCollection ConditionalFormats { get; }
Property Value
Copying
public bool Copying { get; set; }
Property Value
DVTable
public IDataValidationTable DVTable { get; }
Property Value
DefaultColumnWidth
Returns or sets the default width of all the columns in the worksheet. Read/write Double.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get column width
Console.Write(worksheet.DefaultColumnWidth);
//Set default width
worksheet.DefaultColumnWidth = 40;
//Save to file
workbook.SaveToFile("DefaultColumnWidth.xlsx");
public double DefaultColumnWidth { get; set; }
Property Value
DefaultPrintRowHeight
Return default row height.
public int DefaultPrintRowHeight { get; set; }
Property Value
DefaultRowHeight
Gets or sets default height of all the rows in the worksheet,
in points.Read/write Double.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get row height
Console.Write(worksheet.DefaultRowHeight);
//Set default height
worksheet.DefaultRowHeight = 40;
//Save to file
workbook.SaveToFile("DefaultRowHeight.xlsx");
public double DefaultRowHeight { get; set; }
Property Value
DisplayPageBreaks
True if page breaks (both automatic and manual) on the specified worksheet are displayed.
public bool DisplayPageBreaks { get; set; }
Property Value
FirstVisibleColumn
Index to first visible column in right pane(s).
public int FirstVisibleColumn { get; set; }
Property Value
FirstVisibleRow
Index to first visible row in bottom pane(s).
public int FirstVisibleRow { get; set; }
Property Value
FormulasVisible
public bool FormulasVisible { get; set; }
Property Value
GridLinesVisible
True if gridlines are visible;
False otherwise.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set grid line visibility
worksheet.GridLinesVisible = false;
//Save to file
workbook.SaveToFile("GridLinesVisible.xlsx");
public bool GridLinesVisible { get; set; }
Property Value
HPageBreaks
Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet. Read-only.
public IHPageBreaks HPageBreaks { get; }
Property Value
HasMergedCells
Indicates whether worksheet has merged cells.
public bool HasMergedCells { get; }
Property Value
HasOleObjects
Indicats whether there is OLE object.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Check HasOleObject.Output will be true.
Console.Write(worksheet.HasOleObjects);
//Save to file
workbook.SaveToFile("HasOleObjects.xlsx");
public bool HasOleObjects { get; }
Property Value
- bool
true
if this instance is OLE object; otherwise,false
.
HorizontalSplit
public int HorizontalSplit { get; set; }
Property Value
HyperLinks
Collection of all worksheet's hyperlinks.
public IHyperLinks HyperLinks { get; }
Property Value
InnerHyperLinks
protected XlsHyperLinksCollection InnerHyperLinks { get; }
Property Value
IsDisplayZeros
Indicates whether zero values to be displayed
public bool IsDisplayZeros { get; set; }
Property Value
IsEmpty
Indicates whether worksheet is empty. Read-only.
public bool IsEmpty { get; }
Property Value
IsFreezePanes
Indicates whether freezed panes are applied.
public bool IsFreezePanes { get; }
Property Value
IsStringsPreserved
Indicates if all values in the workbook are preserved as strings.
public bool IsStringsPreserved { get; set; }
Property Value
this[int, int]
Gets / sets cell by row and index.
public IXLSRange this[int row, int column] { get; }
Parameters
Property Value
this[int, int, int, int]
Get cells range.
public IXLSRange this[int row, int column, int lastRow, int lastColumn] { get; }
Parameters
Property Value
this[string]
Get cell range.
public IXLSRange this[string name] { get; }
Parameters
name
string
Property Value
ListObjects
Returns all list objects in the worksheet.
public IListObjects ListObjects { get; }
Property Value
MaxDisplayRange
public IXLSRange MaxDisplayRange { get; }
Property Value
MergedCells
Returns all merged ranges. Read-only.
//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Merge cellsworksheet["C2:D2"].Merge();worksheet["F3:G3"].Merge();//Get merged rangesIXLSRange[] mergedRanges = worksheet.MergedCells;//Get merged range count . Output will be 2Console.Write(mergedRanges.Length);//Save to fileworkbook.SaveToFile("MergedCells.xlsx");
public IXLSRange[] MergedCells { get; }
Property Value
Names
Name range used by macros to access to workbook items.
public INameRanges Names { get; }
Property Value
OleObjects
Gets the OLE objects.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create image stream
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add ole object
IOleObject oleObject = worksheet.OleObjects.Add("Shapes.xlsx", image, OleLinkType.Embed);
//Save to file
workbook.SaveToFile("OLEObjects.xlsx");
public IOleObjects OleObjects { get; }
Property Value
- IOleObjects
The OLE objects.
PageSetup
Returns a PageSetup object that contains all the page setup settings for the specified object. Read-only.
public IPageSetup PageSetup { get; }
Property Value
PivotTables
Returns charts collection. Read-only.
public PivotTablesCollection PivotTables { get; }
Property Value
ProtectContents
Indicates whether current sheet is protected.
public override bool ProtectContents { get; }
Property Value
QuotedName
Returns quoted name of the worksheet.
public string QuotedName { get; }
Property Value
Range
Returns a Range object that represents the used range on the
specified worksheet. Read-only.
//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Set textworksheet["B2"].Text = "Text";//Set Colorworksheet["J3"].Style.Color = Color.Red;//Get used range . Output will be B2:J3Console.Write(worksheet.Range.RangeAddressLocal);//Save to fileworkbook.SaveToFile("UsedRange.xlsx");
public XlsRange Range { get; }
Property Value
RowColumnHeadersVisible
True if row and column headers are visible. False otherwise.
public bool RowColumnHeadersVisible { get; set; }
Property Value
Rows
For a Worksheet object, returns an array of Range objects that represents all the rows on the specified worksheet. Read-only Range object.
public IXLSRange[] Rows { get; }
Property Value
SelectionCount
public int SelectionCount { get; }
Property Value
SparklineGroups
public SparklineGroupCollection SparklineGroups { get; }
Property Value
StandardHeightFlag
Gets or sets the standard (default) height option flag, which defines that standard (default) row height and book default font height do not match. Bool.
public bool StandardHeightFlag { get; set; }
Property Value
TopLeftCell
Gets top left cell of the worksheet.
public CellRange TopLeftCell { get; set; }
Property Value
Type
Returns or sets the worksheet type. Read-only ExcelSheetType.
public ExcelSheetType Type { get; }
Property Value
UseRangesCache
Indicates whether all created range objects should be cached. Default value is true.
public bool UseRangesCache { get; set; }
Property Value
VPageBreaks
Returns a VPageBreaks collection that represents the vertical page breaks on the sheet. Read-only.
public IVPageBreaks VPageBreaks { get; }
Property Value
Version
Gets or sets excel file version.
public ExcelVersion Version { get; set; }
Property Value
VerticalSplit
public int VerticalSplit { get; set; }
Property Value
ViewMode
Gets or sets the view mode of the sheet.
public ViewMode ViewMode { get; set; }
Property Value
Zoom
Zoom factor of document.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set zoom
worksheet.Zoom = 200;
//Save to file
workbook.SaveToFile("Zoom.xlsx");
public int Zoom { get; set; }
Property Value
Remarks
Value of zoom should be between 10 and 400.
ZoomScaleNormal
Gets or sets the zoom scale of normal view of the sheet.
public int ZoomScaleNormal { get; set; }
Property Value
ZoomScalePageBreakView
Gets or sets the zoom scale of page break preview of the sheet.
public int ZoomScalePageBreakView { get; set; }
Property Value
ZoomScalePageLayoutView
Gets or sets the zoom scale of page layout view of the sheet.
public int ZoomScalePageLayoutView { get; set; }
Property Value
Methods
AccessColumn(int)
protected void AccessColumn(int iColumnIndex)
Parameters
iColumnIndex
int
AccessRow(int)
protected void AccessRow(int iRowIndex)
Parameters
iRowIndex
int
AddAllowEditRange(string, CellRange)
AddAllowEditRange : add a range of cells that allow editing
public bool AddAllowEditRange(string title, CellRange range)
Parameters
Returns
AddAllowEditRange(string, CellRange, string)
AddAllowEditRange : add a range of cells that allow editing
public bool AddAllowEditRange(string title, CellRange range, string password)
Parameters
Returns
ApplyStyle(CellStyle)
public void ApplyStyle(CellStyle style)
Parameters
style
CellStyle
ApplyStyle(CellStyle, bool, bool)
Apply style to whole sheet.
public void ApplyStyle(CellStyle style, bool applyRowStyle, bool applyColumnStyle)
Parameters
style
CellStylestyle to apply
applyRowStyle
booltrue means apply style to all rows
applyColumnStyle
booltrue means apply style to all columns
AutoFitColumn(int)
Autofit the column width.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["A1"].Text = "Sample text in cell";
//Set auto fit
worksheet.AutoFitColumn(1);
//Save to file
workbook.SaveToFile("AutoFitColumn.xlsx");
public void AutoFitColumn(int columnIndex)
Parameters
columnIndex
intColumn index.
AutoFitColumn(int, AutoFitterOptions)
Autofit the column width.
public void AutoFitColumn(int columnIndex, AutoFitterOptions options)
Parameters
columnIndex
intColumn index.
options
AutoFitterOptionsauto fit options
AutoFitColumn(int, int, int)
Autofit the column width.
public void AutoFitColumn(int columnIndex, int firstRow, int lastRow)
Parameters
columnIndex
intColumn index.
firstRow
intOne-based index of the first row to be used for autofit operation.
lastRow
intOne-based index of the last row to be used for autofit operation.
AutoFitColumn(int, int, int, AutoFitterOptions)
Autofit the column width.
public void AutoFitColumn(int columnIndex, int firstRow, int lastRow, AutoFitterOptions options)
Parameters
columnIndex
intColumn index.
firstRow
intOne-based index of the first row to be used for autofit operation.
lastRow
intOne-based index of the last row to be used for autofit operation.
options
AutoFitterOptionsauto fit options
AutoFitRow(int)
Autofit the row height.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["C2"].Value = "Sample text";
//Set Style
CellStyle style = workbook.Styles.Add("CustomStyle");
IFont font = style.Font;
font.Size = 18;
worksheet["C2"].Style = style;
//Set auto fit
worksheet.AutoFitRow(2);
//Save to file
workbook.SaveToFile("AutoFitRow.xlsx");
public void AutoFitRow(int rowIndex)
Parameters
rowIndex
intRow index
AutoFitRow(int, int, int, AutoFitterOptions)
Autofit the row height.
public void AutoFitRow(int rowIndex, int firstColumn, int lastColumn, AutoFitterOptions options)
Parameters
rowIndex
intRow index
firstColumn
intOne-based index of the first column to be used for autofit operation.
lastColumn
intOne-based index of the last column to be used for autofit operation.
options
AutoFitterOptionsauto fit options
AutoFitRow(int, int, int, bool)
Autofit the row height.
public void AutoFitRow(int rowIndex, int firstColumn, int lastColumn, bool bRaiseEvents)
Parameters
rowIndex
intRow index
firstColumn
intOne-based index of the first column to be used for autofit operation.
lastColumn
intOne-based index of the last column to be used for autofit operation.
bRaiseEvents
boolIf true then raise events.
AutoFitRow(int, int, int, bool, AutoFitterOptions)
Autofit the row height.
public void AutoFitRow(int rowIndex, int firstColumn, int lastColumn, bool bRaiseEvents, AutoFitterOptions options)
Parameters
rowIndex
intRow index
firstColumn
intOne-based index of the first column to be used for autofit operation.
lastColumn
intOne-based index of the last column to be used for autofit operation.
bRaiseEvents
boolIf true then raise events.
options
AutoFitterOptionsauto fit options
CalculateAllValue()
Caculate all formula for the specified worksheet
public void CalculateAllValue()
CheckExistence(int, int)
Indicates whether cell has been initialized.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet.Range["A1"].Text = "Hello";
//Check the cell.Output will be true.
Console.Write(worksheet.CheckExistence(1, 1));
//Save to file
workbook.SaveToFile("CheckExistence.xlsx");
public bool CheckExistence(int row, int column)
Parameters
Returns
- bool
Value indicating whether the cell was initialized or accessed by the user.
Clear()
Clears data the worksheet.
public void Clear()
ClearData()
Clears contents of a range.
public void ClearData()
ColumnWidthToPixels(double)
public int ColumnWidthToPixels(double widthInChars)
Parameters
widthInChars
double
Returns
CopyFrom(XlsWorksheet, Dictionary<string, string>, Dictionary<string, string>, Dictionary<int, int>, WorksheetCopyType, Dictionary<int, int>, Dictionary<int, int>, Dictionary<int, int>)
[Obsolete("the method is not implemented")]
public void CopyFrom(XlsWorksheet worksheet, Dictionary<string, string> hashStyleNames, Dictionary<string, string> hashWorksheetNames, Dictionary<int, int> dicFontIndexes, WorksheetCopyType flags, Dictionary<int, int> hashExtFormatIndexes, Dictionary<int, int> hashNameIndexes, Dictionary<int, int> hashExternSheets)
Parameters
worksheet
XlsWorksheethashStyleNames
Dictionary<string, string>hashWorksheetNames
Dictionary<string, string>dicFontIndexes
Dictionary<int, int>flags
WorksheetCopyTypehashExtFormatIndexes
Dictionary<int, int>hashNameIndexes
Dictionary<int, int>hashExternSheets
Dictionary<int, int>
CopyToClipboard()
[Obsolete("the method is not implemented")]
public void CopyToClipboard()
CreateNamedRanges(string, string, bool)
public void CreateNamedRanges(string namedRange, string referRange, bool vertical)
Parameters
CreateRanges(CellRange[])
public XlsRangesCollection CreateRanges(CellRange[] ranges)
Parameters
ranges
CellRange[]
Returns
DeleteColumn(int)
Deletes a column.
public void DeleteColumn(int index)
Parameters
index
int
DeleteColumn(int, int)
Removes specified column.
public void DeleteColumn(int index, int count)
Parameters
DeleteRange(CellRange, DeleteOption)
delete a range in worksheet
public void DeleteRange(CellRange range, DeleteOption deleteOption)
Parameters
range
CellRangethe range to be deleted
deleteOption
DeleteOptionChoose to move the right range to left or move the below range to above
DeleteRow(int)
Delete a row.
public void DeleteRow(int index)
Parameters
index
intRow index to remove
DeleteRow(int, int)
Removes specified row.
public void DeleteRow(int index, int count)
Parameters
DeleteRows(int[])
Removes specified rows.
public void DeleteRows(int[] rows)
Parameters
rows
int[]Index of all row that need to remove
ExportDataTable()
public DataTable ExportDataTable()
Returns
FreeRange(CellRange)
protected void FreeRange(CellRange range)
Parameters
range
CellRange
GetBoolean(int, int)
Gets bool value from cell.
public bool GetBoolean(int row, int column)
Parameters
Returns
- bool
Returns found bool value. If cannot found returns false.
GetCaculateValue(int, int)
[Obsolete("the method is obsolete, please use GetCalculateValue.")]
public object GetCaculateValue(int row, int col)
Parameters
Returns
GetCalculateValue(int, int)
Returns the formula string if the cell contains a formula, or the value if the cell cantains anything other than a formula.
public object GetCalculateValue(int row, int col)
Parameters
Returns
- object
The formula string or value.
GetCellType(int, int, bool)
Gets cell type from current column.
public XlsWorksheet.TRangeValueType GetCellType(int row, int column, bool bNeedFormulaSubType)
Parameters
row
intIndicates row.
column
intIndicates column.
bNeedFormulaSubType
boolIndicates is need to indified formula sub type.
Returns
- XlsWorksheet.TRangeValueType
Returns cell type.
GetClonedObject(Dictionary<string, string>, XlsWorkbook)
public IInternalWorksheet GetClonedObject(Dictionary<string, string> hashNewNames, XlsWorkbook book)
Parameters
hashNewNames
Dictionary<string, string>book
XlsWorkbook
Returns
GetColumnIsAutoFit(int)
Get ColumnIsAutofit By columnIndex
public bool GetColumnIsAutoFit(int columnIndex)
Parameters
columnIndex
int
Returns
- bool
If the column is null Return false,else if the column width is Autofit Return true, the column width is CustomWidth Return false
GetColumnIsHide(int)
Indicates whether the column is hidden.
public bool GetColumnIsHide(int columnIndex)
Parameters
columnIndex
intColumn index.
Returns
GetColumnWidth(int)
Gets the width of the specified column
public double GetColumnWidth(int columnIndex)
Parameters
columnIndex
intColumn index
Returns
- double
Width of column
GetColumnWidthPixels(int)
Gets the width of the specified column, in units of pixel.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["A1"].Text = "Sample text in cell";
//Set auto fit
worksheet.AutoFitColumn(1);
//Get column width
Console.WriteLine(worksheet.GetColumnWidthPixels(1));
//Save to file
workbook.SaveToFile("UsedRange.xlsx");
public int GetColumnWidthPixels(int columnIndex)
Parameters
columnIndex
intColumn index.
Returns
- int
Width of column
GetDefaultColumnStyle(int)
public IStyle GetDefaultColumnStyle(int columnIndex)
Parameters
columnIndex
int
Returns
GetDefaultRowStyle(int)
public IStyle GetDefaultRowStyle(int rowIndex)
Parameters
rowIndex
int
Returns
GetError(int, int)
Gets error value from cell.
public string GetError(int row, int column)
Parameters
Returns
- string
Returns error value or null.
GetFormula(int, int, bool)
public string GetFormula(int row, int column, bool bR1C1)
Parameters
Returns
GetFormula(int, int, bool, bool)
public string GetFormula(int row, int column, bool bR1C1, bool isForSerialization)
Parameters
Returns
GetFormulaBoolValue(int, int)
Gets formula bool value from cell.
public bool GetFormulaBoolValue(int row, int column)
Parameters
Returns
- bool
Returns found bool value. If cannot found returns false.
GetFormulaErrorValue(int, int)
Gets formula error value from cell.
public string GetFormulaErrorValue(int row, int column)
Parameters
Returns
- string
Returns error value or null.
GetFormulaNumberValue(int, int)
Returns formula number value corresponding to the cell.
public double GetFormulaNumberValue(int row, int column)
Parameters
row
intOne-based row index of the cell to get value from.
column
intOne-based column index of the cell to get value from.
Returns
- double
Number contained by the cell.
GetFormulaStringValue(int, int)
Returns formula string value corresponding to the cell.
public string GetFormulaStringValue(int row, int column)
Parameters
row
intOne-based row index of the cell to get value from.
column
intOne-based column index of the cell to get value from.
Returns
- string
String contained by the cell.
GetNumber(int, int)
Returns number value corresponding to the cell.
public double GetNumber(int row, int column)
Parameters
row
intOne-based row index of the cell to get value from.
column
intOne-based column index of the cell to get value from.
Returns
- double
Number contained by the cell.
GetRowHeight(int)
Gets the height of a specified row.
public double GetRowHeight(int row)
Parameters
row
intRow index.
Returns
- double
Height of row
GetRowHeightPixels(int)
Gets the height of a specified row in unit of pixel.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["C2"].Text = "Sample text";
worksheet["C2"].Style.Font.Size = 18;
//Set auto fit
worksheet.AutoFitRow(2);
//Get row height
Console.WriteLine(worksheet.GetRowHeightPixels(2));
//Save to file
workbook.SaveToFile("UsedRange.xlsx");
public int GetRowHeightPixels(int rowIndex)
Parameters
rowIndex
intRow index.
Returns
- int
Height of row
GetRowIsAutoFit(int)
Get GetRowIsAutoFit By rowIndex
public bool GetRowIsAutoFit(int rowIndex)
Parameters
rowIndex
int
Returns
- bool
If the row is null Return false,else if the row height is Autofit Return true, the row height is CustomHeight Return false
GetRowIsHide(int)
Indicates whether the row is hidden.
public bool GetRowIsHide(int rowIndex)
Parameters
rowIndex
intRow index.
Returns
GetStringValue(int, int)
Returns string value corresponding to the cell.
public string GetStringValue(int row, int column)
Parameters
Returns
- string
String contained by the cell.
GetStringValue(long)
Returns string value corresponding to the cell.
[Obsolete("This is an obsolete method.")]
public string GetStringValue(long cellIndex)
Parameters
cellIndex
long
Returns
- string
String contained by the cell.
GetText(int, int)
Returns string value corresponding to the cell.
public string GetText(int row, int column)
Parameters
row
intOne-based row index of the cell to get value from.
column
intOne-based column index of the cell to get value from.
Returns
- string
String contained by the cell.
GetTextObject(int, int)
Returns TextWithFormat object corresponding to the specified cell.
public object GetTextObject(int row, int column)
Parameters
Returns
- object
Object corresponding to the specified cell.
GetTextObject(long)
Returns TextWithFormat object corresponding to the specified cell.
[Obsolete("This is an obsolete method.")]
public object GetTextObject(long cellIndex)
Parameters
cellIndex
longCell index.
Returns
- object
Object corresponding to the specified cell.
GroupByColumns(int, int, bool)
Groups columns.
public CellRange GroupByColumns(int firstColumn, int lastColumn, bool isCollapsed)
Parameters
firstColumn
intThe first column index to be grouped.
lastColumn
intThe last column index to be grouped.
isCollapsed
boolIndicates whether group should be collapsed.
Returns
GroupByRows(int, int, bool)
Groups rows.
public CellRange GroupByRows(int firstRow, int lastRow, bool isCollapsed)
Parameters
firstRow
intThe first row index to be grouped.
lastRow
intThe last row index to be grouped.
isCollapsed
boolIndicates whether group should be collapsed.
Returns
HasArrayFormula(long)
Indicates whether cell contains array-entered formula.
[Obsolete("This is an obsolete method.")]
public bool HasArrayFormula(long cellIndex)
Parameters
cellIndex
longcell index.
Returns
HasArrayFormulaRecord(int, int)
Indicates is has array formula.
public bool HasArrayFormulaRecord(int row, int column)
Parameters
Returns
- bool
Indicates is contain array formula record.
HideColumn(int)
Hides a column.
public void HideColumn(int columnIndex)
Parameters
columnIndex
intColumn index.
HideColumns(int, int)
Hides columns.
public void HideColumns(int columnIndex, int columnCount)
Parameters
HideRow(int)
Hides a row.
public void HideRow(int rowIndex)
Parameters
rowIndex
intRow index.
HideRows(int, int)
Hides a row.
public void HideRows(int rowIndex, int rowCount)
Parameters
ImportCustomObjects(ICollection, int, int, ImportObjectOptions)
public int ImportCustomObjects(ICollection list, int firstRow, int firstColumn, ImportObjectOptions options)
Parameters
list
ICollectionfirstRow
intfirstColumn
intoptions
ImportObjectOptions
Returns
ImportCustomObjects(ICollection, string[], bool, int, int, int, bool, string, bool)
public int ImportCustomObjects(ICollection list, string[] propertyNames, bool isPropertyNameShown, int firstRow, int firstColumn, int rowNumber, bool insertRows, string dateFormatString, bool convertStringToNumber)
Parameters
list
ICollectionpropertyNames
string[]isPropertyNameShown
boolfirstRow
intfirstColumn
introwNumber
intinsertRows
booldateFormatString
stringconvertStringToNumber
bool
Returns
InitializeCollections()
protected override void InitializeCollections()
InsertArray(DateTime[], int, int, bool)
Imports an array of datetimes into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the DateTime Array
DateTime[] arrayDate = new DateTime[4] { DateTime.Parse("06:45"), DateTime.Parse("08:30"), DateTime.Parse("09:40"), DateTime.Parse("10:30") };
//Insert the DateTime Array to Sheet
worksheet.InsertArray(arrayDate, 1, 1, true);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(DateTime[] dateTimeArray, int firstRow, int firstColumn, bool isVertical)
Parameters
dateTimeArray
DateTime[]Datetime array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
Returns
InsertArray(double[], int, int, bool)
Imports an array of doubles into a worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the double Array
double[] arrayDouble = new double[4] { 344.0045, 345.0045, 346.0045, 347.0045 };
//Insert the double Array to Sheet
worksheet.InsertArray(arrayDouble, 1, 1, true);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(double[] doubleArray, int firstRow, int firstColumn, bool isVertical)
Parameters
doubleArray
double[]Double array
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
Returns
InsertArray(int[], int, int, bool)
Imports an array of integer into a worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the integer Array
int[] arrayInt = new int[4] {1000, 2000, 3000, 4000};
//Insert the integer Array to Sheet
worksheet.InsertArray(arrayInt, 1, 1, true);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(int[] intArray, int firstRow, int firstColumn, bool isVertical)
Parameters
intArray
int[]Integer array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
Returns
InsertArray(object[,], int, int)
Imports an array of objects into a worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the Object Array
object[,] arrayTwoDimen = new object[3, 2] { { "AND", "OR" }, { "NAND", "XOR" },{ "NOR", "NOT" } };
//Insert the Object Array to Sheet
worksheet.InsertArray(arrayTwoDimen, 1, 1);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(object[,] objectArray, int firstRow, int firstColumn)
Parameters
objectArray
object[,]Object array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
Returns
InsertArray(object[,], int, int, bool)
Imports an array of objects into a worksheet.
public int InsertArray(object[,] objectArray, int firstRow, int firstColumn, bool needConvert)
Parameters
objectArray
object[,]Object array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
needConvert
boolWhether others type inputted as string type need to be converted, such as number, datetime.
Returns
InsertArray(object[], int, int, bool)
Imports an array of objects into a worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the Object Array
object[] array = new object[4] { "Total Income", "Actual Expense", "Expected Expenses", "Profit" };
//Insert the Object Array to Sheet
worksheet.InsertArray(array, 1, 1, true);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(object[] arrObject, int firstRow, int firstColumn, bool isVertical)
Parameters
arrObject
object[]Array to import.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolTRUE if array should be imported vertically; FALSE - horizontally.
Returns
- int
Number of imported elements.
InsertArray(string[], int, int, bool)
Imports an array of strings into a worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Initialize the string Array
string[] arrayString = new string[4] { "Total Income", "Actual Expense", "Expected Expenses", "Profit" };
//Insert the string Array to Sheet
worksheet.InsertArray(arrayString, 1, 1, true);
//Save to file
workbook.SaveToFile(InsertArray.xlsx");
public int InsertArray(string[] stringArray, int firstRow, int firstColumn, bool isVertical)
Parameters
stringArray
string[]String array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
Returns
InsertArrayList(ArrayList, int, int, bool)
Imports an arraylist of data into a worksheet.
public int InsertArrayList(ArrayList arrayList, int firstRow, int firstColumn, bool isVertical)
Parameters
arrayList
ArrayListData arraylist.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
Returns
InsertArrayList(ArrayList, int, int, bool, bool)
Imports an arraylist of data into a worksheet.
public int InsertArrayList(ArrayList arrayList, int firstRow, int firstColumn, bool isVertical, bool isText)
Parameters
arrayList
ArrayListData arraylist.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
isText
boolSpecifies to import data as text or not.
Returns
InsertArray<T>(T[], int, int, bool, bool)
Imports an array of objects into a worksheet.
public int InsertArray<T>(T[] objects, int firstRow, int firstColumn, bool isVertical, bool isText)
Parameters
objects
T[]Object array.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
isVertical
boolSpecifies to import data vertically or horizontally.
isText
bool
Returns
Type Parameters
T
InsertColumn(int)
Inserts a new column into the worksheet.
public void InsertColumn(int columnIndex)
Parameters
columnIndex
intColumn index
InsertColumn(int, int)
Inserts specified number column into the worksheet.
public void InsertColumn(int columnIndex, int columnCount)
Parameters
InsertColumn(int, int, InsertOptionsType)
public void InsertColumn(int columnIndex, int columnCount, InsertOptionsType insertOptions)
Parameters
columnIndex
intcolumnCount
intinsertOptions
InsertOptionsType
InsertCutRange(IXLSRange, int, int, InsertMoveOption)
Insert cut range into worksheet at specified position.
public void InsertCutRange(IXLSRange cutRange, int rowIndex, int colIndex, InsertMoveOption moveOptions)
Parameters
cutRange
IXLSRangethe cut range
rowIndex
intthe dest range first row index
colIndex
intthe dest range first column index
moveOptions
InsertMoveOptioninsert options.
InsertDataColumn(DataColumn, bool, int, int)
Imports data column.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Insert the DataColumn to worksheet
System.Data.DataColumn column = table.Columns[2];
worksheet.InsertDataColumn(column, true, 1, 1);
//Save to file
workbook.SaveToFile(InsertDataColumn.xlsx");
public int InsertDataColumn(DataColumn dataColumn, bool columnHeaders, int firstRow, int firstColumn)
Parameters
dataColumn
DataColumnData column to import.
columnHeaders
boolIndicates whether to import field names.
firstRow
intIndex of the first row.
firstColumn
intIndex of the first column
Returns
InsertDataColumns(DataColumn[], bool, int, int)
Imports array of data columns.
public int InsertDataColumns(DataColumn[] dataColumns, bool columnHeaders, int firstRow, int firstColumn)
Parameters
dataColumns
DataColumn[]Data columns to import.
columnHeaders
boolIndicates whether to import field names.
firstRow
intIndex to the first row.
firstColumn
intIndex to the first column.
Returns
InsertDataTable(DataTable, bool, int, int)
Imports data from a DataTable into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Insert the DataTable to worksheet
worksheet.InsertDataTable(table, true, 1, 1);
//Save to file
workbook.SaveToFile(InsertDataTable.xlsx");
public int InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn)
Parameters
dataTable
DataTableDataTable
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
Returns
InsertDataTable(DataTable, bool, int, int, bool)
Imports data from a DataTable into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Insert the DataTable to worksheet
worksheet.InsertDataTable(table, true, 1, 1 , true);
//Save to file
workbook.SaveToFile(InsertDataTable.xlsx");
public int InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn, bool transTypes)
Parameters
dataTable
DataTableDataTable
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
transTypes
boolIndicates if preserve types when insert data into worksheet
Returns
InsertDataTable(DataTable, bool, int, int, int, int)
Imports data from a DataTable into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Insert the DataTable to worksheet
worksheet.InsertDataTable(table, true, 1 , 1 , 2 , 2);
//Save to file
workbook.SaveToFile(InsertDataTable.xlsx");
public int InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns)
Parameters
dataTable
DataTableDataTable
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
maxRows
intMaximum number of rows to import
maxColumns
intMaximum number of columns to import
Returns
InsertDataTable(DataTable, bool, int, int, int, int, bool)
Imports data from a DataTable into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Insert the DataTable to worksheet
worksheet.InsertDataTable(table, true, 1 , 1 , 2 , 2 , true);
//Save to file
workbook.SaveToFile(InsertDataTable.xlsx");
public int InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns, bool transTypes)
Parameters
dataTable
DataTableDatatable
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
maxRows
intMaximum number of rows to import
maxColumns
intMaximum number of columns to import
transTypes
boolIndicates if preserve types when insert data into worksheet
Returns
InsertDataTable(DataTable, bool, int, int, int, int, DataColumn[], bool)
Imports data from a DataTable into worksheet
public int InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns, DataColumn[] columnsArray, bool transTypes)
Parameters
dataTable
DataTableDataTable
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
maxRows
intMaximum number of rows to import
maxColumns
intMaximum number of columns to import
columnsArray
DataColumn[]Array of columns to import.
transTypes
boolIndicates if preserve types when insert data into worksheet.true is default
Returns
InsertDataView(DataView, bool, int, int)
Imports data from a DataView into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Initialize dataview of datatable
System.Data.DataView view = table.DefaultView;
//Import data from DataView
worksheet.InsertDataView(view, true, 1, 1);
//Save to file
workbook.SaveToFile(InsertDataView.xlsx");
public int InsertDataView(DataView dataView, bool columnHeaders, int firstRow, int firstColumn)
Parameters
dataView
DataViewData view object
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
Returns
InsertDataView(DataView, bool, int, int, bool)
Imports data from a DataView into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Initialize dataview of datatable
System.Data.DataView view = table.DefaultView;
//Import data from DataView
worksheet.InsertDataView(view, true, 1, 1 , true);
//Save to file
workbook.SaveToFile(InsertDataView.xlsx");
public int InsertDataView(DataView dataView, bool columnHeaders, int firstRow, int firstColumn, bool transTypes)
Parameters
dataView
DataViewDataview object.
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
transTypes
boolIndicates if preserve types when insert data into worksheet.
Returns
InsertDataView(DataView, bool, int, int, int, int)
Imports data from a DataView into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Initialize dataview of datatable
System.Data.DataView view = table.DefaultView;
//Import data from DataView
worksheet.InsertDataView(view, true, 1, 1 , 2 , 2);
//Save to file
workbook.SaveToFile(InsertDataView.xlsx");
public int InsertDataView(DataView dataView, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns)
Parameters
dataView
DataViewDataview object.
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
maxRows
intMaximum number of rows to import.
maxColumns
intMaximum number of columns to import.
Returns
InsertDataView(DataView, bool, int, int, int, int, bool)
Imports data from a DataView into worksheet.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a DataTable
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Item", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Rows.Add(1, "Soap", "David");
table.Rows.Add(2, "Paste", "Sam");
table.Rows.Add(3, "Cream", "Christoff");
//Initialize dataview of datatable
System.Data.DataView view = table.DefaultView;
//Import data from DataView
worksheet.InsertDataView(view, true, 1, 1 , 2 , 2 , true);
//Save to file
workbook.SaveToFile(InsertDataView.xlsx");
public int InsertDataView(DataView dataView, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns, bool transTypes)
Parameters
dataView
DataViewDataview object.
columnHeaders
boolIndicates whether to import field names.
firstRow
intThe row number of the first cell to import in.
firstColumn
intThe column number of the first cell to import in.
maxRows
intMaximum number of rows to import.
maxColumns
intMaximum number of columns to import.
transTypes
boolIndicates if preserve types when insert data into worksheet.
Returns
InsertRange(int, int, int, int, InsertMoveOption, InsertOptionsType)
Insert a cell range into worksheet
public IXLSRange InsertRange(int rowIndex, int columnIndex, int rowCount, int columnCount, InsertMoveOption moveOptions, InsertOptionsType insertOptions)
Parameters
rowIndex
intthe cell range first row index
columnIndex
intthe cell range first column index
rowCount
intthe number of rows
columnCount
intthe number of columns
moveOptions
InsertMoveOptionInsert options.
insertOptions
InsertOptionsTypeMove the cell on the right to right or Move the cell below down
Returns
- IXLSRange
return the range that insert into worksheet
InsertRow(int)
Inserts a new row into the worksheet.
public void InsertRow(int rowIndex)
Parameters
rowIndex
intIndex at which new row should be inserted
InsertRow(int, int)
Inserts multiple rows into the worksheet.
public void InsertRow(int rowIndex, int rowCount)
Parameters
InsertRow(int, int, InsertOptionsType)
public void InsertRow(int rowIndex, int rowCount, InsertOptionsType insertOptions)
Parameters
rowIndex
introwCount
intinsertOptions
InsertOptionsType
IntersectRanges(IXLSRange, IXLSRange)
protected IXLSRange IntersectRanges(IXLSRange range1, IXLSRange range2)
Parameters
Returns
IsArrayFormula(int, int)
Indicates whether cell contains array-entered formula.
public bool IsArrayFormula(int row, int column)
Parameters
Returns
- bool
True if cell contains array-entered formula.
IsArrayFormula(long)
[Obsolete("This is an obsolete method.")]
public bool IsArrayFormula(long cellIndex)
Parameters
cellIndex
long
Returns
IsColumnVisible(int)
Indicates whether column is visible.
public bool IsColumnVisible(int columnIndex)
Parameters
columnIndex
intColumn index.
Returns
- bool
true - visible, otherwise false.
IsExternalFormula(int, int)
Indicates is formula in cell is formula to external workbook.
public bool IsExternalFormula(int row, int column)
Parameters
Returns
- bool
If contain extern formula returns true; otherwise false.
IsRowVisible(int)
Indicates whether row is visible.
public bool IsRowVisible(int rowIndex)
Parameters
rowIndex
intRow index.
Returns
- bool
true - visible, otherwise false.
MergeRanges(IXLSRange, IXLSRange)
protected IXLSRange MergeRanges(IXLSRange range1, IXLSRange range2)
Parameters
Returns
MoveWorksheet(int)
Moves worksheet into new position.
public void MoveWorksheet(int destIndex)
Parameters
destIndex
intDestination index.
PixelsToColumnWidth(double)
public double PixelsToColumnWidth(double pixels)
Parameters
pixels
double
Returns
Remove()
Removes worksheet from parernt worksheets collection.
public void Remove()
RemoveMergedCells(IXLSRange)
public void RemoveMergedCells(IXLSRange range)
Parameters
range
IXLSRange
RemovePanes()
Removes panes from a worksheet.
public void RemovePanes()
ReparseFormula()
public void ReparseFormula()
Replace(string, DataColumn, bool)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by data column
string oldValue = "Find";
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Rows.Add(1);
System.Data.DataColumn dataColumn = table.Columns[0];
worksheet.Replace(oldValue, dataColumn, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DataColumn column, bool columnHeaders)
Parameters
oldValue
stringString value to replace.
column
DataColumnData table with new data.
columnHeaders
boolIndicates whether to import field names.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, DataTable, bool)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by data table
string oldValue = "Find";
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Rows.Add(1);
worksheet.Replace(oldValue, table, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DataTable newValues, bool columnHeaders)
Parameters
oldValue
stringString value to replace.
newValues
DataTableData table with new data.
columnHeaders
boolIndicates whether to import field names.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, DateTime)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by dateTime
string oldValue = "Find";
DateTime dateTime = DateTime.Now;
worksheet.Replace(oldValue, dateTime);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DateTime newValue)
Parameters
oldValue
stringString value to replace.
newValue
DateTimeNew value for the range with specified string.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, double)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by double
string oldValue = "Ten";
worksheet.Replace(oldValue, 10.0);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, double newValue)
Parameters
oldValue
stringString value to replace.
newValue
doubleNew value for the range with specified string.
Replace(string, double[], bool)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by array of double values
string oldValue = "Find";
double[] newValues = { 1.0, 2.0 };
worksheet.Replace(oldValue, newValues, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, double[] newValues, bool isVertical)
Parameters
oldValue
stringString value to replace.
newValues
double[]Array of new values.
isVertical
boolIndicates whether array should be inserted vertically.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, int[], bool)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by array of int values
string oldValue = "Find";
int[] newValues = { 1, 2 };
worksheet.Replace(oldValue, newValues, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, int[] newValues, bool isVertical)
Parameters
oldValue
stringString value to replace.
newValues
int[]Array of new values.
isVertical
boolIndicates whether array should be inserted vertically.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, string)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by newValue
string oldValue = "Find";
string newValue = "NewValue";
worksheet.Replace(oldValue, newValue);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, string newValue)
Parameters
oldValue
stringString value to replace.
newValue
stringNew value for the range with specified string.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
Replace(string, string[], bool)
Replaces cells' values with new data.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Replace the oldValue by array of string values
string oldValue = "Find";
string[] newValues = { "X values", "Y values" };
worksheet.Replace(oldValue, newValues , true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, string[] newValues, bool isVertical)
Parameters
oldValue
stringString value to replace.
newValues
string[]Array of new values.
isVertical
boolIndicates whether array should be inserted vertically.
Remarks
This can be long operation (needs iteration through all cells in the worksheet). Better use named ranges instead and call Import function instead of placeholders.
ReplaceAll(string, CellStyle, string, CellStyle)
Replaces cells' values with new data and style.
public int ReplaceAll(string oldValue, CellStyle oldStyle, string newValue, CellStyle newStyle)
Parameters
oldValue
stringString value to replace.
oldStyle
CellStyleCell style to replace.
newValue
stringNew value for the range with specified string.
newStyle
CellStyleNew cell style for the range.
Returns
ReplaceAll(string, string, bool)
public int ReplaceAll(string oldValue, string newValue, bool matchCase)
Parameters
Returns
SaveAndGetShapesToImage(SaveShapeTypeOption)
Save option specify shapes to image, and get option specify shapes together.
public Dictionary<IShape, SKBitmap> SaveAndGetShapesToImage(SaveShapeTypeOption option)
Parameters
option
SaveShapeTypeOption
Returns
- Dictionary<IShape, SKBitmap>
SaveShapesToImage(SaveShapeTypeOption)
Save option specify shapes to image.
public List<SKBitmap> SaveShapesToImage(SaveShapeTypeOption option)
Parameters
option
SaveShapeTypeOption
Returns
- List<SKBitmap>
SaveToFile(string, string)
Save worksheet to file.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Save to file
worksheet.SaveToFile("SaveToFile.csv" , ",");
public void SaveToFile(string fileName, string separator)
Parameters
SaveToFile(string, string, bool)
Save worksheet to file.
public void SaveToFile(string fileName, string separator, bool retainHiddenData)
Parameters
SaveToFile(string, string, Encoding)
Save worksheet to file..
public void SaveToFile(string fileName, string separator, Encoding encoding)
Parameters
SaveToFile(string, string, Encoding, bool)
Save worksheet to file..
public void SaveToFile(string fileName, string separator, Encoding encoding, bool addQuotationsForStringValue)
Parameters
fileName
stringFile name.
separator
stringSeperator.
encoding
EncodingEncoding to use.
addQuotationsForStringValue
boolAdd double Quotation marks for string value.
SaveToHtml(Stream)
Save to HTML stream.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Creat stream
Stream stream = new MemoryStream();
//Save to HTML stream
worksheet.SaveToHtml(stream);
public void SaveToHtml(Stream stream)
Parameters
stream
StreamStream object
SaveToHtml(Stream, HTMLOptions)
Saves work sheet to HTML.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Creat stream
Stream stream = new MemoryStream();
//Save to HTML stream
worksheet.SaveToHtml(stream, Spire.Xls.Core.Spreadsheet.HTMLOptions.Default);
public void SaveToHtml(Stream stream, HTMLOptions saveOption)
Parameters
stream
StreamThe stream
saveOption
HTMLOptionsThe option
SaveToHtml(string)
Save to HTML file.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Save to HTML file
worksheet.SaveToHtml("Output.html");
public void SaveToHtml(string filename)
Parameters
filename
stringFile name
SaveToHtml(string, HTMLOptions)
Saves as HTML.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Save to HTML file
worksheet.SaveToHtml("Sample.html" , Spire.Xls.Core.Spreadsheet.HTMLOptions.Default);
public void SaveToHtml(string fileName, HTMLOptions saveOption)
Parameters
fileName
stringThe filename
saveOption
HTMLOptionsThe option
SaveToPdf(string)
Save worksheet to pdf.
public void SaveToPdf(string fileName)
Parameters
fileName
stringFile name.
SaveToPdf(string, FileFormat)
Save worksheet to pdf.
[Obsolete("the parameter[fileFormat] is useless")]
public void SaveToPdf(string fileName, FileFormat fileFormat)
Parameters
fileName
stringFile name.
fileFormat
FileFormat
SaveToPdfStream(Stream)
Save worksheet to pdf Stream.
public void SaveToPdfStream(Stream stream)
Parameters
stream
StreamStream.
SaveToPdfStream(Stream, FileFormat)
[Obsolete("the parameter[fileFormat] is useless")]
public void SaveToPdfStream(Stream stream, FileFormat fileFormat)
Parameters
stream
StreamfileFormat
FileFormat
SaveToStream(Stream, string)
Save worksheet to stream.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Create stream
Stream stream = new MemoryStream();
//Save to stream
worksheet.SaveToStream(stream , ",");
public void SaveToStream(Stream stream, string separator)
Parameters
SaveToStream(Stream, string, bool)
Save worksheet to stream.
public void SaveToStream(Stream stream, string separator, bool retainHiddenData)
Parameters
SaveToStream(Stream, string, Encoding)
Save worksheet to stream.
public void SaveToStream(Stream stream, string separator, Encoding encoding)
Parameters
stream
StreamStream to save.
separator
stringCurrent seperator.
encoding
EncodingEncoding to use.
SaveToStream(Stream, string, Encoding, bool)
Save worksheet to stream.
public void SaveToStream(Stream stream, string separator, Encoding encoding, bool addQuotationsForStringValue)
Parameters
stream
StreamStream to save.
separator
stringCurrent seperator.
encoding
EncodingEncoding to use.
addQuotationsForStringValue
boolAdd double Quotation marks for string value.
SaveToXps(string)
Saves specific worksheet to xps.
public void SaveToXps(string fileName)
Parameters
fileName
stringFile name.
SetActiveCell(IXLSRange)
public void SetActiveCell(IXLSRange range)
Parameters
range
IXLSRange
SetActiveCell(IXLSRange, bool)
public void SetActiveCell(IXLSRange range, bool updateApplication)
Parameters
SetBlank(int, int)
Sets blank in specified cell.
public void SetBlank(int iRow, int iColumn)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
SetBoolean(int, int, bool)
Sets value in the specified cell.
public void SetBoolean(int iRow, int iColumn, bool value)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
boolValue to set.
SetCaculateValue(object, int, int)
[Obsolete("the method is obsolete, please use SetCalculateValue.")]
public void SetCaculateValue(object value, int row, int col)
Parameters
SetCalculateValue(object, int, int)
Sets the value of a cell.
public void SetCalculateValue(object value, int row, int col)
Parameters
SetCellValue(int, int, bool)
Sets value in the specified cell.
public void SetCellValue(int rowIndex, int columnIndex, bool boolValue)
Parameters
SetCellValue(int, int, string)
Sets value in the specified cell.
public void SetCellValue(int rowIndex, int columnIndex, string stringValue)
Parameters
SetColumnWidth(int, double)
Set solumn width
public void SetColumnWidth(int columnIndex, double width)
Parameters
SetColumnWidthInPixels(int, int)
Sets column width in pixels.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set column width
worksheet.SetColumnWidthInPixels(2, 160);
//Save to file
workbook.SaveToFile("SetColumnWidthInPixels.xlsx");
public void SetColumnWidthInPixels(int iColumn, int value)
Parameters
SetColumnWidthInPixels(int, int, int)
Sets the width of the specified columns.
public void SetColumnWidthInPixels(int columnIndex, int count, int value)
Parameters
SetDefaultColumnStyle(int, IStyle)
Sets default style for column.
public void SetDefaultColumnStyle(int columnIndex, IStyle defaultStyle)
Parameters
SetDefaultColumnStyle(int, int, IStyle)
public void SetDefaultColumnStyle(int firstColumnIndex, int lastColumnIndex, IStyle defaultStyle)
Parameters
SetDefaultRowStyle(int, IStyle)
public void SetDefaultRowStyle(int rowIndex, IStyle defaultStyle)
Parameters
SetDefaultRowStyle(int, int, IStyle)
public void SetDefaultRowStyle(int firstRowIndex, int lastRowIndex, IStyle defaultStyle)
Parameters
SetError(int, int, string)
Sets error in the specified cell.
public void SetError(int iRow, int iColumn, string value)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
stringError to set.
SetError(int, int, string, bool)
public void SetError(int iRow, int iColumn, string value, bool isSetText)
Parameters
SetFirstColumn(int)
public void SetFirstColumn(int columnIndex)
Parameters
columnIndex
int
SetFirstRow(int)
Updates first row index.
public void SetFirstRow(int rowIndex)
Parameters
rowIndex
intRow index.
SetFormula(int, int, string)
Sets formula in the specified cell.
public void SetFormula(int iRow, int iColumn, string value)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
stringFormula to set.
SetFormula(int, int, string, bool)
Sets formula in the specified cell.
public void SetFormula(int iRow, int iColumn, string value, bool bIsR1C1)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
stringFormula to set.
bIsR1C1
boolIndicates is formula in R1C1 notation.
SetFormulaBoolValue(int, int, bool)
Sets formula bool value.
public void SetFormulaBoolValue(int iRow, int iColumn, bool value)
Parameters
iRow
intOne based row index.
iColumn
intOne based column index.
value
boolRepresents formula bool value for set.
SetFormulaErrorValue(int, int, string)
Sets formula error value.
public void SetFormulaErrorValue(int iRow, int iColumn, string value)
Parameters
iRow
intOne based row index.
iColumn
intOne based column index.
value
stringRepresents formula error value for set.
SetFormulaNumberValue(int, int, double)
Sets formula number value.
public void SetFormulaNumberValue(int iRow, int iColumn, double value)
Parameters
iRow
intOne based row index.
iColumn
intOne based column index.
value
doubleRepresents formula number value for set.
SetFormulaStringValue(int, int, string)
Sets formula string value.
public void SetFormulaStringValue(int iRow, int iColumn, string value)
Parameters
iRow
intOne based row index.
iColumn
intOne based column index.
value
stringRepresents formula string value for set.
SetLastColumn(int)
Updates last column index.
public void SetLastColumn(int columnIndex)
Parameters
columnIndex
intColumn index.
SetLastRow(int)
Updates last row index.
public void SetLastRow(int rowIndex)
Parameters
rowIndex
intRow index.
SetNumber(int, int, double)
Sets value in the specified cell.
public void SetNumber(int iRow, int iColumn, double value)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
doubleValue to set.
SetRowHeight(int, double)
Sets the height of the specified row.
public void SetRowHeight(int rowIndex, double height)
Parameters
SetRowHeightInPixels(int, int, double)
Set Row height from Start Row index
public void SetRowHeightInPixels(int rowIndex, int count, double value)
Parameters
SetRowHeightPixels(int, double)
Sets the height of the specified row.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set row height
worksheet.SetRowHeightPixels(3, 150);
//Save to file
workbook.SaveToFile("SetRowHeightPixels.xlsx");
public void SetRowHeightPixels(int rowIndex, double height)
Parameters
SetText(int, int, string)
Sets text in the specified cell.
public void SetText(int iRow, int iColumn, string value)
Parameters
iRow
intOne-based row index of the cell to set value.
iColumn
intOne-based column index of the cell to set value.
value
stringText to set.
SetValue(int, int, string)
public void SetValue(int rowIndex, int columnIndex, string stringValue)
Parameters
ShowColumn(int)
Shows a column.
public void ShowColumn(int columnIndex)
Parameters
columnIndex
intColumn index.
ShowRow(int)
public void ShowRow(int rowIndex)
Parameters
rowIndex
int
Subtotal(IXLSRange, int, int[], SubtotalTypes)
Creates subtotals for the range.
public void Subtotal(IXLSRange range, int groupByIndex, int[] totalFields, SubtotalTypes subtotalType)
Parameters
range
IXLSRangeThe range
groupByIndex
intThe field index to group by, offset from zero
totalFields
int[]An array of zero-based field index offsets, indicating the fields to which the subtotals are added.
subtotalType
SubtotalTypesThe subtotal type.
Subtotal(IXLSRange, int, int[], SubtotalTypes, bool, bool, bool)
Creates subtotals for the range.
public void Subtotal(IXLSRange range, int groupByIndex, int[] totalFields, SubtotalTypes subtotalType, bool replace, bool addPageBreak, bool addsummaryBelowData)
Parameters
range
IXLSRangeThe range
groupByIndex
intThe field index to group by, offset from zero
totalFields
int[]An array of zero-based field index offsets, indicating the fields to which the subtotals are added.
subtotalType
SubtotalTypesThe subtotal type.
replace
boolIndicates whether replace the current subtotals
addPageBreak
boolIndicates whether add page break between groups
addsummaryBelowData
boolIndicates whether add summarry below data.
ToEMFStreamForOnline(Stream, int, int, int, int)
public void ToEMFStreamForOnline(Stream stream, int firstRow, int firstColumn, int lastRow, int lastColumn)
Parameters
ToImage(int, int, int, int)
public Stream ToImage(int firstRow, int firstColumn, int lastRow, int lastColumn)
Parameters
Returns
ToSVGStream(Stream, int, int, int, int)
Convert CellRange to Svg stream
public void ToSVGStream(Stream stream, int firstRow, int firstColumn, int lastRow, int lastColumn)
Parameters
stream
Streamstream.
firstRow
intOne-based index of the first row to convert.
firstColumn
intOne-based index of the first column to convert.
lastRow
intOne-based index of the last row to convert.
lastColumn
intOne-based index of the last column to convert.
UngroupByColumns(int, int)
Ungroups columns.
public CellRange UngroupByColumns(int firstColumn, int lastColumn)
Parameters
firstColumn
intThe first column index to be grouped.
lastColumn
intThe last column index to be grouped.
Returns
UngroupByRows(int, int)
Ungroups rows.
public CellRange UngroupByRows(int firstRow, int lastRow)
Parameters
Returns
Events
CellValueChanged
Occurs when the value of a cell changes.
public event XlsRange.CellValueChangedEventHandler CellValueChanged