Class SpreadsheetDocument
- Namespace
- OdfKit.Spreadsheet
- Assembly
- OdfKit.dll
Provides the SpreadsheetDocument API. 提供 SpreadsheetDocument API。
public class SpreadsheetDocument : OdfDocument, IDisposable, IAsyncDisposable
- Inheritance
-
SpreadsheetDocument
- Implements
- Derived
- Inherited Members
Constructors
SpreadsheetDocument(OdfPackage)
Initializes a new instance of the SpreadsheetDocument class. 初始化 SpreadsheetDocument 類別的新執行個體。
public SpreadsheetDocument(OdfPackage package)
Parameters
packageOdfPackageThe ODF package. / Odf 套件包。
Properties
CalculationSettings
Gets the workbook-level formula calculation and recalculation settings for the ODS spreadsheet. 取得 ODS 活頁簿層級的公式計算與重算設定。
public OdfSpreadsheetCalculationSettings CalculationSettings { get; }
Property Value
ExternalLinks
Gets the external link manager for cross-document formula references. 取得跨文件公式引用的外部連結管理器。
public OdfExternalLinkManager ExternalLinks { get; }
Property Value
TrackedChanges
Gets or sets a value indicating whether spreadsheet change tracking is enabled. 取得或設定一個值,指出是否啟用試算表追蹤修訂。
public bool TrackedChanges { get; set; }
Property Value
WorkbookStructureProtected
Gets a value indicating whether the workbook structure is protected. 取得一個值,指出活頁簿結構是否受到保護。
public bool WorkbookStructureProtected { get; }
Property Value
Worksheets
Gets the worksheet collection. 取得工作表集合。
public OdfWorksheetCollection Worksheets { get; }
Property Value
Methods
AcceptAllChanges()
Accepts all pending tracked changes. 接受所有待處理的追蹤修訂。
public void AcceptAllChanges()
AcceptChange(string)
Accepts the specified tracked change. 接受指定的追蹤修訂。
public void AcceptChange(string changeId)
Parameters
changeIdstringThe change identifier. / 修訂識別碼。
AddChart(string, OdfCellAddress, OdfChartDefinition)
Inserts a chart at the specified cell position in a worksheet. 在指定工作表的儲存格位置插入圖表。
public void AddChart(string sheetName, OdfCellAddress anchor, OdfChartDefinition chart)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
anchorOdfCellAddressThe cell address. / 圖表左上角錨定的儲存格位置
chartOdfChartDefinitionThe value to use. / 圖表設定物件
AddChart(string, OdfCellAddress, OdfChartDefinition, OdfLength, OdfLength)
Inserts a chart at the specified cell position in a worksheet with custom dimensions. 在指定工作表的儲存格位置插入圖表(支援自訂寬高)。
public OdfNode AddChart(string sheetName, OdfCellAddress anchor, OdfChartDefinition chart, OdfLength width, OdfLength height)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
anchorOdfCellAddressThe cell address. / 圖表左上角錨定的儲存格位置
chartOdfChartDefinitionThe value to use. / 圖表設定物件
widthOdfLengthThe value to use. / 圖表寬度
heightOdfLengthThe value to use. / 圖表高度
Returns
- OdfNode
The result. / 代表圖表物件的 OdfNode 節點
AddChartFromRange(string, OdfCellAddress, OdfCellRange)
Short overload of AddChartFromRange that accepts sheetName, anchor, and range; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName、anchor 與 range;其餘可選參數使用預設值並轉呼叫最長 AddChartFromRange 多載。
public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range)
Parameters
sheetNamestringanchorOdfCellAddressrangeOdfCellRange
Returns
- OdfNode
AddChartFromRange(string, OdfCellAddress, OdfCellRange, OdfChartPreset)
Short overload of AddChartFromRange that accepts sheetName, anchor, range, and preset; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName、anchor、range 與 preset;其餘可選參數使用預設值並轉呼叫最長 AddChartFromRange 多載。
public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfChartPreset preset)
Parameters
sheetNamestringanchorOdfCellAddressrangeOdfCellRangepresetOdfChartPreset
Returns
- OdfNode
AddChartFromRange(string, OdfCellAddress, OdfCellRange, OdfChartPreset, string?)
Inserts a practical preset chart bound to a worksheet range. 插入繫結至工作表範圍的實務預設圖表。
public OdfNode AddChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfChartPreset preset, string? title)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
anchorOdfCellAddressThe top-left anchor cell. / 左上角錨定儲存格。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
presetOdfChartPresetThe chart preset. / 圖表預設。
titlestringThe optional chart title. / 選用的圖表標題。
Returns
- OdfNode
The created frame node. / 建立完成的框架節點。
AddDataValidation(string, OdfDataValidation)
Adds a data validation rule to the specified worksheet. 在指定的工作表中新增資料驗證規則。
public void AddDataValidation(string sheetName, OdfDataValidation validation)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
validationOdfDataValidationThe value to use. / 資料驗證設定物件
AddDatabaseRange(string, OdfCellRange)
Adds a database range. 新增資料庫範圍。
public OdfDatabaseRange AddDatabaseRange(string name, OdfCellRange range)
Parameters
namestringThe name or identifier. / 資料庫範圍名稱
rangeOdfCellRangeThe cell range. / 目標儲存格範圍
Returns
- OdfDatabaseRange
The result. / 新增的 OdfDatabaseRange 執行個體
AddImageFrame(string, OdfCellAddress, byte[], OdfLength, OdfLength)
Short overload of AddImageFrame that accepts sheetName, anchor, imageBytes, width, and height; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName、anchor、imageBytes、width 與 height;其餘可選參數使用預設值並轉呼叫最長 AddImageFrame 多載。
public OdfImage AddImageFrame(string sheetName, OdfCellAddress anchor, byte[] imageBytes, OdfLength width, OdfLength height)
Parameters
sheetNamestringanchorOdfCellAddressimageBytesbyte[]widthOdfLengthheightOdfLength
Returns
AddImageFrame(string, OdfCellAddress, byte[], OdfLength, OdfLength, string?)
Inserts an image frame at the specified cell position in a worksheet. 在指定工作表的儲存格位置插入影像框架。
public OdfImage AddImageFrame(string sheetName, OdfCellAddress anchor, byte[] imageBytes, OdfLength width, OdfLength height, string? name)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
anchorOdfCellAddressThe cell address. / 影像左上角錨定的儲存格位置
imageBytesbyte[]The value to use. / 影像的二進位資料位元組
widthOdfLengthThe value to use. / 影像寬度
heightOdfLengthThe value to use. / 影像高度
namestringThe name or identifier. / 影像名稱
Returns
- OdfImage
The result. / 代表新建立影像框架的 OdfImage 物件
AddNamedExpression(string, string)
Short overload of AddNamedExpression that accepts name and expression; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name 與 expression;其餘可選參數使用預設值並轉呼叫最長 AddNamedExpression 多載。
public void AddNamedExpression(string name, string expression)
Parameters
AddNamedExpression(string, string, OdfCellAddress?)
Adds a named expression. 新增具名運算式。
public void AddNamedExpression(string name, string expression, OdfCellAddress? baseCell)
Parameters
namestringThe name or identifier. / 具名運算式的名稱
expressionstringThe value to use. / 公式運算式字串
baseCellOdfCellAddress?The cell address. / 基準儲存格位址
AddNamedRange(string, OdfCellRange)
Short overload of AddNamedRange that accepts name and range; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name 與 range;其餘可選參數使用預設值並轉呼叫最長 AddNamedRange 多載。
public void AddNamedRange(string name, OdfCellRange range)
Parameters
namestringrangeOdfCellRange
AddNamedRange(string, OdfCellRange, OdfCellAddress?)
Adds a named range. 新增命名範圍。
public void AddNamedRange(string name, OdfCellRange range, OdfCellAddress? baseCell)
Parameters
namestringThe name or identifier. / 命名範圍的名稱
rangeOdfCellRangeThe cell range. / 儲存格範圍
baseCellOdfCellAddress?The cell address. / 基準儲存格位址
AddSheet(string)
Adds a worksheet with the specified name. 新增指定名稱的工作表。
public OdfTableSheet AddSheet(string name)
Parameters
namestringThe name or identifier. / 工作表名稱
Returns
- OdfTableSheet
The result. / 新增的 OdfTableSheet 執行個體
AdoptSheet(OdfTableSheet)
Short overload of AdoptSheet that accepts sheet; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheet;其餘可選參數使用預設值並轉呼叫最長 AdoptSheet 多載。
public OdfTableSheet AdoptSheet(OdfTableSheet sheet)
Parameters
sheetOdfTableSheet
Returns
AdoptSheet(OdfTableSheet, string?)
Adopts a worksheet from another document or the same document at the end of this workbook. 將另一份文件或同一份文件中的工作表採納到此活頁簿末尾。
public OdfTableSheet AdoptSheet(OdfTableSheet sheet, string? newName)
Parameters
sheetOdfTableSheetThe value to use. / 要採納的來源工作表
newNamestringThe name or identifier. / 採納後選用的新工作表名稱;未指定時保留來源名稱
Returns
- OdfTableSheet
The result. / 採納完成且屬於此文件的工作表
Remarks
此方法沿用 AdoptNode(OdfDocument, OdfNode) 的低分配採納路徑, 會將來源工作表節點自原本活頁簿移除、遷移媒體參照,並更新節點文件所有權與命名空間前綴。
Exceptions
- ArgumentNullException
Thrown when the documented condition occurs. / 當
sheet為 null 時擲出
AppendObjects<T>(string, IEnumerable<T>)
Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。
public OdfObjectBindingReport AppendObjects<T>(string sheetName, IEnumerable<T> items)
Parameters
sheetNamestringitemsIEnumerable<T>
Returns
Type Parameters
T
AppendObjects<T>(string, IEnumerable<T>, OdfObjectBindingOptions?)
Appends public readable object properties after the used range of the specified worksheet. 將物件的可讀公開屬性附加到指定工作表已使用範圍之後。
public OdfObjectBindingReport AppendObjects<T>(string sheetName, IEnumerable<T> items, OdfObjectBindingOptions? options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
itemsIEnumerable<T>The object sequence to append. / 要附加的物件序列。
optionsOdfObjectBindingOptionsThe object binding options. / 物件繫結選項。
Returns
- OdfObjectBindingReport
The object binding report. / 物件繫結報告。
Type Parameters
TThe object type to append. / 要附加的物件型別。
AppendRows(string, IEnumerable<IEnumerable<object?>>)
Appends rows after the current used range in the specified worksheet. 將資料列附加到指定工作表目前已使用範圍之後。
public OdfCellRange AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rowsIEnumerable<IEnumerable<object>>The row values to append. / 要附加的資料列。
Returns
- OdfCellRange
The appended range. / 已附加的範圍。
AppendRows(string, IEnumerable<IEnumerable<object?>>, int)
Short overload of AppendRows that accepts sheetName and startColumn; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName 與 startColumn;其餘可選參數使用預設值並轉呼叫最長 AppendRows 多載。
public OdfCellRange AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows, int startColumn)
Parameters
sheetNamestringrowsIEnumerable<IEnumerable<object>>startColumnint
Returns
AppendRows(string, IEnumerable<IEnumerable<object?>>, int, OdfRangeWriteOptions?)
Appends rows after the current used range in the specified worksheet and returns a write report. 將資料列附加到指定工作表目前已使用範圍之後並傳回寫入報告。
public OdfRangeWriteReport AppendRows(string sheetName, IEnumerable<IEnumerable<object?>> rows, int startColumn, OdfRangeWriteOptions? options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rowsIEnumerable<IEnumerable<object>>The row values to append. / 要附加的資料列。
startColumnintThe zero-based start column. / 以 0 為基準的起始欄。
optionsOdfRangeWriteOptionsThe range write options. / 範圍寫入選項。
Returns
- OdfRangeWriteReport
The range write report. / 範圍寫入報告。
BeginFormulaEvaluationChannel()
Short overload of BeginFormulaEvaluationChannel that uses default values for all optional parameters and forwards to the full overload. 便利多載:BeginFormulaEvaluationChannel 的所有可選參數使用預設值並轉呼叫最長多載。
public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel()
Returns
BeginFormulaEvaluationChannel(int)
Short overload of BeginFormulaEvaluationChannel that accepts capacity; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 capacity;其餘可選參數使用預設值並轉呼叫最長 BeginFormulaEvaluationChannel 多載。
public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel(int capacity)
Parameters
capacityint
Returns
BeginFormulaEvaluationChannel(int, CancellationToken)
Opens an asynchronous formula recalculation channel that queues subsequent cell value or formula changes for background recalculation. 開啟非同步公式重算通道,將後續儲存格值或公式變更排入背景重算。
public OdfFormulaEvaluationChannel BeginFormulaEvaluationChannel(int capacity, CancellationToken cancellationToken)
Parameters
capacityintThe channel capacity. / 通道容量。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- OdfFormulaEvaluationChannel
The started formula recalculation channel. / 已啟動的公式重算通道。
Builder()
Creates a new ODS spreadsheet document fluent builder. 建立新的 ODS 試算表文件 Fluent builder。
public static SpreadsheetDocumentBuilder Builder()
Returns
- SpreadsheetDocumentBuilder
A new SpreadsheetDocumentBuilder instance. / 新的 SpreadsheetDocumentBuilder 執行個體。
ClearTemplateUserContent()
Clears template user content. 清除 Template User Content。
protected override void ClearTemplateUserContent()
Remarks
基底實作不做任何事;各文件種類(文字、試算表、簡報、繪圖)於對應的部分類別中覆寫, 依各自的內容模型清除使用者資料。
Create()
Creates a new ODS spreadsheet document. 建立新的 ODS 試算表文件。
public static SpreadsheetDocument Create()
Returns
- SpreadsheetDocument
A new SpreadsheetDocument instance. / 新的 SpreadsheetDocument 執行個體。
CreateFromFlatDocument(FlatSpreadsheetDocument)
Creates an equivalent ODS (ZIP package) spreadsheet document from a FODS flat XML spreadsheet document, with identical content. 從 FODS 扁平 XML 試算表文件建立等價的 ODS(ZIP 封裝)試算表文件,內容完全相同。
public static SpreadsheetDocument CreateFromFlatDocument(FlatSpreadsheetDocument document)
Parameters
documentFlatSpreadsheetDocumentThe source FODS flat XML spreadsheet document. / 來源 FODS 扁平 XML 試算表文件。
Returns
- SpreadsheetDocument
The created SpreadsheetDocument instance. / 建立完成的 SpreadsheetDocument 執行個體。
CreateFromTemplate(SpreadsheetTemplateDocument)
Short overload of CreateFromTemplate that accepts template; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 template;其餘可選參數使用預設值並轉呼叫最長 CreateFromTemplate 多載。
public static SpreadsheetDocument CreateFromTemplate(SpreadsheetTemplateDocument template)
Parameters
templateSpreadsheetTemplateDocument
Returns
CreateFromTemplate(SpreadsheetTemplateDocument, bool)
Creates a new spreadsheet document from the specified spreadsheet template. 從指定的試算表範本文件建立新的試算表文件。
public static SpreadsheetDocument CreateFromTemplate(SpreadsheetTemplateDocument template, bool clearUserContent)
Parameters
templateSpreadsheetTemplateDocumentThe spreadsheet template document. / 試算表範本文件。
clearUserContentboolWhether to clear the data rows of each sheet in the template while keeping column widths and sheet structure. / 是否清除範本中各工作表的資料列,但保留欄寬與工作表結構。
Returns
- SpreadsheetDocument
The created SpreadsheetDocument instance. / 建立完成的 SpreadsheetDocument 執行個體。
CreateTable(string, OdfCellRange)
Short overload of CreateTable that accepts name and range; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 name 與 range;其餘可選參數使用預設值並轉呼叫最長 CreateTable 多載。
public OdfSpreadsheetTable CreateTable(string name, OdfCellRange range)
Parameters
namestringrangeOdfCellRange
Returns
CreateTable(string, OdfCellRange, OdfSpreadsheetTableOptions?)
Creates a practical spreadsheet table backed by an ODF database range. 建立由 ODF 資料庫範圍支援的實務試算表表格。
public OdfSpreadsheetTable CreateTable(string name, OdfCellRange range, OdfSpreadsheetTableOptions? options)
Parameters
namestringThe table name. / 表格名稱。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
optionsOdfSpreadsheetTableOptionsThe table options. / 表格選項。
Returns
- OdfSpreadsheetTable
The editable table facade. / 可編輯的表格 facade。
Dispose(bool)
Releases unmanaged resources. 釋放非受控資源。
protected override void Dispose(bool disposing)
Parameters
EvaluateFormulas()
Evaluates formulas in the current spreadsheet document and resolves cross-document references with ExternalLinks. 評估目前試算表文件中的公式,並使用 ExternalLinks 解析跨文件參照。
public void EvaluateFormulas()
FindSheet(string)
Finds the worksheet with the specified name. 尋找指定名稱的工作表。
public OdfTableSheet? FindSheet(string name)
Parameters
namestringThe name or identifier. / 工作表名稱
Returns
- OdfTableSheet
The result. / 找不到則傳回 null
FindTable(string)
Finds an editable practical spreadsheet table by name. 依名稱尋找可編輯的實務試算表表格。
public OdfSpreadsheetTable? FindTable(string name)
Parameters
namestringThe table name. / 表格名稱。
Returns
- OdfSpreadsheetTable
The table facade, or null when not found. / 表格 facade;找不到時為 null。
GetConditionalFormats()
Gets summaries for LibreOffice calcext conditional formatting rules across all worksheets in the spreadsheet. 取得試算表中所有工作表的 LibreOffice calcext 條件格式規則摘要清單。
public IReadOnlyList<OdfConditionalFormatInfo> GetConditionalFormats()
Returns
GetDataValidations()
Gets summaries for all data validation rules in the spreadsheet. 取得試算表中所有資料驗證規則的摘要清單。
public IReadOnlyList<OdfDataValidationInfo> GetDataValidations()
Returns
GetDatabaseRanges()
Gets summaries for all database ranges in the spreadsheet. 取得試算表中所有資料庫範圍的摘要清單。
public IReadOnlyList<OdfDatabaseRangeInfo> GetDatabaseRanges()
Returns
GetDefaultContentXml()
Gets the default content.xml content. 取得預設的 content.xml 內容。
protected override string GetDefaultContentXml()
Returns
- string
The default XML content string. / 預設的 XML 內容字串。
GetDefaultStylesXml()
Gets the default styles.xml content. 取得預設的 styles.xml 內容。
protected override string GetDefaultStylesXml()
Returns
- string
The default XML content string. / 預設的 XML 內容字串。
GetEmbeddedChartDocument(OdfEmbeddedChartInfo)
Gets the chart document for an embedded chart subpackage for advanced editing. 取得嵌入圖表的子封裝圖表文件,以供進階編輯。
public OdfChartDocument GetEmbeddedChartDocument(OdfEmbeddedChartInfo chartInfo)
Parameters
chartInfoOdfEmbeddedChartInfoThe embedded chart summary information. / 嵌入圖表摘要資訊。
Returns
- OdfChartDocument
The editable OdfChartDocument instance. / 可編輯的 OdfChartDocument 執行個體。
Remarks
傳回的執行個體會從目前封裝中既有的 content.xml 位元組重新解析出獨立的 DOM 樹,
對其呼叫的任何修改方法(例如 ApplyDefinition(OdfChartDefinition)、
ClearSeries() 等)會先變更此記憶體中的 DOM。
父文件儲存時會自動 flush 已追蹤的嵌入圖表;呼叫端也可手動呼叫傳回執行個體的
Save 方法,以提早將變更寫回共用封裝。
GetEmbeddedChartDocument(string)
Gets an embedded chart document by subpackage path. 依子封裝路徑取得嵌入圖表文件。
public OdfChartDocument GetEmbeddedChartDocument(string objectPath)
Parameters
objectPathstringThe embedded chart subpackage path (e.g.
Object 1/). / 嵌入圖表子封裝路徑(例如Object 1/)。
Returns
- OdfChartDocument
The editable OdfChartDocument instance. / 可編輯的 OdfChartDocument 執行個體。
Remarks
父文件儲存時會自動 flush 對傳回執行個體所做的修改;呼叫端仍可手動呼叫其
Save 方法,以提早寫回共用封裝。
GetEmbeddedCharts()
Gets summaries for all embedded charts in the spreadsheet. 取得試算表中所有嵌入圖表的摘要清單。
public IReadOnlyList<OdfEmbeddedChartInfo> GetEmbeddedCharts()
Returns
GetFormula(string, string)
Gets the formula for a cell in the specified worksheet. 取得指定工作表儲存格的公式。
public string GetFormula(string sheetName, string address)
Parameters
Returns
- string
The result. / 指定儲存格的公式;若沒有公式則為空字串
GetFormulaCells()
Gets all used cells with formulas in the workbook. 取得活頁簿中所有含公式的已使用儲存格。
public IEnumerable<OdfFormulaCellInfo> GetFormulaCells()
Returns
- IEnumerable<OdfFormulaCellInfo>
The result. / 含公式儲存格資訊列舉
GetFormulaCells(Func<OdfFormulaCellInfo, bool>)
Gets formula cells in the workbook that match the specified predicate. 取得活頁簿中符合指定條件的公式儲存格。
public IEnumerable<OdfFormulaCellInfo> GetFormulaCells(Func<OdfFormulaCellInfo, bool> predicate)
Parameters
predicateFunc<OdfFormulaCellInfo, bool>The delegate to invoke. / 用來篩選公式儲存格的條件委派
Returns
- IEnumerable<OdfFormulaCellInfo>
The result. / 符合條件的公式儲存格資訊列舉
GetFrozenPanes()
Gets summaries for all worksheets in the spreadsheet that define frozen panes. 取得試算表中所有已設定凍結窗格的工作表摘要清單。
public IReadOnlyList<OdfSheetFrozenPanesInfo> GetFrozenPanes()
Returns
GetNamedExpressions()
Gets summaries for all named expressions in the spreadsheet, including document-level and worksheet-level expressions. 取得試算表中所有具名運算式的摘要清單(含文件層與各工作表層)。
public IReadOnlyList<OdfNamedExpressionInfo> GetNamedExpressions()
Returns
GetNamedRanges()
Gets summaries for all named ranges in the spreadsheet, including document-level and worksheet-level ranges. 取得試算表中所有命名範圍的摘要清單(含文件層與各工作表層)。
public IReadOnlyList<OdfNamedRangeInfo> GetNamedRanges()
Returns
GetPivotTables()
Gets summaries for pivot tables across all worksheets in the spreadsheet. 取得試算表中所有工作表的樞紐分析表摘要清單。
public IReadOnlyList<OdfPivotTableInfo> GetPivotTables()
Returns
GetPrintAreas()
Gets summaries for all worksheets in the spreadsheet that define print areas. 取得試算表中所有已設定列印範圍的工作表摘要清單。
public IReadOnlyList<OdfSheetPrintAreaInfo> GetPrintAreas()
Returns
GetSheets()
Gets all worksheets in the current workbook. 取得目前活頁簿中所有的工作表。
public IReadOnlyList<OdfTableSheet> GetSheets()
Returns
- IReadOnlyList<OdfTableSheet>
The result. / 工作表唯讀清單
GetSparklineGroups()
Gets summaries for LibreOffice calcext sparkline groups across all worksheets in the spreadsheet. 取得試算表中所有工作表的 LibreOffice calcext 走勢圖群組摘要清單。
public IReadOnlyList<OdfSparklineGroupInfo> GetSparklineGroups()
Returns
GetSplitPanes()
Gets summaries for all worksheets in the spreadsheet that define split panes. 取得試算表中所有已設定分割窗格的工作表摘要清單。
public IReadOnlyList<OdfSheetSplitPanesInfo> GetSplitPanes()
Returns
GetTables()
Gets practical spreadsheet table summaries. 取得實務試算表表格摘要。
public IReadOnlyList<OdfSpreadsheetTableInfo> GetTables()
Returns
- IReadOnlyList<OdfSpreadsheetTableInfo>
The table summaries. / 表格摘要。
GetTrackedChanges()
Gets summaries for all tracked changes in the document. 取得文件中所有追蹤修訂摘要。
public IReadOnlyList<OdfSpreadsheetTrackedChangeInfo> GetTrackedChanges()
Returns
- IReadOnlyList<OdfSpreadsheetTrackedChangeInfo>
The list of tracked changes. / 追蹤修訂清單。
GetUsedRange(string)
Gets the used range of the specified worksheet. 取得指定工作表的已使用範圍。
public OdfCellRange? GetUsedRange(string sheetName)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
Returns
- OdfCellRange?
The used range, or null when the sheet is empty. / 已使用範圍;工作表為空時傳回 null。
InsertChartFromRange(string, OdfCellAddress, OdfCellRange)
Short overload of InsertChartFromRange that accepts sheetName, anchor, and range; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 sheetName、anchor 與 range;其餘可選參數使用預設值並轉呼叫最長 InsertChartFromRange 多載。
public OdfChartDocument InsertChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range)
Parameters
sheetNamestringanchorOdfCellAddressrangeOdfCellRange
Returns
InsertChartFromRange(string, OdfCellAddress, OdfCellRange, OdfEmbeddedChartOptions?)
Inserts an editable embedded chart bound to a worksheet range. 插入繫結至工作表範圍且可繼續編輯的嵌入圖表。
public OdfChartDocument InsertChartFromRange(string sheetName, OdfCellAddress anchor, OdfCellRange range, OdfEmbeddedChartOptions? options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
anchorOdfCellAddressThe top-left anchor cell. / 左上角錨定儲存格。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
optionsOdfEmbeddedChartOptionsThe embedded chart options. / 嵌入圖表選項。
Returns
- OdfChartDocument
The embedded chart document. / 嵌入的圖表文件。
Load(Stream)
Loads an ODS spreadsheet document from the specified stream. 從指定資料流載入 ODS 試算表文件。
public static SpreadsheetDocument Load(Stream stream)
Parameters
streamStream
Returns
- SpreadsheetDocument
The loaded SpreadsheetDocument instance. / 載入完成的 SpreadsheetDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODS spreadsheet. / 當指定文件不是 ODS 試算表時擲出。
Load(Stream, string?)
Short overload of Load that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 Load 多載。
public static SpreadsheetDocument Load(Stream stream, string? fileName)
Parameters
Returns
Load(string)
Loads an ODS spreadsheet document from the specified path. 從指定路徑載入 ODS 試算表文件。
public static SpreadsheetDocument Load(string path)
Parameters
pathstringThe ODS document path. / ODS 文件路徑。
Returns
- SpreadsheetDocument
The loaded SpreadsheetDocument instance. / 載入完成的 SpreadsheetDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODS spreadsheet. / 當指定文件不是 ODS 試算表時擲出。
LoadAsync(Stream)
Asynchronously loads an ODS spreadsheet document from the specified stream. 非同步從指定資料流載入 ODS 試算表文件。
public static Task<SpreadsheetDocument> LoadAsync(Stream stream)
Parameters
streamStream
Returns
- Task<SpreadsheetDocument>
A task representing the asynchronous load operation, whose result is the loaded SpreadsheetDocument. / 代表非同步載入作業的工作,其結果為載入完成的 SpreadsheetDocument。
LoadAsync(Stream, string?)
Short overload of LoadAsync that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<SpreadsheetDocument> LoadAsync(Stream stream, string? fileName)
Parameters
Returns
LoadAsync(Stream, string?, CancellationToken)
Short overload of LoadAsync that accepts stream, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<SpreadsheetDocument> LoadAsync(Stream stream, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamfileNamestringcancellationTokenCancellationToken
Returns
LoadAsync(Stream, CancellationToken)
Asynchronously loads the document from a stream with a cancellation token. 以取消語彙基元非同步從資料流載入文件。
public static Task<SpreadsheetDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe document stream. / 文件資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<SpreadsheetDocument>
A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的文件。
LoadAsync(string)
Asynchronously loads an ODS spreadsheet document from the specified path. 非同步從指定路徑載入 ODS 試算表文件。
public static Task<SpreadsheetDocument> LoadAsync(string path)
Parameters
pathstring
Returns
- Task<SpreadsheetDocument>
A task representing the asynchronous load operation, whose result is the loaded SpreadsheetDocument. / 代表非同步載入作業的工作,其結果為載入完成的 SpreadsheetDocument。
Remarks
若 已請求取消,作業會立即以 OperationCanceledException 結束; 否則會在 ZIP 解壓與封裝初始化期間協作檢查取消語彙。
LoadAsync(string, CancellationToken)
Short overload of LoadAsync that accepts path and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<SpreadsheetDocument> LoadAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringcancellationTokenCancellationToken
Returns
MergeContentNodes(OdfDocument, OdfMergeOptions, Dictionary<string, string>)
Merges content nodes from the source document. 合併來源文件的內容節點。
protected override void MergeContentNodes(OdfDocument sourceDoc, OdfMergeOptions options, Dictionary<string, string> renameMap)
Parameters
sourceDocOdfDocumentThe value to use. / 來源文件
optionsOdfMergeOptionsThe value to use. / 合併選項
renameMapDictionary<string, string>The name or identifier. / 重命名對照表
Exceptions
- ArgumentException
Thrown when the documented condition occurs. / 當來源文件類型不正確時擲出
ProtectWorkbook(string)
Enables workbook protection and stores the hashed protection password. 啟用活頁簿保護,並設定雜湊後的保護密碼。
public void ProtectWorkbook(string password)
Parameters
passwordstringThe password text. / 密碼明文
ReadObjects<T>(string, OdfCellRange)
Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。
public IReadOnlyList<T> ReadObjects<T>(string sheetName, OdfCellRange range) where T : new()
Parameters
sheetNamestringrangeOdfCellRange
Returns
Type Parameters
T
ReadObjects<T>(string, OdfCellRange, OdfObjectReadOptions?)
Reads rows from the specified worksheet into objects using the header row as the property map. 使用標題列作為屬性對應,將指定工作表資料列讀成物件。
public IReadOnlyList<T> ReadObjects<T>(string sheetName, OdfCellRange range, OdfObjectReadOptions? options) where T : new()
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
optionsOdfObjectReadOptionsThe object read options. / 物件讀取選項。
Returns
- IReadOnlyList<T>
The materialized object list. / 具體化後的物件清單。
Type Parameters
TThe object type to create. / 要建立的物件型別。
RefreshChartDataRange(OdfChartDocument, string, OdfCellRange)
Short overload of RefreshChartDataRange that accepts chart, sheetName, and range; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 chart、sheetName 與 range;其餘可選參數使用預設值並轉呼叫最長 RefreshChartDataRange 多載。
public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range)
Parameters
chartOdfChartDocumentsheetNamestringrangeOdfCellRange
Returns
RefreshChartDataRange(OdfChartDocument, string, OdfCellRange, bool)
Short overload of RefreshChartDataRange that accepts chart, sheetName, range, and firstRowAsHeader; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 chart、sheetName、range 與 firstRowAsHeader;其餘可選參數使用預設值並轉呼叫最長 RefreshChartDataRange 多載。
public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range, bool firstRowAsHeader)
Parameters
chartOdfChartDocumentsheetNamestringrangeOdfCellRangefirstRowAsHeaderbool
Returns
RefreshChartDataRange(OdfChartDocument, string, OdfCellRange, bool, bool)
Refreshes an embedded chart data range. 重新設定嵌入圖表的資料範圍。
public OdfChartDocument RefreshChartDataRange(OdfChartDocument chart, string sheetName, OdfCellRange range, bool firstRowAsHeader, bool firstColumnAsLabel)
Parameters
chartOdfChartDocumentThe embedded chart document. / 嵌入圖表文件。
sheetNamestringThe worksheet name. / 工作表名稱。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
firstRowAsHeaderboolWhether the first row is treated as series labels. / 首列是否視為序列標籤。
firstColumnAsLabelboolWhether the first column is treated as category labels. / 首欄是否視為分類標籤。
Returns
- OdfChartDocument
The updated embedded chart document. / 已更新的嵌入圖表文件。
RejectAllChanges()
Rejects all pending tracked changes. 拒絕所有待處理的追蹤修訂。
public void RejectAllChanges()
RejectChange(string)
Rejects the specified tracked change. 拒絕指定的追蹤修訂。
public void RejectChange(string changeId)
Parameters
changeIdstringThe change identifier. / 修訂識別碼。
ReplaceFormulaText(string, string)
Short overload of ReplaceFormulaText that accepts oldValue and newValue; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 oldValue 與 newValue;其餘可選參數使用預設值並轉呼叫最長 ReplaceFormulaText 多載。
public int ReplaceFormulaText(string oldValue, string newValue)
Parameters
Returns
ReplaceFormulaText(string, string, StringComparison)
Replaces the specified text in all formulas in the workbook. 取代活頁簿所有公式中的指定文字。
public int ReplaceFormulaText(string oldValue, string newValue, StringComparison comparisonType)
Parameters
oldValuestringThe value to use. / 要尋找的文字
newValuestringThe value to use. / 替換後的文字
comparisonTypeStringComparisonThe value to use. / 文字比對方式
Returns
- int
The result. / 實際變更的公式數量
ResizeTable(string, OdfCellRange)
Resizes a practical spreadsheet table by name. 依名稱調整實務試算表表格範圍。
public bool ResizeTable(string name, OdfCellRange range)
Parameters
namestringThe table name. / 表格名稱。
rangeOdfCellRangeThe new cell range. / 新儲存格範圍。
Returns
SetFormula(string, string, string)
Sets the formula for a cell in the specified worksheet. 設定指定工作表儲存格的公式。
public OdfCell SetFormula(string sheetName, string address, string formula)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
addressstringThe cell address. / 儲存格位址,例如
A1formulastringThe value to use. / 要寫入的公式;傳入空字串會清除公式
Returns
- OdfCell
The result. / 已更新的儲存格 facade
SetFormula(string, string, string, object?)
Sets the formula and cached value for a cell in the specified worksheet. 設定指定工作表儲存格的公式與快取值。
public OdfCell SetFormula(string sheetName, string address, string formula, object? cachedValue)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
addressstringThe cell address. / 儲存格位址,例如
A1。formulastringThe ODF formula text; an empty value clears the formula. / ODF 公式文字;空值會清除公式。
cachedValueobjectThe cached value stored with the formula. / 隨公式儲存的快取值。
Returns
- OdfCell
The updated cell facade. / 已更新的儲存格 facade。
SetValues(string, OdfCellAddress, IEnumerable<IEnumerable<object?>>)
Sets rows of values in the specified worksheet. 在指定工作表逐列設定資料。
public OdfCellRange SetValues(string sheetName, OdfCellAddress startAddress, IEnumerable<IEnumerable<object?>> rows)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
startAddressOdfCellAddressThe top-left target cell. / 左上角目標儲存格。
rowsIEnumerable<IEnumerable<object>>The row values to write. / 要寫入的資料列。
Returns
- OdfCellRange
The updated range. / 已更新的範圍。
SetValues(string, OdfCellAddress, IEnumerable<IEnumerable<object?>>, OdfRangeWriteOptions?)
Sets rows of values in the specified worksheet and returns a write report. 在指定工作表逐列設定資料並傳回寫入報告。
public OdfRangeWriteReport SetValues(string sheetName, OdfCellAddress startAddress, IEnumerable<IEnumerable<object?>> rows, OdfRangeWriteOptions? options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
startAddressOdfCellAddressThe top-left target cell. / 左上角目標儲存格。
rowsIEnumerable<IEnumerable<object>>The row values to write. / 要寫入的資料列。
optionsOdfRangeWriteOptionsThe range write options. / 範圍寫入選項。
Returns
- OdfRangeWriteReport
The range write report. / 範圍寫入報告。
SetValues(string, OdfCellAddress, object?[,])
Sets a rectangular block of values in the specified worksheet. 在指定工作表設定一個矩形資料區塊。
public OdfCellRange SetValues(string sheetName, OdfCellAddress startAddress, object?[,] values)
Parameters
sheetNamestringstartAddressOdfCellAddressvaluesobject[,]
Returns
- OdfCellRange
The updated range. / 已更新的範圍。
SetValues(string, OdfCellAddress, object?[,], OdfRangeWriteOptions?)
Sets a rectangular block of values in the specified worksheet and returns a write report. 在指定工作表設定矩形資料區塊並傳回寫入報告。
public OdfRangeWriteReport SetValues(string sheetName, OdfCellAddress startAddress, object?[,] values, OdfRangeWriteOptions? options)
Parameters
sheetNamestringstartAddressOdfCellAddressvaluesobject[,]optionsOdfRangeWriteOptions
Returns
- OdfRangeWriteReport
The range write report. / 範圍寫入報告。
TryGetFormula(string, string, out string)
Attempts to get the formula for a cell in the specified worksheet. 嘗試取得指定工作表儲存格的公式。
public bool TryGetFormula(string sheetName, string address, out string formula)
Parameters
sheetNamestringThe name or identifier. / 工作表名稱
addressstringThe cell address. / 儲存格位址,例如
A1formulastringThe value to use. / 取得成功時傳回公式文字
Returns
UpdateEmbeddedChartSeries(OdfChartDocument, IEnumerable<OdfEmbeddedChartSeriesUpdate>)
Applies practical updates to embedded chart series. 將實務更新套用至嵌入圖表序列。
public OdfBatchUpdateResult UpdateEmbeddedChartSeries(OdfChartDocument chart, IEnumerable<OdfEmbeddedChartSeriesUpdate> updates)
Parameters
chartOdfChartDocumentThe embedded chart document. / 嵌入圖表文件。
updatesIEnumerable<OdfEmbeddedChartSeriesUpdate>The series updates. / 序列更新。
Returns
- OdfBatchUpdateResult
The batch update result. / 批次更新結果。
UpdateFormulas(Func<OdfFormulaCellInfo, string?>)
Updates all formulas in the workbook. 更新活頁簿中的所有公式。
public int UpdateFormulas(Func<OdfFormulaCellInfo, string?> updater)
Parameters
updaterFunc<OdfFormulaCellInfo, string>The delegate to invoke. / 接收目前公式資訊並傳回新公式的委派;傳回 null 表示不變更
Returns
- int
The result. / 實際變更的公式數量
UpdateObjects<T>(string, OdfCellRange, IEnumerable<T>, OdfObjectUpdateOptions)
Updates existing object-bound rows by key without inserting new rows. 依 key 更新既有物件繫結資料列且不新增資料列。
public OdfObjectBindingReport UpdateObjects<T>(string sheetName, OdfCellRange range, IEnumerable<T> items, OdfObjectUpdateOptions options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rangeOdfCellRangeThe target table range. / 目標資料表範圍。
itemsIEnumerable<T>The object sequence to update. / 要更新的物件序列。
optionsOdfObjectUpdateOptionsThe update options. / 更新選項。
Returns
- OdfObjectBindingReport
The object binding report. / 物件繫結報告。
Type Parameters
TThe object type to update. / 要更新的物件型別。
UpsertObjects<T>(string, OdfCellRange, IEnumerable<T>, OdfObjectUpdateOptions)
Updates object-bound rows by key and inserts rows for missing keys. 依 key 更新物件繫結資料列,並針對缺少的 key 新增資料列。
public OdfObjectBindingReport UpsertObjects<T>(string sheetName, OdfCellRange range, IEnumerable<T> items, OdfObjectUpdateOptions options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rangeOdfCellRangeThe target table range. / 目標資料表範圍。
itemsIEnumerable<T>The object sequence to upsert. / 要 upsert 的物件序列。
optionsOdfObjectUpdateOptionsThe update options. / 更新選項。
Returns
- OdfObjectBindingReport
The object binding report. / 物件繫結報告。
Type Parameters
TThe object type to upsert. / 要 upsert 的物件型別。
ValidateObjectBinding<T>(string, OdfCellRange)
Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。
public OdfObjectBindingValidationReport ValidateObjectBinding<T>(string sheetName, OdfCellRange range) where T : new()
Parameters
sheetNamestringrangeOdfCellRange
Returns
Type Parameters
T
ValidateObjectBinding<T>(string, OdfCellRange, OdfObjectReadOptions?)
Validates whether a worksheet range can be bound to the specified object type. 驗證工作表範圍是否可繫結至指定物件型別。
public OdfObjectBindingValidationReport ValidateObjectBinding<T>(string sheetName, OdfCellRange range, OdfObjectReadOptions? options) where T : new()
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
rangeOdfCellRangeThe source cell range. / 來源儲存格範圍。
optionsOdfObjectReadOptionsThe validation options. / 驗證選項。
Returns
- OdfObjectBindingValidationReport
The validation report. / 驗證報告。
Type Parameters
TThe object type to validate. / 要驗證的物件型別。
VerifyWorkbookPassword(string)
Verifies whether the specified workbook password is valid. 驗證指定的活頁簿密碼是否正確。
public bool VerifyWorkbookPassword(string password)
Parameters
passwordstringThe password text. / 要驗證的密碼
Returns
- bool
The result. / 若驗證成功則為 true,否則為 false
WriteObjects<T>(string, OdfCellAddress, IEnumerable<T>)
Convenience overload that uses default values for remaining parameters. 便利多載:其餘參數使用預設值並轉呼叫最長多載。
public OdfObjectBindingReport WriteObjects<T>(string sheetName, OdfCellAddress startAddress, IEnumerable<T> items)
Parameters
sheetNamestringstartAddressOdfCellAddressitemsIEnumerable<T>
Returns
Type Parameters
T
WriteObjects<T>(string, OdfCellAddress, IEnumerable<T>, OdfObjectBindingOptions?)
Writes public readable object properties into the specified worksheet. 將物件的可讀公開屬性寫入指定工作表。
public OdfObjectBindingReport WriteObjects<T>(string sheetName, OdfCellAddress startAddress, IEnumerable<T> items, OdfObjectBindingOptions? options)
Parameters
sheetNamestringThe worksheet name. / 工作表名稱。
startAddressOdfCellAddressThe top-left target cell. / 左上角目標儲存格。
itemsIEnumerable<T>The object sequence to write. / 要寫入的物件序列。
optionsOdfObjectBindingOptionsThe object binding options. / 物件繫結選項。
Returns
- OdfObjectBindingReport
The object binding report. / 物件繫結報告。
Type Parameters
TThe object type to write. / 要寫入的物件型別。