Table of Contents

Class OdfWorksheetCollection

Namespace
OdfKit.Spreadsheet
Assembly
OdfKit.dll

Indexes and enumerates workbook worksheets. 提供活頁簿工作表的索引與列舉入口。

public sealed class OdfWorksheetCollection : IEnumerable<OdfTableSheet>, IEnumerable
Inheritance
OdfWorksheetCollection
Implements
Inherited Members

Constructors

OdfWorksheetCollection(SpreadsheetDocument)

Initializes a new instance of the OdfWorksheetCollection class. 初始化 OdfWorksheetCollection 類別的新執行個體。

public OdfWorksheetCollection(SpreadsheetDocument document)

Parameters

document SpreadsheetDocument

The owning spreadsheet document. / 所屬試算表文件。

Properties

Count

Gets the current worksheet count. 取得目前工作表數量。

public int Count { get; }

Property Value

int

this[int]

Gets a worksheet by index. 依索引取得工作表。

public OdfTableSheet this[int index] { get; }

Parameters

index int

The zero-based worksheet index. / 採 0 為基準的工作表索引。

Property Value

OdfTableSheet

The worksheet at the specified index. / 指定索引的工作表。

Exceptions

ArgumentOutOfRangeException

Thrown when the index is out of range. / 當索引超出範圍時擲出。

this[string]

Gets a worksheet by name. 依名稱取得工作表。

public OdfTableSheet this[string name] { get; }

Parameters

name string

The worksheet name. / 工作表名稱。

Property Value

OdfTableSheet

The worksheet with the specified name. / 指定名稱的工作表。

Exceptions

KeyNotFoundException

Thrown when the specified worksheet cannot be found. / 當找不到指定工作表時擲出。

Methods

Add(string)

Adds a worksheet to the collection. 新增工作表。

public OdfTableSheet Add(string name)

Parameters

name string

The worksheet name. / 工作表名稱。

Returns

OdfTableSheet

The added worksheet. / 新增完成的工作表。

Adopt(OdfTableSheet)

Short overload of Adopt that accepts sheet; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheet;其餘可選參數使用預設值並轉呼叫最長 Adopt 多載。

public OdfTableSheet Adopt(OdfTableSheet sheet)

Parameters

sheet OdfTableSheet

Returns

OdfTableSheet

Adopt(OdfTableSheet, string?)

Adopts a worksheet from another document or the same document to the end of the collection. 將另一份文件或同一份文件中的工作表採納到集合末尾。

public OdfTableSheet Adopt(OdfTableSheet sheet, string? newName)

Parameters

sheet OdfTableSheet

The source worksheet to adopt. / 要採納的來源工作表。

newName string

The optional new worksheet name after adoption; when unspecified, the source name is preserved. / 採納後選用的新工作表名稱;未指定時保留來源名稱。

Returns

OdfTableSheet

The adopted worksheet that belongs to this collection's owning document. / 採納完成且屬於此集合所屬文件的工作表。

Exceptions

ArgumentNullException

Thrown when sheet is null. / 當 sheetnull 時擲出。

Find(string)

Finds a worksheet with the specified name. 尋找指定名稱的工作表。

public OdfTableSheet? Find(string name)

Parameters

name string

The worksheet name. / 工作表名稱。

Returns

OdfTableSheet

The found worksheet, or null if no worksheet is found. / 找到的工作表;找不到時為 null

GetEnumerator()

Gets the worksheet enumerator. 取得工作表列舉器。

public IEnumerator<OdfTableSheet> GetEnumerator()

Returns

IEnumerator<OdfTableSheet>

The worksheet enumerator. / 工作表列舉器。