Show / Hide Table of Contents

Class ExcelWorksheets

The collection of worksheets for the workbook

Inheritance
System.Object
XmlHelper
ExcelWorksheets
Implements
System.Collections.Generic.IEnumerable<ExcelWorksheet>
System.Collections.IEnumerable
System.IDisposable
Inherited Members
XmlHelper.AddSchemaNodeOrder(String[], String[])
XmlHelper.AddSchemaNodeOrder(String[], String[], Int32[])
XmlHelper.GetBoolFromString(String)
XmlHelper.CreatespPrNode(String, Boolean)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.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
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
Compatibility

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

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

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
System.IDisposable
Back to top Generated by DocFX