Show / Hide Table of Contents

Class ExcelWorksheets

The collection of worksheets for the workbook

Inheritance
object
XmlHelper
ExcelWorksheets
Implements
IEnumerable<ExcelWorksheet>
IEnumerable
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: OfficeOpenXml
Assembly: EPPlus.dll
Syntax
public class ExcelWorksheets : XmlHelper, IEnumerable<ExcelWorksheet>, IEnumerable, IDisposable

Properties

Count

Returns the number of worksheets in the workbook

Declaration
public int Count { get; }
Property Value
Type Description
int

this[int]

Returns the worksheet at the specified position.

Declaration
public ExcelWorksheet this[int PositionID] { get; }
Parameters
Type Name Description
int PositionID

The position of the worksheet. Collection is zero-based or one-base depending on the Package.Compatibility.IsWorksheets1Based propery. Default is Zero based

Property Value
Type Description
ExcelWorksheet
See Also
Compatibility

this[string]

Returns the worksheet matching the specified name

Declaration
public ExcelWorksheet this[string Name] { get; }
Parameters
Type Name Description
string Name

The name of the worksheet

Property Value
Type Description
ExcelWorksheet

Methods

Add(string)

Adds a new blank worksheet.

Declaration
public ExcelWorksheet Add(string Name)
Parameters
Type Name Description
string Name

The name of the workbook

Returns
Type Description
ExcelWorksheet

Add(string, ExcelWorksheet)

Adds a copy of a worksheet

Declaration
public ExcelWorksheet Add(string Name, ExcelWorksheet Copy)
Parameters
Type Name Description
string Name

The name of the workbook

ExcelWorksheet Copy

The worksheet to be copied

Returns
Type Description
ExcelWorksheet

AddChart(string, eChartType)

Adds a chartsheet to the workbook.

Declaration
public ExcelChartsheet AddChart(string Name, eChartType chartType)
Parameters
Type Name Description
string Name

The name of the worksheet

eChartType chartType

The type of chart

Returns
Type Description
ExcelChartsheet

AddChart(string, eChartType, ExcelPivotTable)

Adds a chartsheet to the workbook.

Declaration
public ExcelChartsheet AddChart(string Name, eChartType chartType, ExcelPivotTable pivotTableSource)
Parameters
Type Name Description
string Name

The name of the worksheet

eChartType chartType

The type of chart

ExcelPivotTable pivotTableSource

The pivottable source

Returns
Type Description
ExcelChartsheet

AddStockChart(string, ExcelRangeBase, ExcelRangeBase, ExcelRangeBase, ExcelRangeBase, ExcelRangeBase, ExcelRangeBase)

Adds a stock chart sheet to the workbook.

Declaration
public ExcelChartsheet AddStockChart(string Name, ExcelRangeBase CategorySerie, ExcelRangeBase HighSerie, ExcelRangeBase LowSerie, ExcelRangeBase CloseSerie, ExcelRangeBase OpenSerie = null, ExcelRangeBase VolumeSerie = null)
Parameters
Type Name Description
string Name

The name of the worksheet

ExcelRangeBase CategorySerie

The category serie. A serie containing dates or names

ExcelRangeBase HighSerie

The high price serie

ExcelRangeBase LowSerie

The low price serie

ExcelRangeBase CloseSerie

The close price serie containing

ExcelRangeBase OpenSerie

The opening price serie. Supplying this serie will create a StockOHLC or StockVOHLC chart

ExcelRangeBase VolumeSerie

The volume represented as a column chart. Supplying this serie will create a StockVHLC or StockVOHLC chart

Returns
Type Description
ExcelChartsheet

Copy(string, string)

Copies the named worksheet and creates a new worksheet in the same workbook

Declaration
public ExcelWorksheet Copy(string Name, string NewName)
Parameters
Type Name Description
string Name

The name of the existing worksheet

string NewName

The name of the new worksheet to create

Returns
Type Description
ExcelWorksheet

The new copy added to the end of the worksheets collection

Delete(ExcelWorksheet)

Delete a worksheet from the collection

Declaration
public void Delete(ExcelWorksheet Worksheet)
Parameters
Type Name Description
ExcelWorksheet Worksheet

The worksheet to delete

Delete(int)

Deletes a worksheet from the collection

Declaration
public void Delete(int Index)
Parameters
Type Name Description
int Index

The position of the worksheet in the workbook

Delete(string)

Deletes a worksheet from the collection

Declaration
public void Delete(string name)
Parameters
Type Name Description
string name

The name of the worksheet in the workbook

DeleteAll(Predicate<ExcelWorksheet>)

Deletes all worksheets that matches the Predicate from the collection of worksheets

Declaration
public void DeleteAll(Predicate<ExcelWorksheet> match)
Parameters
Type Name Description
Predicate<ExcelWorksheet> match
Exceptions
Type Condition
ArgumentException

Dispose()

Dispose the worksheets collection

Declaration
public void Dispose()

GetEnumerator()

Foreach support

Declaration
public IEnumerator<ExcelWorksheet> GetEnumerator()
Returns
Type Description
IEnumerator<ExcelWorksheet>

An enumerator

MoveAfter(int, int)

Moves the source worksheet to the position after the target worksheet

Declaration
public void MoveAfter(int sourcePositionId, int targetPositionId)
Parameters
Type Name Description
int sourcePositionId

The id of the source worksheet

int targetPositionId

The id of the target worksheet

MoveAfter(string, string)

Moves the source worksheet to the position after the target worksheet

Declaration
public void MoveAfter(string sourceName, string targetName)
Parameters
Type Name Description
string sourceName

The name of the source worksheet

string targetName

The name of the target worksheet

MoveBefore(int, int)

Moves the source worksheet to the position before the target worksheet

Declaration
public void MoveBefore(int sourcePositionId, int targetPositionId)
Parameters
Type Name Description
int sourcePositionId

The id of the source worksheet

int targetPositionId

The id of the target worksheet

MoveBefore(string, string)

Moves the source worksheet to the position before the target worksheet

Declaration
public void MoveBefore(string sourceName, string targetName)
Parameters
Type Name Description
string sourceName

The name of the source worksheet

string targetName

The name of the target worksheet

MoveToEnd(int)

Moves the source worksheet to the end of the worksheets collection

Declaration
public void MoveToEnd(int sourcePositionId)
Parameters
Type Name Description
int sourcePositionId

The position of the source worksheet

MoveToEnd(string)

Moves the source worksheet to the end of the worksheets collection

Declaration
public void MoveToEnd(string sourceName)
Parameters
Type Name Description
string sourceName

The name of the source worksheet

MoveToStart(int)

Moves the source worksheet to the start of the worksheets collection

Declaration
public void MoveToStart(int sourcePositionId)
Parameters
Type Name Description
int sourcePositionId

The position of the source worksheet

MoveToStart(string)

Moves the source worksheet to the start of the worksheets collection

Declaration
public void MoveToStart(string sourceName)
Parameters
Type Name Description
string sourceName

The name of the source worksheet

Implements

IEnumerable<T>
IEnumerable
IDisposable
In this article
Back to top Generated by DocFX