Class ExcelWorksheets
The collection of worksheets for the workbook
Implements
Inherited Members
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 | 
|---|---|
| System.Int32 | 
Item[Int32]
Returns the worksheet at the specified position.
Declaration
public ExcelWorksheet this[int PositionID] { get; }
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | 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
Item[String]
Returns the worksheet matching the specified name
Declaration
public ExcelWorksheet this[string Name] { get; }
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.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 | 
|---|---|---|
| System.String | Name | The name of the existing worksheet  | 
      
| System.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(Int32)
Deletes a worksheet from the collection
Declaration
public void Delete(int Index)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | 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 | 
|---|---|---|
| System.String | name | The name of the worksheet in the workbook  | 
      
Dispose()
Dispose the worksheets collection
Declaration
public void Dispose()
  GetEnumerator()
Foreach support
Declaration
public IEnumerator<ExcelWorksheet> GetEnumerator()
  Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerator<ExcelWorksheet> | An enumerator  | 
      
MoveAfter(Int32, Int32)
Moves the source worksheet to the position after the target worksheet
Declaration
public void MoveAfter(int sourcePositionId, int targetPositionId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | sourcePositionId | The id of the source worksheet  | 
      
| System.Int32 | 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 | 
|---|---|---|
| System.String | sourceName | The name of the source worksheet  | 
      
| System.String | targetName | The name of the target worksheet  | 
      
MoveBefore(Int32, Int32)
Moves the source worksheet to the position before the target worksheet
Declaration
public void MoveBefore(int sourcePositionId, int targetPositionId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | sourcePositionId | The id of the source worksheet  | 
      
| System.Int32 | 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 | 
|---|---|---|
| System.String | sourceName | The name of the source worksheet  | 
      
| System.String | targetName | The name of the target worksheet  | 
      
MoveToEnd(Int32)
Moves the source worksheet to the end of the worksheets collection
Declaration
public void MoveToEnd(int sourcePositionId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | 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 | 
|---|---|---|
| System.String | sourceName | The name of the source worksheet  | 
      
MoveToStart(Int32)
Moves the source worksheet to the start of the worksheets collection
Declaration
public void MoveToStart(int sourcePositionId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | 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 | 
|---|---|---|
| System.String | sourceName | The name of the source worksheet  | 
      
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
  Returns
| Type | Description | 
|---|---|
| System.Collections.IEnumerator |