Skip to content

Python API ​

Python パッケージは、formulon_capi.wasm にコンパイルされた Formulon C ABI を呼ぶ Python 向けラッパーです。公開 wheel は py3-none-any 形式で、pip が実行環境に合う wasmtime wheel をインストールします。

用語: py3-none-any wheel

Python ABI タグ・プラットフォームタグ・ネイティブコードのいずれも持たない wheel。互換する wasmtime wheel が利用できる CPython 3.9 以降で動作します。プラットフォーム依存部分は wasmtime が担い、formulon 自体には含まれません。

トップレベル API ​

モジュール関数(formulon.eval_formula、formulon.error_display_name、formulon.merge_function_metadata、formulon.library_version、その別名の formulon.version_string、formulon.set_log_min_level)は、ワークブックのメソッドと一緒に 関数とメソッド に載せています。formulon.__version__ はインストール済みパッケージのバージョンです。set_log_min_level() はプロセス全体に効きます。既定の LogLevel.OFF では何も出力せず、WARN 以下にすると 1 行 1 件の JSON を stderr に書きます。Python にはログの受け取り先を渡すコールバックはありません。主な型は、ワークブックのハンドル Workbook、セル値のレコード Value とその種類を表す enum ValueKind、ホスト側の失敗を表す例外 FormulonError です。

パッケージは、ワークブックのメソッドが使う enum とデータクラスのレコード(Cell、Comment、ConditionalFormat、DataValidation、PaginationResult、PivotLayout、Theme など。一覧は formulon.__all__)も公開します。

分野enum
値ErrorCode(NULL = 0、DIV0 = 1、… UNKNOWN = 16)
寸法と表示GeometryMode(DISPLAY = 0、PRINT = 1)、DisplayStatus(OK = 0、OVERFLOW = 1、INVALID_FORMAT = 2)
AutoFilterFilterKind、FilterOperator、DynamicFilterType、SortBy、SortMethod、DateTimeGrouping
入力規則ValidationErrorStyle(STOP = 0、WARNING = 1、INFORMATION = 2)
テーマとスタイルColorContext、ColorResolution、ThemeSource、EffectiveStyleSource
画像と描画ImageFormat、DrawingObjectKind、AnchorKind、AnchorEditAs
ピボットテーブルPivotAxis、PivotAggregation、PivotShowValuesAs、PivotFilterType、PivotFilterValueKind、PivotDateGrouping、PivotCalendar、PivotReportLayout、PivotCellKind
テキスト照合CollationStrength(COMPARE = 0、DYNAMIC = 1、CLASSIC_EXACT = 2)
ワークブック状態CalcMode、SheetVisibility、WorkbookFormat、ExternalLinkKind
ログLogLevel(DEBUG = 0、INFO = 1、WARN = 2、ERROR = 3、OFF = 4)

関数カタログは役割ごとに分かれています。Workbook.function_metadata(name) は正規名、引数数、利用可能性などの構造フィールドだけを返し、人間向けのシグネチャと説明は None です。Excel の表示名と数式テキストはプロファイル単位のヘルパーで変換し、説明文の翻訳はホスト側の BCP-47 UI ロケールを指定して merge_function_metadata() に渡してください。

Workbook クラス ​

python
from formulon import Workbook

with Workbook.create_default() as wb:
    wb.set_formula(0, 0, 0, "=SUM(1,2,3)")
    wb.recalc()
    print(wb.get_value(0, 0, 0).to_python())

create_default() は Calibri 11 を含む通常の 1 シートワークブックを作成します。create_for_profile(profile_id) は選択したプロファイルを記録し、本文用フォントと必要なロケールのふりがな用フォント、ローカライズされた Normal スタイルと最初のシート名、セル XF の配置、ふりがな設定、ページ余白、Mac の行の高さと基本列幅を設定します。テーマパートは書き出さないため、新しいワークブックは既定の Office テーマとして読み取られます。Windows の行と列の寸法はエンジンの既定値を使います。

プロファイルと数式テキストのヘルパーは、ワークブックに依存しない静的メソッドです。

python
from formulon import Workbook

profile = "mac-365-de_DE"
shown = Workbook.localize_formula("=SUM(1.5,TRUE)", profile)
stored = Workbook.canonicalize_formula(shown, profile)
facts = Workbook.locale_facts(profile)
print(shown, stored, facts.decimal_separator, facts.true_name)

localize_function_name() / canonicalize_function_name() は 1 つの関数名を変換します。localize_formula() は関数名、リスト / 配列区切り、小数点、真偽値名、エラー名を変換し、文字列、引用符付きシート名、外部修飾子、構造化参照の角括弧を保持します。canonicalize_formula() はこの変換を戻します。これらは数値ロケールコードではなく完全なプロファイル ID を受け取り、数式の検証や登録は行いません。プロファイルは 28 個あり、ロケール情報はすべての mac-* と win-365-ja_JP で Excel の実測値、残り 13 個の Windows プロファイルは推定値です。LocaleFacts.collation_measured は別の項目で、テキスト照合の実測値を持つのは mac-* だけです。

Workbook.compare_text(a, b, strength, profile_id) は -1、0、1 のいずれかを返します。Workbook.collation_classes(values, strength, profile_id) は CollationClasses(class_ids, class_count) を返します。ID は Value ごとに 1 つ、SORT の順序で昇順に振られ、その呼び出しの中だけで意味を持ちます。CollationStrength ごとの比較規則とクラスの規則は テキスト照合 を参照してください。

python
from formulon import CollationStrength, Value, ValueKind, Workbook

profile = "mac-365-en_US"
order = Workbook.compare_text("a", "b", CollationStrength.COMPARE, profile)
values = [Value(kind=ValueKind.TEXT, text="A"), Value(kind=ValueKind.TEXT, text="a")]
classes = Workbook.collation_classes(values, CollationStrength.DYNAMIC, profile)
print(order, classes.class_ids, classes.class_count)

関数とメソッド ​

パッケージの type stub(formulon/__init__.pyi)と formulon ソースの docstring から生成した一覧です。formulon. で始まる名前はモジュール関数、Workbook. で始まる名前はクラスメソッドまたは静的メソッドで、それ以外はすべて Workbook インスタンスのメソッドです。is_valid はプロパティです。= ... は stub と同じく既定値のある引数を表します。説明列は docstring の最初の 1 文で、API 自身の英語のテキストをそのまま載せています。Workbook はコンテキストマネージャーでもあり、with ブロックを抜けると close() が呼ばれます。

参照元

この一覧は、ドキュメント対象 0.18.0 のコアソースから生成しています。取得元のコミットを固定し、WASM・Python・C の宣言を同じリビジョンで照合しています。デモは公開済みパッケージを使い、実行バージョンを別に表示します。

ライブラリ、診断、ログ ​

名前シグネチャ説明
formulon.library_versionlibrary_version() -> strReturn the version string baked into the loaded WASM module.
formulon.version_stringversion_string() -> strAlias of library_version().
formulon.error_display_nameerror_display_name(error_code: int) -> strReturn an Excel literal such as "#DIV/0!" for an error code.
formulon.set_log_min_levelset_log_min_level(level: Union[LogLevel, int]) -> NoneSet the engine's minimum structured-log severity.

ワークブックのライフサイクルと入出力 ​

名前シグネチャ説明
Workbook.create_defaultcreate_default() -> WorkbookBuild a default workbook (a single sheet named Sheet1).
Workbook.create_for_profilecreate_for_profile(profile_id: str) -> WorkbookBuild a new workbook with the defaults of an Excel profile.
Workbook.create_emptycreate_empty() -> WorkbookBuild an empty workbook (no sheets).
Workbook.loadload(data: Union[bytes, bytearray, memoryview]) -> WorkbookLoad a workbook from an in-memory byte buffer.
closeclose() -> NoneRelease the underlying handle.
is_validis_valid: boolTrue while the handle is still alive.
memory_usagememory_usage() -> intReturn an estimate of the workbook's heap footprint, in bytes.
savesave() -> bytesSerialise the workbook to an in-memory .xlsx byte stream.
save_assave_as(fmt: Union[WorkbookFormat, int]) -> bytesSerialise the workbook to an in-memory byte stream in fmt.
save_with_diagnosticssave_with_diagnostics(fmt: Union[WorkbookFormat, int]) -> SaveDiagnosticsSerialise the workbook and return what the save cost.
read_diagnosticsread_diagnostics() -> ReadDiagnosticsReturn the loss counters captured when this workbook was loaded.
iter_passthroughiter_passthrough() -> Iterator[PassthroughPart]Iterate over passthrough OOXML part paths.

シートと構造 ​

名前シグネチャ説明
sheet_countsheet_count() -> intNumber of sheets in the workbook.
active_sheetactive_sheet() -> intIndex of the active sheet (activeTab of the first workbook view).
set_active_sheetset_active_sheet(index: int) -> NoneMark the sheet at index active so save records it.
sheet_namesheet_name(index: int) -> strDisplay name (UTF-8) of the sheet at index.
add_sheetadd_sheet(name: str) -> NoneAppend a new sheet with the given UTF-8 display name.
move_sheetmove_sheet(from_index: int, to_index: int) -> NoneMove the sheet at from_index to to_index (post-removal).
remove_sheetremove_sheet(index: int) -> NoneRemove the sheet at index.
rename_sheetrename_sheet(index: int, new_name: str) -> NoneRename the sheet at index to new_name.
insert_rowsinsert_rows(sheet: int, row: int, count: int) -> NoneInsert count rows at row on sheet.
delete_rowsdelete_rows(sheet: int, row: int, count: int) -> NoneDelete count rows starting at row on sheet.
insert_colsinsert_cols(sheet: int, col: int, count: int) -> NoneInsert count columns at col on sheet.
delete_colsdelete_cols(sheet: int, col: int, count: int) -> NoneDelete count columns starting at col on sheet.

セル ​

名前シグネチャ説明
set_numberset_number(sheet: int, row: int, col: int, value: float) -> NoneStore the number value at (sheet, row, col).
set_boolset_bool(sheet: int, row: int, col: int, value: bool) -> NoneStore the boolean value at (sheet, row, col).
set_errorset_error(sheet: int, row: int, col: int, error_code: int) -> NoneStore an Excel cell error at (sheet, row, col).
set_textset_text(sheet: int, row: int, col: int, value: str) -> NoneStore the string value at (sheet, row, col).
set_blankset_blank(sheet: int, row: int, col: int) -> NoneClear the cell at (sheet, row, col).
set_formulaset_formula(sheet: int, row: int, col: int, formula: str) -> NoneStore the formula formula at (sheet, row, col).
set_phoneticset_phonetic(sheet: int, row: int, col: int, text: str) -> NoneSet the cell's phonetic guide (OOXML <rPh>, furigana).
set_phonetic_runsset_phonetic_runs(sheet: int, row: int, col: int, runs: Sequence[PhoneticRun]) -> NoneSet the cell's phonetic guide as one <rPh> block per run.
get_phoneticget_phonetic(sheet: int, row: int, col: int) -> strReturn the cell's phonetic guide, or "" when it has none.
get_phonetic_runsget_phonetic_runs(sheet: int, row: int, col: int) -> List[PhoneticRun]Return the cell's <rPh> blocks, spans included.
set_phonetic_propertiesset_phonetic_properties(sheet: int, row: int, col: int, properties: PhoneticProperties) -> NoneSet how the cell's phonetic guide renders.
get_phonetic_propertiesget_phonetic_properties(sheet: int, row: int, col: int) -> PhoneticPropertiesReturn how the cell's phonetic guide renders.
has_phonetic_propertieshas_phonetic_properties(sheet: int, row: int, col: int) -> boolWhether the cell's phonetic properties are explicit.
get_valueget_value(sheet: int, row: int, col: int) -> ValueRead the cached value at (sheet, row, col).
lambda_text_atlambda_text_at(sheet: int, row: int, col: int) -> strRender the lambda cached at (sheet, row, col) as text.
iter_cellsiter_cells(sheet: int) -> Iterator[Cell]Iterate over every written coordinate on sheet.
get_formulaget_formula(sheet: int, row: int, col: int) -> Optional[str]Return the stored A1 formula (leading = included), or None for a non-formula cell.
get_formula_r1c1get_formula_r1c1(sheet: int, row: int, col: int) -> Optional[str]Return the formula in R1C1 notation relative to the cell, or None for a non-formula cell.
get_cells_in_rangeget_cells_in_range(sheet: int, cell_range: MergeRange, cursor: Optional[int] = ..., limit: Optional[int] = ...) -> Tuple[List[Cell], Optional[int]]Return one page of the populated cells in cell_range (row-major).

再計算 ​

名前シグネチャ説明
recalcrecalc() -> NoneDrive a full incremental recalc.
set_iterativeset_iterative(enabled: bool, max_iterations: int, max_change: float) -> NoneConfigure iterative calculation.
set_iterative_enabledset_iterative_enabled(enabled: bool) -> NoneToggle iterative calculation, keeping the cap and threshold.
get_iterativeget_iterative() -> IterativeSettingsRead back the iterative-calculation settings.
partial_recalcpartial_recalc(sheet: int, first_row: int, last_row: int, first_col: int, last_col: int) -> intRecalc the dependency closure for a viewport; return cell count.
calc_modecalc_mode() -> CalcModeReturn the workbook's calc mode (round-trip metadata).
full_precisionfull_precision() -> boolReturn <calcPr fullPrecision>; false is "set precision as displayed" (metadata only).
set_full_precisionset_full_precision(full_precision: bool) -> NoneSet <calcPr fullPrecision>.
calc_on_savecalc_on_save() -> boolReturn <calcPr calcOnSave> (default true).
set_calc_on_saveset_calc_on_save(calc_on_save: bool) -> NoneSet <calcPr calcOnSave>.
ref_moderef_mode() -> RefModeReturn <calcPr refMode>: the reference notation formulas are shown in.
set_ref_modeset_ref_mode(mode: Union[RefMode, int]) -> NoneSet <calcPr refMode>.
date1904date1904() -> boolReturn whether the workbook uses the 1904 date system.
set_date1904set_date1904(date1904: bool) -> NoneSwitch the date system.
set_calc_modeset_calc_mode(mode: Union[CalcMode, int]) -> NoneSet the workbook's calc mode.
pinned_nowpinned_now() -> Optional[CivilTime]Return the pinned wall-clock reading, or None when the
set_pinned_nowset_pinned_now(year: int, month: int, day: int, hour: int = ..., minute: int = ..., second: int = ...) -> NonePin every clock-dependent result to one instant.
clear_pinned_nowclear_pinned_now() -> NoneRelease the pin so clock-dependent results follow the host clock
add_data_tableadd_data_table(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int, *, row_input: Optional[Tuple[int, int]] = ..., col_input: Optional[Tuple[int, int]] = ...) -> NoneCreate a data table whose result range is first_row..last_col (0-based, inclusive).
get_data_tableget_data_table(sheet: int, row: int, col: int) -> Optional[DataTable]Return the data table whose result range contains (row, col), or None.
remove_data_tableremove_data_table(sheet: int, row: int, col: int) -> NoneRemove the data table containing (row, col) and blank its result cells.
recalc_data_tablesrecalc_data_tables() -> NoneRecompute every data table now, whatever the calc mode (the explicit calculation of AUTO_NO_TABLE).

読み取り専用の評価 ​

名前シグネチャ説明
evaluate_formula_arrayevaluate_formula_array(sheet: int, row: int, col: int, formula: str) -> List[List[Value]]Evaluate formula as if entered at (sheet, row, col) and
evaluate_cf_formulaevaluate_cf_formula(sheet: int, row: int, col: int, anchor_row: int, anchor_col: int, formula: str) -> boolEvaluate a conditional-format formula at one cell without mutation.
formulon.eval_formulaeval_formula(formula: str) -> ValueEvaluate a single formula against a fresh, default workbook.

プロファイル、ロケール、テキスト ​

名前シグネチャ説明
formulon.merge_function_metadatamerge_function_metadata(base: FunctionMetadata, entry: Optional[Mapping[str, object]], locale: str) -> Union[FunctionMetadata, MergedFunctionMetadata]Merge a host-supplied entry over the engine result base.
excel_profile_idexcel_profile_id() -> ExcelProfileIdReturn the active Excel formula profile id.
set_excel_profile_idset_excel_profile_id(profile_id: ExcelProfileId) -> NoneSet the workbook's Excel formula profile by id.
Workbook.function_countfunction_count() -> intReturn the total number of registered Formulon functions.
Workbook.function_name_atfunction_name_at(index: int) -> strReturn the canonical name of the index-th function.
Workbook.function_metadatafunction_metadata(name: str) -> Optional[FunctionMetadata]Return metadata for name or None when unknown.
Workbook.localize_function_namelocalize_function_name(canonical_name: str, profile_id: ExcelProfileId) -> strReturn the display name of canonical_name under profile_id.
Workbook.canonicalize_function_namecanonicalize_function_name(localized_name: str, profile_id: ExcelProfileId) -> strReturn the canonical English name for localized_name under profile_id.
Workbook.localize_formulalocalize_formula(formula: str, profile_id: ExcelProfileId) -> strRewrite stored (en-invariant) formula text into profile_id's spelling.
Workbook.canonicalize_formulacanonicalize_formula(formula: str, profile_id: ExcelProfileId) -> strRewrite profile_id-spelled formula text into the en-invariant form.
Workbook.locale_factslocale_facts(profile_id: ExcelProfileId) -> LocaleFactsReturn the locale facts (separators, names, currency, error names) of profile_id.
Workbook.compare_textcompare_text(a: str, b: str, strength: CollationStrength, profile_id: ExcelProfileId) -> intCompare two texts under the collation of profile_id.
Workbook.collation_classescollation_classes(values: Sequence[Value], strength: CollationStrength, profile_id: ExcelProfileId) -> CollationClassesClassify values into collation-ordered equivalence classes.

定義名 ​

名前シグネチャ説明
set_defined_nameset_defined_name(name: str, formula: str) -> NoneSet, append, or remove a workbook-scoped defined name.
set_defined_name_scopedset_defined_name_scoped(name: str, formula: str, local_sheet_id: int) -> NoneSet, append, or remove a defined name in workbook or sheet scope.
set_defined_name_attrsset_defined_name_attrs(name: str, local_sheet_id: int = ..., *, comment: Optional[str] = ..., hidden: Optional[bool] = ...) -> NoneSet the comment and / or hidden attribute of an existing defined name.
iter_defined_namesiter_defined_names() -> Iterator[DefinedName]Iterate over every defined name in declaration order.

テーブル ​

名前シグネチャ説明
iter_tablesiter_tables() -> Iterator[Table]Iterate over every table in declaration order.
table_createtable_create(sheet: int, ref: str, name: str, display_name: str, column_names: Sequence[str], style_name: str = ..., header_row: bool = ..., totals_row: bool = ..., *, show_first_column: Optional[bool] = ..., show_last_column: Optional[bool] = ..., show_row_stripes: Optional[bool] = ..., show_column_stripes: Optional[bool] = ...) -> intCreate a worksheet table and return its index.
table_set_style_infotable_set_style_info(index: int, style_name: Optional[str], show_first_column: bool = ..., show_last_column: bool = ..., show_row_stripes: bool = ..., show_column_stripes: bool = ...) -> NoneSet the table's style name and toggles, making the style element present.
table_renametable_rename(index: int, name: str, display_name: Optional[str] = ...) -> NoneRename table index; display_name=None uses name for both.
table_set_column_totalstable_set_column_totals(index: int, column: int, function: Optional[str] = ..., label: Optional[str] = ..., formula: Optional[str] = ...) -> NoneSet column column's totals-row function and label.
table_updatetable_update(index: int, ref: str, style_name: Optional[str] = ..., header_row: Optional[bool] = ..., totals_row: Optional[bool] = ..., *, name: Optional[str] = ..., display_name: Optional[str] = ..., show_first_column: Optional[bool] = ..., show_last_column: Optional[bool] = ..., show_row_stripes: Optional[bool] = ..., show_column_stripes: Optional[bool] = ...) -> NoneReplace a table's range and optional visual style.
table_removetable_remove(index: int) -> NoneRemove the table at index.
table_style_counttable_style_count() -> intReturn the number of custom table / PivotTable styles.
get_table_styleget_table_style(index: int) -> TableStyleReturn the custom table style at index.
set_table_styleset_table_style(style: TableStyle) -> NoneAdd a custom table style, or replace the one with the same name.
remove_table_styleremove_table_style(name: str) -> NoneRemove the custom table style name.
table_style_defaultstable_style_defaults() -> Tuple[str, str]Return the default (table_style, pivot_style) names; empty when unset.
set_table_style_defaultsset_table_style_defaults(table_style: Optional[str] = ..., pivot_style: Optional[str] = ...) -> NoneSet the default style names; None keeps one, "" removes it.

依存関係、スピル、外部リンク ​

名前シグネチャ説明
precedentsprecedents(sheet: int, row: int, col: int, depth: int = ...) -> List[CellNode]Return the cells (sheet, row, col) reads (up to depth).
dependentsdependents(sheet: int, row: int, col: int, depth: int = ...) -> List[CellNode]Return the cells that read (sheet, row, col) (up to depth).
spill_infospill_info(sheet: int, row: int, col: int) -> SpillInfoReturn dynamic-array spill info for (sheet, row, col).
external_link_countexternal_link_count() -> intReturn the number of external-link records on the workbook.
get_external_link_atget_external_link_at(index: int) -> ExternalLinkRead the index-th external-link record.
get_external_linksget_external_links() -> List[ExternalLink]Return every external-link record in document order.

シートの表示と保護 ​

名前シグネチャ説明
get_show_phoneticget_show_phonetic(sheet: int, row: int, col: int) -> boolWhether the cell shows its phonetic guide (<c ph="1">).
set_show_phoneticset_show_phonetic(sheet: int, row: int, col: int, show: bool) -> NoneSet the cell's "Show Phonetic" display flag.
get_workbook_protectionget_workbook_protection() -> WorkbookProtectionRead the workbook's <workbookProtection>; every field is false, empty or zero when absent.
set_workbook_protectionset_workbook_protection(protection: WorkbookProtection) -> NoneReplace the modelled <workbookProtection> attributes; an all-empty record removes the element.
protected_range_countprotected_range_count(sheet: int) -> intReturn the number of protected ranges on sheet.
get_protected_rangesget_protected_ranges(sheet: int) -> List[ProtectedRange]Return the protected ranges of sheet in file order.
add_protected_rangeadd_protected_range(sheet: int, protected: ProtectedRange) -> NoneAppend a protected range; name must be non-empty and unique on the sheet.
update_protected_rangeupdate_protected_range(sheet: int, index: int, protected: ProtectedRange) -> NoneReplace the index-th protected range of sheet.
remove_protected_rangeremove_protected_range(sheet: int, index: int) -> NoneRemove the index-th protected range of sheet.
get_sheet_protectionget_sheet_protection(sheet: int) -> SheetProtectionRead the sheet's <sheetProtection> flags.
set_sheet_protectionset_sheet_protection(sheet: int, protection: SheetProtection) -> NoneReplace the sheet's <sheetProtection> flags wholesale.
get_sheet_viewget_sheet_view(sheet: int) -> SheetViewRead the full per-sheet view (zoom, freeze, tab-hidden, and the
set_sheet_zoomset_sheet_zoom(sheet: int, zoom_scale: int) -> NoneSet the sheet zoom percentage (clamped to [10, 400]).
set_sheet_freezeset_sheet_freeze(sheet: int, freeze_rows: int, freeze_cols: int) -> NoneSet the frozen pane in (rows, cols).
set_sheet_tab_hiddenset_sheet_tab_hidden(sheet: int, hidden: bool) -> NoneSet the sheet tab's hidden flag.
set_sheet_visibilityset_sheet_visibility(sheet: int, visibility: Union[SheetVisibility, int]) -> NoneSet the sheet tab's visibility to one of the three states.
set_sheet_show_grid_linesset_sheet_show_grid_lines(sheet: int, show: bool) -> NoneSet the sheet's showGridLines flag.
set_sheet_show_row_col_headersset_sheet_show_row_col_headers(sheet: int, show: bool) -> NoneSet the sheet's showRowColHeaders flag.
set_sheet_show_zerosset_sheet_show_zeros(sheet: int, show: bool) -> NoneSet the sheet's showZeros flag.
set_sheet_show_formulasset_sheet_show_formulas(sheet: int, show: bool) -> NoneSet the sheet's showFormulas flag.
set_sheet_show_outline_symbolsset_sheet_show_outline_symbols(sheet: int, show: bool) -> NoneSet the sheet's showOutlineSymbols flag.
set_sheet_right_to_leftset_sheet_right_to_left(sheet: int, right_to_left: bool) -> NoneSet the sheet's rightToLeft flag.
set_sheet_tab_selectedset_sheet_tab_selected(sheet: int, selected: bool) -> NoneSet the sheet's tabSelected flag.
set_sheet_top_leftset_sheet_top_left(sheet: int, row: int, col: int) -> NoneSet the sheet view's scroll origin (topLeftCell).
set_sheet_pane_top_leftset_sheet_pane_top_left(sheet: int, row: int, col: int) -> NoneSet the first visible cell of a frozen or split view's lower-right pane.
set_sheet_splitset_sheet_split(sheet: int, x_twips: float, y_twips: float) -> NoneSplit the view at x_twips / y_twips (0 for none on that axis).
get_sheet_selectionget_sheet_selection(sheet: int) -> Tuple[Tuple[int, int], List[MergeRange]]Return ((active_row, active_col), ranges) of the active pane's selection.
set_sheet_selectionset_sheet_selection(sheet: int, active_row: int, active_col: int, ranges: Sequence[MergeRange] = ...) -> NoneReplace the active pane's selection; no ranges selects the active cell alone.
set_sheet_view_modeset_sheet_view_mode(sheet: int, mode: str) -> NoneSet the sheet's <sheetView view="..."> mode: "",

行、列、ジオメトリ ​

名前シグネチャ説明
get_sheet_columnsget_sheet_columns(sheet: int) -> List[ColumnLayout]Return the column-layout overrides on sheet.
set_column_widthset_column_width(sheet: int, first: int, last: int, width: float) -> NoneSet the column width override on [first, last].
set_column_hiddenset_column_hidden(sheet: int, first: int, last: int, hidden: bool) -> NoneSet the column hidden flag on [first, last].
set_column_outlineset_column_outline(sheet: int, first: int, last: int, level: int) -> NoneSet the column outline level (0-7) on [first, last].
set_column_collapsedset_column_collapsed(sheet: int, first: int, last: int, collapsed: bool) -> NoneSet or clear the collapsed flag on the columns [first, last].
get_sheet_row_overridesget_sheet_row_overrides(sheet: int) -> List[RowLayout]Return the row-layout overrides on sheet.
set_row_heightset_row_height(sheet: int, row: int, height: float) -> NoneSet the row height override at row.
clear_row_heightclear_row_height(sheet: int, row: int) -> NoneRemove the height override at row (back to the sheet default).
set_column_styleset_column_style(sheet: int, first: int, last: int, xf_index: int) -> NoneSet the cell-style XF on [first, last], keeping the other column attributes.
clear_column_styleclear_column_style(sheet: int, first: int, last: int) -> NoneRemove the cell-style XF on [first, last], keeping the other column attributes.
set_row_styleset_row_style(sheet: int, first: int, last: int, xf_index: int) -> NoneSet the cell-style XF on the inclusive row span first..last, keeping the other row attributes.
clear_row_styleclear_row_style(sheet: int, first: int, last: int) -> NoneRemove the cell-style XF on the inclusive row span first..last, keeping the other row attributes.
clear_column_widthclear_column_width(sheet: int, first: int, last: int) -> NoneRemove the width override on [first, last] (back to the sheet default).
get_sheet_format_defaultsget_sheet_format_defaults(sheet: int) -> SheetFormatDefaultsRead the sheet's default column / row metrics (<sheetFormatPr>).
set_sheet_format_defaultsset_sheet_format_defaults(sheet: int, defaults: SheetFormatDefaults) -> NoneReplace the sheet's default column / row metrics; a None flag keeps the stored one.
get_cell_rect_ptget_cell_rect_pt(sheet: int, cell_range: MergeRange, mode: Union[GeometryMode, int] = ...) -> RectPtReturn the rectangle covering cell_range in points from the top-left of A1.
get_column_width_ptget_column_width_pt(sheet: int, col: int, mode: Union[GeometryMode, int] = ...) -> floatReturn the effective width of col in points (0 when hidden).
get_row_height_ptget_row_height_pt(sheet: int, row: int) -> floatReturn the effective height of row in points (0 when hidden).
get_width_modelget_width_model(sheet: int, mode: Union[GeometryMode, int] = ...) -> WidthModelReturn the character-unit to point conversion model in mode.
column_chars_to_ptcolumn_chars_to_pt(sheet: int, chars: float, mode: Union[GeometryMode, int] = ...) -> floatConvert a stored column width (padding included) to points, snapped to whole screen pixels.
column_pt_to_charscolumn_pt_to_chars(sheet: int, pt: float, mode: Union[GeometryMode, int] = ...) -> floatConvert points to the stored column width Excel writes for that column.
set_row_hiddenset_row_hidden(sheet: int, row: int, hidden: bool) -> NoneSet the row hidden flag at row.
set_row_outlineset_row_outline(sheet: int, row: int, level: int) -> NoneSet the row outline level (0-7) at row.
set_row_collapsedset_row_collapsed(sheet: int, row: int, collapsed: bool) -> NoneSet or clear the collapsed flag at row.

表示テキスト ​

名前シグネチャ説明
get_display_textget_display_text(sheet: int, row: int, col: int) -> Tuple[str, DisplayStatus]Return the text Excel displays for the cell and the rendering outcome.
format_valueformat_value(value: Value, format_code: str = ...) -> Tuple[str, DisplayStatus]Render value under the number format format_code (empty means General).

スタイル ​

名前シグネチャ説明
range_style_basesrange_style_bases(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int) -> List[int]List, ascending, every cell XF some cell of the selection resolves to.
remap_range_styleremap_range_style(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int, mapping: Dict[int, int]) -> NoneRemap the XFs of a selection: a cell resolving to key k ends at mapping[k].
snapshot_range_stylesnapshot_range_style(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int) -> bytesCapture the style state of a selection as opaque bytes for restore_range_style.
restore_range_stylerestore_range_style(sheet: int, data: Union[bytes, bytearray, memoryview]) -> NonePut a snapshot_range_style capture back on sheet.
get_cell_xf_indexget_cell_xf_index(sheet: int, row: int, col: int) -> intReturn the xf (style record) index attached to a cell.
set_cell_xf_indexset_cell_xf_index(sheet: int, row: int, col: int, xf_index: int) -> NoneStore xf_index on the cell at (row, col).
clear_cell_xf_indexclear_cell_xf_index(sheet: int, row: int, col: int) -> NoneRemove the direct style assignment from the cell at (row, col).
set_range_xf_indexset_range_xf_index(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int, xf_index: int) -> NoneStore xf_index on every cell in the inclusive rectangle.
get_cell_xfget_cell_xf(xf_index: int) -> CellXfReturn the resolved <xf> record at xf_index.
get_fontget_font(font_index: int) -> FontRecordReturn the font record at font_index.
get_fillget_fill(fill_index: int) -> FillRecordReturn the fill record at fill_index.
get_borderget_border(border_index: int) -> Dict[str, object]Return the border record at border_index.
get_dxfget_dxf(dxf_index: int) -> DifferentialFormatRead one differential format by its conditional-format dxfId.
get_num_fmtget_num_fmt(num_fmt_id: int) -> strReturn the format code registered for num_fmt_id.
font_countfont_count() -> intReturn the number of font records registered.
fill_countfill_count() -> intReturn the number of fill records registered.
border_countborder_count() -> intReturn the number of border records registered.
cell_xf_countcell_xf_count() -> intReturn the number of <xf> records registered.
cell_style_countcell_style_count() -> intReturn the number of named cell styles.
cell_style_xf_countcell_style_xf_count() -> intReturn the number of <cellStyleXfs> records.
dxf_countdxf_count() -> intReturn the number of differential formats available to CF rules.
add_fontadd_font(record: FontRecord) -> intAdd (dedup) a font record; return its index.
set_fontset_font(font_index: int, record: FontRecord) -> NoneOverwrite an existing font slot in place.
set_default_fontset_default_font(record: FontRecord) -> NoneDeclare the workbook's default font (font 0).
add_filladd_fill(record: FillRecord) -> intAdd (dedup) a fill record; return its index.
add_borderadd_border(sides: Dict[str, object]) -> intAdd (dedup) a border record; return its index.
add_num_fmtadd_num_fmt(format_code: str) -> intAdd (dedup) a number-format code; return its resolved id.
add_cell_xfadd_cell_xf(record: CellXf) -> intAdd (dedup) an <xf> record; return its index.
add_cell_style_xfadd_cell_style_xf(record: CellXf) -> intAdd (dedup) a named-style <xf>; return its <cellStyleXfs> id.
add_batchadd_batch(*, fonts: Optional[Sequence[FontRecord]] = ..., fills: Optional[Sequence[FillRecord]] = ..., borders: Optional[Sequence[Dict[str, object]]] = ..., num_fmts: Optional[Sequence[str]] = ..., cell_xfs: Optional[Sequence[CellXf]] = ...) -> StyleBatchIndicesAdd (dedup) whole style tables in one call.
add_dxfadd_dxf(record: DifferentialFormat) -> intAdd (dedup) a differential format and return its dxfId.
set_cell_styleset_cell_style(record: CellStyle) -> NoneAdd or replace the named <cellStyle> record record.name.
remove_cell_styleremove_cell_style(name: str) -> NoneRemove the named cell style name.
get_effective_styleget_effective_style(sheet: int, row: int, col: int) -> EffectiveStyleRead the effective style of the cell at (row, col); the cell need not exist.
get_cell_styleget_cell_style(index: int) -> CellStyleReturn the named cell style at index.
get_cell_style_xfget_cell_style_xf(index: int) -> CellXfReturn the named-style xf record at index.

テーマと色 ​

名前シグネチャ説明
get_themeget_theme() -> ThemeRead the theme's 12 scheme colours and typefaces.
set_theme_colorsset_theme_colors(colors: Sequence[int]) -> NoneReplace the theme's 12 scheme colours (a:clrScheme order; alpha ignored).
set_theme_fontsset_theme_fonts(fonts: ThemeFonts) -> NoneReplace the theme's major and minor typefaces.
set_theme_script_fontset_theme_script_font(major: bool, script: str, typeface: str) -> NoneSet the typeface of one script in the major (heading) or minor (body) font set.
reset_themereset_theme() -> NoneRemove the theme part so the workbook reports the default theme.
resolve_colorresolve_color(spec: ColorSpec, context: Union[ColorContext, int] = ...) -> ResolvedColorResolve spec to the 0xAARRGGBB Excel renders.

セルの結合 ​

名前シグネチャ説明
add_mergeadd_merge(sheet: int, merge: MergeRange) -> NoneAppend a merge range to sheet.
remove_mergeremove_merge(sheet: int, merge: MergeRange) -> NoneRemove every merge on sheet overlapping merge.
remove_merge_atremove_merge_at(sheet: int, index: int) -> NoneRemove the merge at index on sheet.
clear_mergesclear_merges(sheet: int) -> NoneDrop every merge range on sheet.
merge_countmerge_count(sheet: int) -> intReturn the number of merge ranges on sheet.
get_mergesget_merges(sheet: int) -> List[MergeRange]Return every merge range on sheet.
get_merges_in_rangeget_merges_in_range(sheet: int, cell_range: MergeRange) -> List[MergeRange]Return every merge range on sheet that intersects cell_range.
名前シグネチャ説明
add_hyperlinkadd_hyperlink(sheet: int, row: int, col: int, target: str, display: str = ..., tooltip: str = ..., location: str = ...) -> NoneAppend a hyperlink to sheet.
add_hyperlink_rangeadd_hyperlink_range(sheet: int, row: int, col: int, last_row: int, last_col: int, target: str, display: str = ..., tooltip: str = ..., location: str = ...) -> NoneAppend a hyperlink covering the inclusive cell rectangle.
remove_hyperlinkremove_hyperlink(sheet: int, row: int, col: int) -> NoneRemove every hyperlink anchored at (row, col) on sheet.
remove_hyperlink_atremove_hyperlink_at(sheet: int, index: int) -> NoneRemove the hyperlink at index on sheet.
clear_hyperlinksclear_hyperlinks(sheet: int) -> NoneDrop every hyperlink on sheet.
hyperlink_counthyperlink_count(sheet: int) -> intReturn the number of hyperlinks on sheet.
get_hyperlinksget_hyperlinks(sheet: int) -> List[Hyperlink]Return every hyperlink on sheet.
get_commentget_comment(sheet: int, row: int, col: int) -> Optional[Comment]Return the comment at (sheet, row, col) or None if absent.
set_commentset_comment(sheet: int, row: int, col: int, author: str, text: str) -> NoneSet, replace, or (empty text) remove a cell comment.
get_comment_visibleget_comment_visible(sheet: int, row: int, col: int) -> Optional[bool]Return whether the note at the cell is shown without hovering, or None if absent.
set_comment_visibleset_comment_visible(sheet: int, row: int, col: int, visible: bool) -> NoneShow or hide the note at the cell; its box geometry is kept.
comment_countcomment_count(sheet: int) -> intReturn the number of comments on sheet.
get_commentsget_comments(sheet: int) -> List[CommentEntry]Return every comment on sheet in storage order.

スレッド形式のコメントと人物 ​

名前シグネチャ説明
get_threaded_commentsget_threaded_comments(sheet: int) -> List[ThreadedComment]Return the sheet's threaded comments in file order (openers followed by their replies).
add_threaded_commentadd_threaded_comment(sheet: int, comment: ThreadedComment) -> NoneAdd a threaded comment: a new thread when parent_id is empty, else a reply.
edit_threaded_commentedit_threaded_comment(sheet: int, comment_id: str, text: str, mentions: Sequence[Mention] = ...) -> NoneReplace the text and mentions of the comment comment_id.
set_thread_resolvedset_thread_resolved(sheet: int, thread_id: str, done: bool) -> NoneSet the resolved state of the thread opened by thread_id.
remove_threaded_commentremove_threaded_comment(sheet: int, comment_id: str) -> NoneRemove the comment comment_id; removing a thread opener removes its whole thread.
get_personsget_persons() -> List[Person]Return the workbook's person list in file order.
add_personadd_person(person: Person) -> NoneAppend a person to the workbook's person list.
remove_personremove_person(person_id: str) -> NoneRemove the person person_id (refused while a comment or mention still names them).

オートフィルター ​

名前シグネチャ説明
get_auto_filter_xmlget_auto_filter_xml(sheet: int) -> strReturn the sheet's <autoFilter> XML fragment, or "".
set_auto_filter_xmlset_auto_filter_xml(sheet: int, xml: str) -> NoneReplace the sheet's <autoFilter> XML fragment.
get_auto_filterget_auto_filter(sheet: int) -> Optional[AutoFilter]Return the sheet AutoFilter, or None when the sheet has none.
set_auto_filterset_auto_filter(sheet: int, auto_filter: AutoFilter) -> NoneReplace the sheet AutoFilter.
remove_auto_filterremove_auto_filter(sheet: int) -> NoneRemove the sheet AutoFilter (no-op when absent).
apply_auto_filterapply_auto_filter(sheet: int) -> NoneHide the body rows the sheet AutoFilter excludes and show the rest.
clear_auto_filterclear_auto_filter(sheet: int) -> NoneDrop every column criterion of the sheet AutoFilter and show all its body rows.
evaluate_auto_filterevaluate_auto_filter(sheet: int) -> Tuple[int, List[bool]]Evaluate the sheet AutoFilter without changing the sheet.
get_table_auto_filterget_table_auto_filter(table_index: int) -> Optional[AutoFilter]Return the AutoFilter of table table_index, or None when it has none.
set_table_auto_filterset_table_auto_filter(table_index: int, auto_filter: AutoFilter) -> NoneReplace the AutoFilter of table table_index.
remove_table_auto_filterremove_table_auto_filter(table_index: int) -> NoneRemove the AutoFilter of table table_index (no-op when absent).
apply_table_auto_filterapply_table_auto_filter(table_index: int) -> NoneHide the body rows the table AutoFilter excludes and show the rest.
clear_table_auto_filterclear_table_auto_filter(table_index: int) -> NoneDrop every column criterion of the table AutoFilter and show all its body rows.
evaluate_table_auto_filterevaluate_table_auto_filter(table_index: int) -> Tuple[int, List[bool]]Evaluate the table AutoFilter; returns (first_row, match) as evaluate_auto_filter.

データの入力規則 ​

名前シグネチャ説明
validation_countvalidation_count(sheet: int) -> intReturn the number of data-validation rules on sheet.
get_validation_atget_validation_at(sheet: int, index: int) -> DataValidationRead the index-th data-validation rule on sheet.
get_validationsget_validations(sheet: int) -> List[DataValidation]Return every data-validation rule on sheet.
add_validationadd_validation(sheet: int, validation: DataValidationInput) -> NoneAppend a data-validation rule to sheet.
remove_validation_atremove_validation_at(sheet: int, index: int) -> NoneRemove the validation rule at index on sheet.
clear_validationsclear_validations(sheet: int) -> NoneDrop every validation rule on sheet.
validate_valuevalidate_value(sheet: int, row: int, col: int, value: Value) -> ValidationOutcomeCheck value against the data-validation rule covering (row, col) without storing it.
list_invalid_cellslist_invalid_cells(sheet: int, cursor: Optional[int] = ..., limit: Optional[int] = ...) -> Tuple[List[Cell], Optional[int]]Return one page of the populated cells failing their data-validation rule (row-major).

条件付き書式 ​

名前シグネチャ説明
evaluate_cf_rangeevaluate_cf_range(sheet: int, first_row: int, first_col: int, last_row: int, last_col: int, today_serial: float = ...) -> List[CfCellResult]Evaluate every CF block on sheet against an inclusive range.
cf_countcf_count(sheet: int) -> intReturn the number of CF rules on sheet (flattened).
get_conditional_format_atget_conditional_format_at(sheet: int, index: int) -> ConditionalFormatRead the index-th CF rule on sheet (flattened order).
get_conditional_formatsget_conditional_formats(sheet: int) -> List[ConditionalFormat]Return every CF rule on sheet in flattened priority order.
add_conditional_formatadd_conditional_format(sheet: int, rule: ConditionalFormatInput) -> intAppend a CF rule to sheet; return its index.
remove_conditional_format_atremove_conditional_format_at(sheet: int, index: int) -> NoneRemove the CF rule at index on sheet (flattened order).
clear_conditional_formatsclear_conditional_formats(sheet: int) -> NoneDrop every CF block on sheet.

画像と描画オブジェクト ​

名前シグネチャ説明
probe_imageprobe_image(data: Union[bytes, bytearray, memoryview]) -> ImageInfoSniff the format and pixel size of PNG, JPEG, GIF or BMP bytes without touching the workbook.
list_drawing_objectslist_drawing_objects(sheet: int) -> List[DrawingObject]Return the anchored objects of the sheet's drawing in document order.
get_imageget_image(sheet: int, object_id: int) -> bytesReturn the bytes of the picture object_id (copied out of WASM memory).
insert_imageinsert_image(sheet: int, data: Union[bytes, bytearray, memoryview], *, name: str = ..., descr: str = ..., anchor_kind: Union[AnchorKind, int] = ..., edit_as: Union[AnchorEditAs, int] = ..., row: int = ..., col: int = ..., row_off_emu: int = ..., col_off_emu: int = ..., width_emu: int = ..., height_emu: int = ...) -> intInsert an image anchored at (row, col) and return its object id.
remove_drawingremove_drawing(sheet: int, object_id: int) -> NoneRemove the picture or chart object_id and the parts only it reaches; other drawing content is kept.
set_drawing_anchorset_drawing_anchor(sheet: int, object_id: int, *, anchor_kind: Union[AnchorKind, int] = ..., edit_as: Union[AnchorEditAs, int] = ..., row: int = ..., col: int = ..., row_off_emu: int = ..., col_off_emu: int = ..., width_emu: int = ..., height_emu: int = ...) -> NoneMove and resize the picture or chart object_id, keeping its id and every other element.
set_drawing_z_orderset_drawing_z_order(sheet: int, object_id: int, index: int) -> NoneMake the picture or chart object_id item index of list_drawing_objects (0 is the back).
snapshot_drawingsnapshot_drawing(sheet: int, object_id: int) -> bytesCapture the picture or chart object_id as opaque bytes for restore_drawing.
restore_drawingrestore_drawing(sheet: int, data: Union[bytes, bytearray, memoryview], *, new_id: bool = ...) -> intPut a snapshot_drawing capture back and return the object's id.
list_shapeslist_shapes(sheet: int) -> List[Shape]Return the shapes, connectors and groups of the sheet's drawing in z-order (back first).
insert_shapeinsert_shape(sheet: int, *, anchor_kind: Union[AnchorKind, int], edit_as: Union[AnchorEditAs, int] = ..., from_row: int = ..., from_col: int = ..., from_row_off: int = ..., from_col_off: int = ..., to_row: int = ..., to_col: int = ..., to_row_off: int = ..., to_col_off: int = ..., cx: int = ..., cy: int = ..., name: Optional[str] = ..., prst: Optional[str] = ..., text: Optional[str] = ..., text_box: Optional[bool] = ..., fill_kind: Optional[Union[ShapePaint, int]] = ..., fill_rgb: int = ..., line_kind: Optional[Union[ShapePaint, int]] = ..., line_rgb: int = ..., line_width_emu: Optional[int] = ..., rotation: Optional[int] = ..., hidden: Optional[bool] = ...) -> intAppend a shape on top of the sheet's drawing and return its object id.
update_shapeupdate_shape(sheet: int, object_id: int, *, anchor_kind: Optional[Union[AnchorKind, int]] = ..., edit_as: Union[AnchorEditAs, int] = ..., from_row: int = ..., from_col: int = ..., from_row_off: int = ..., from_col_off: int = ..., to_row: int = ..., to_col: int = ..., to_row_off: int = ..., to_col_off: int = ..., cx: int = ..., cy: int = ..., name: Optional[str] = ..., prst: Optional[str] = ..., text: Optional[str] = ..., text_box: Optional[bool] = ..., fill_kind: Optional[Union[ShapePaint, int]] = ..., fill_rgb: int = ..., line_kind: Optional[Union[ShapePaint, int]] = ..., line_rgb: int = ..., line_width_emu: Optional[int] = ..., rotation: Optional[int] = ..., hidden: Optional[bool] = ...) -> NoneApply the arguments that are not None to the shape object_id; the rest of its XML is kept.
remove_shaperemove_shape(sheet: int, object_id: int) -> NoneRemove the shape, connector or group object_id with its children.
list_slicerslist_slicers(sheet: int) -> List[Slicer]Return the table slicers hosted by the sheet; slicers over a pivot cache are not listed.
add_sliceradd_slicer(sheet: int, table: int, column: int, *, anchor: Sequence[int], name: Optional[str] = ..., caption: Optional[str] = ..., style: Optional[str] = ..., column_count: Optional[int] = ..., row_height: Optional[int] = ..., sort_order: Optional[Union[SlicerSortOrder, int]] = ..., cross_filter: Optional[Union[SlicerCrossFilter, int]] = ...) -> intAdd a slicer over column column of table table and return its frame's object id.
update_slicerupdate_slicer(sheet: int, index: int, *, anchor: Optional[Sequence[int]] = ..., caption: Optional[str] = ..., style: Optional[str] = ..., column_count: Optional[int] = ..., row_height: Optional[int] = ..., sort_order: Optional[Union[SlicerSortOrder, int]] = ..., cross_filter: Optional[Union[SlicerCrossFilter, int]] = ...) -> NoneApply the arguments that are not None to slicer index; the rest of its XML is kept.
remove_slicerremove_slicer(sheet: int, index: int) -> NoneRemove slicer index with its drawing frame, and its cache when no other slicer uses it.
list_sparkline_groupslist_sparkline_groups(sheet: int) -> List[SparklineGroup]Return the sheet's sparkline groups in document order, each with its sparklines.
add_sparkline_groupadd_sparkline_group(sheet: int, group: SparklineGroup) -> NoneAppend group with its sparklines (at least one) to the sheet's worksheet extension list.
update_sparkline_groupupdate_sparkline_group(sheet: int, index: int, group: SparklineGroup) -> NoneRewrite the modelled attributes, colours and date range of group index from group.
set_sparkline_group_sparklinesset_sparkline_group_sparklines(sheet: int, index: int, sparklines: Sequence[Sparkline]) -> NoneReplace the sparklines of group index with sparklines (at least one).
remove_sparkline_groupremove_sparkline_group(sheet: int, index: int) -> NoneRemove sparkline group index.

グラフ ​

名前シグネチャ説明
get_chartget_chart(sheet: int, object_id: int) -> ChartInfoReturn the typed view of the chart object_id: plots, series, axes, legend and source.
get_chart_dataget_chart_data(sheet: int, object_id: int) -> ChartDataResolve the chart's series against the current cell values by Excel's rules.
preview_chart_datapreview_chart_data(sheet: int, object_id: int, overrides: Optional[ChartPreviewOverrides] = ...) -> ChartDataResolve the data of a copy of the chart with overrides applied; the workbook is unchanged.
insert_chartinsert_chart(sheet: int, kind: Union[ChartInsertKind, int], source: str, *, grouping: Union[ChartGrouping, int] = ..., direction: Union[ChartSeriesDirection, int] = ..., header_row: Optional[bool] = ..., header_column: Optional[bool] = ..., title: Optional[str] = ..., legend: Union[ChartLegendPosition, int] = ..., name: str = ..., description: str = ..., anchor_kind: Union[AnchorKind, int] = ..., edit_as: Union[AnchorEditAs, int] = ..., row: int = ..., col: int = ..., row_off_emu: int = ..., col_off_emu: int = ..., width_emu: int = ..., height_emu: int = ...) -> intCreate a chart over the A1 rectangle source and return its object id.
set_chart_typeset_chart_type(sheet: int, object_id: int, plot: int, kind: Union[ChartInsertKind, int], grouping: Union[ChartGrouping, int] = ...) -> NoneReplace plot group plot with kind, keeping each series' references, idx, order and explicit colors.
set_chart_titleset_chart_title(sheet: int, object_id: int, title: Union[str, None, ChartTitleInfo]) -> NoneSet the chart title to title; None removes it.
set_chart_legendset_chart_legend(sheet: int, object_id: int, position: Union[ChartLegendPosition, int], overlay: bool = ..., *, hidden_series: Optional[Sequence[int]] = ...) -> NoneSet the legend position (NONE removes it) and overlay.
set_chart_axisset_chart_axis(sheet: int, object_id: int, axis_id: int, patch: ChartAxisPatch) -> NonePatch axis axis_id: an omitted key is kept, None removes the element.
set_chart_displayset_chart_display(sheet: int, object_id: int, blanks_as: Union[ChartBlanksAs, int], plot_visible_only: Optional[bool]) -> NoneWrite how blanks plot and whether hidden cells are skipped; ABSENT / None remove the element.
set_chart_seriesset_chart_series(sheet: int, object_id: int, plot: int, series_idx: int, patch: ChartSeriesPatch) -> NonePatch the series with c:idx series_idx of plot group plot; a changed reference refreshes its cache.
set_chart_pointset_chart_point(sheet: int, object_id: int, plot: int, series_idx: int, point_idx: int, patch: Optional[ChartPointPatch]) -> NonePatch point point_idx of a series; None (or an empty patch) removes the point's formatting.
set_chart_plotset_chart_plot(sheet: int, object_id: int, plot: int, patch: ChartPlotPatch) -> NonePatch plot group plot; a field the plot type does not have is rejected.
set_chart_filterset_chart_filter(sheet: int, object_id: int, hidden_series: Sequence[int], hidden_categories: Sequence[int]) -> NoneReplace the chart filter: the listed series (by c:idx) and category positions are hidden.
add_chart_seriesadd_chart_series(sheet: int, object_id: int, plot: int, patch: ChartSeriesPatch) -> intAppend a series to plot group plot and return its c:idx.
remove_chart_seriesremove_chart_series(sheet: int, object_id: int, plot: int, series_idx: int) -> NoneRemove the series with c:idx series_idx from plot group plot.
set_chart_sourceset_chart_source(sheet: int, object_id: int, source: str, direction: Union[ChartSeriesDirection, int] = ..., header_row: Optional[bool] = ..., header_column: Optional[bool] = ...) -> NoneRebuild every series from source by the insert splitting rules.

印刷設定とページ分割 ​

名前シグネチャ説明
paginatepaginate(sheet: int) -> PaginationResultResolve the worksheet's print area, page breaks, and page count.
get_page_setup_xmlget_page_setup_xml(sheet: int) -> strReturn the sheet's <pageSetup> fragment, or "".
set_page_setup_xmlset_page_setup_xml(sheet: int, xml: str) -> NoneReplace the sheet's <pageSetup> fragment.
get_page_margins_xmlget_page_margins_xml(sheet: int) -> strReturn the sheet's <pageMargins> fragment, or "".
set_page_margins_xmlset_page_margins_xml(sheet: int, xml: str) -> NoneReplace the sheet's <pageMargins> fragment.
get_print_options_xmlget_print_options_xml(sheet: int) -> strReturn the sheet's <printOptions> fragment, or "".
set_print_options_xmlset_print_options_xml(sheet: int, xml: str) -> NoneReplace the sheet's <printOptions> fragment.
get_header_footer_xmlget_header_footer_xml(sheet: int) -> strReturn the sheet's <headerFooter> fragment, or "".
set_header_footer_xmlset_header_footer_xml(sheet: int, xml: str) -> NoneReplace the sheet's <headerFooter> fragment.
get_sheet_pr_xmlget_sheet_pr_xml(sheet: int) -> strReturn the sheet's <sheetPr> fragment, or "".
set_sheet_pr_xmlset_sheet_pr_xml(sheet: int, xml: str) -> NoneReplace the sheet's <sheetPr> fragment.
set_fit_to_pageset_fit_to_page(sheet: int, enabled: bool) -> NoneSet or clear <sheetPr><pageSetUpPr fitToPage>.
get_print_areaget_print_area(sheet: int) -> strReturn the print area as comma-separated A1 ranges, or "".
set_print_areaset_print_area(sheet: int, ranges_a1: str) -> NoneWrite _xlnm.Print_Area from one or more A1 ranges.
get_print_titlesget_print_titles(sheet: int) -> tuple[str, str]Return (repeat_rows, repeat_cols) as "1:2" / "A:A".
set_print_titlesset_print_titles(sheet: int, repeat_rows: str = ..., repeat_cols: str = ...) -> NoneWrite _xlnm.Print_Titles from a row span and a column span.
add_row_breakadd_row_break(sheet: int, row: int, manual: bool = ...) -> NoneUpsert a row break before row, spanning the whole sheet.
add_col_breakadd_col_break(sheet: int, col: int, manual: bool = ...) -> NoneUpsert a column break before col, spanning the whole sheet.
remove_row_breakremove_row_break(sheet: int, row: int) -> NoneRemove the row break at row.
remove_col_breakremove_col_break(sheet: int, col: int) -> NoneRemove the column break at col.
clear_breaksclear_breaks(sheet: int) -> NoneRemove every manual break on both axes.
get_row_breaksget_row_breaks(sheet: int) -> List[PageBreak]Return the row breaks, ascending by row.
get_col_breaksget_col_breaks(sheet: int) -> List[PageBreak]Return the column breaks, ascending by column.
set_page_setupset_page_setup(sheet: int, *, orientation: Optional[int] = ..., paper_size: Optional[int] = ..., scale: Optional[int] = ..., fit_to_width: Optional[int] = ..., fit_to_height: Optional[int] = ..., fit_to_page: Optional[bool] = ...) -> NoneApply a partial <pageSetup> update.
set_page_marginsset_page_margins(sheet: int, *, left: Optional[float] = ..., right: Optional[float] = ..., top: Optional[float] = ..., bottom: Optional[float] = ..., header: Optional[float] = ..., footer: Optional[float] = ...) -> NoneApply a partial <pageMargins> update, in inches.
set_print_optionsset_print_options(sheet: int, *, grid_lines: Optional[bool] = ..., headings: Optional[bool] = ..., horizontal_centered: Optional[bool] = ..., vertical_centered: Optional[bool] = ...) -> NoneApply a partial <printOptions> update.
set_header_footerset_header_footer(sheet: int, *, odd_header: Optional[str] = ..., odd_footer: Optional[str] = ..., even_header: Optional[str] = ..., even_footer: Optional[str] = ..., first_header: Optional[str] = ..., first_footer: Optional[str] = ..., different_odd_even: Optional[bool] = ..., different_first: Optional[bool] = ..., scale_with_doc: Optional[bool] = ..., align_with_margins: Optional[bool] = ...) -> NoneApply a partial <headerFooter> update.
get_page_setupget_page_setup(sheet: int) -> PageSetupRead the effective page setup and which attributes state it.
get_page_marginsget_page_margins(sheet: int) -> PageMarginsRead the effective page margins in inches, with presence flags.

ピボットテーブル ​

名前シグネチャ説明
pivot_countpivot_count(sheet: int) -> intReturn the number of PivotTables anchored on sheet.
pivot_layoutpivot_layout(sheet: int, pivot_index: int) -> PivotLayoutEvaluate and project a PivotTable into concrete grid cells.
get_pivot_report_layoutget_pivot_report_layout(sheet: int, pivot_index: int) -> PivotReportLayoutReturn the pivot's compact, tabular, or outline report layout.
set_pivot_report_layoutset_pivot_report_layout(sheet: int, pivot_index: int, layout: Union[PivotReportLayout, int]) -> NoneSet the pivot's compact, tabular, or outline report layout.
pivot_createpivot_create(sheet: int, name: str, cache_id: int, anchor_row: int, anchor_col: int) -> intCreate a new empty pivot table; return its flat index.
pivot_removepivot_remove(sheet: int, pivot_index: int) -> NoneRemove the pivot table at pivot_index.
pivot_set_namepivot_set_name(sheet: int, pivot_index: int, name: str) -> NoneRename the pivot table.
pivot_set_anchorpivot_set_anchor(sheet: int, pivot_index: int, anchor_row: int, anchor_col: int, span_rows: int, span_cols: int) -> NoneUpdate the pivot's anchor cell and span.
pivot_set_grand_totalspivot_set_grand_totals(sheet: int, pivot_index: int, rows_enabled: bool, cols_enabled: bool) -> NoneToggle the row / column grand-total bands.
pivot_set_style_infopivot_set_style_info(sheet: int, pivot_index: int, name: Optional[str] = None, *, show_row_headers: bool = False, show_col_headers: bool = False, show_row_stripes: bool = False, show_col_stripes: bool = False, show_last_column: bool = False) -> NoneSet the pivot's table style and toggles, making the style element present.
pivot_namepivot_name(sheet: int, pivot_index: int) -> strReturn the pivot's name.
pivot_grand_totalspivot_grand_totals(sheet: int, pivot_index: int) -> Tuple[bool, bool]Return (rows, cols), the flags pivot_set_grand_totals writes.
pivot_style_infopivot_style_info(sheet: int, pivot_index: int) -> PivotStyleInfoReturn the table style pivot_set_style_info writes.
pivot_row_field_orderpivot_row_field_order(sheet: int, pivot_index: int) -> List[int]Return the row-axis field order (the list pivot_set_row_field_order takes).
pivot_col_field_orderpivot_col_field_order(sheet: int, pivot_index: int) -> List[int]Return the column-axis field order.
pivot_field_atpivot_field_at(sheet: int, pivot_index: int, field_idx: int) -> PivotFieldInfoRead the definition of pivot field field_idx.
pivot_field_item_countpivot_field_item_count(sheet: int, pivot_index: int, field_idx: int) -> intReturn the number of items in pivot field field_idx's item list.
pivot_field_item_atpivot_field_item_at(sheet: int, pivot_index: int, field_idx: int, item_idx: int) -> PivotItemInfoRead item item_idx of pivot field field_idx.
pivot_data_field_atpivot_data_field_at(sheet: int, pivot_index: int, data_field_idx: int) -> PivotDataFieldSpecRead data field data_field_idx in the shape pivot_data_field_add accepts.
pivot_field_countpivot_field_count(sheet: int, pivot_index: int) -> intReturn the number of fields configured on the pivot.
pivot_field_addpivot_field_add(sheet: int, pivot_index: int, spec: PivotFieldSpec) -> intPlace a field on the pivot; return its index.
pivot_field_clearpivot_field_clear(sheet: int, pivot_index: int) -> NoneDrop every field from the pivot.
pivot_field_set_axispivot_field_set_axis(sheet: int, pivot_index: int, field_idx: int, axis: Union[PivotAxis, int]) -> NoneSet the axis of pivot field field_idx.
pivot_field_set_sortpivot_field_set_sort(sheet: int, pivot_index: int, field_idx: int, order: Union[PivotSortOrder, int], by_field: str = ...) -> NoneSet the sibling order of pivot field field_idx.
pivot_field_set_subtotal_toppivot_field_set_subtotal_top(sheet: int, pivot_index: int, field_idx: int, top: bool) -> NoneSet the subtotal_top flag on pivot field field_idx.
pivot_field_add_itempivot_field_add_item(sheet: int, pivot_index: int, field_idx: int, name: str, visible: bool) -> NoneAppend a manual-filter item addressed by its label.
pivot_field_add_item_atpivot_field_add_item_at(sheet: int, pivot_index: int, field_idx: int, cache_index: int, visible: bool) -> NoneAppend a manual-filter item addressed by its cache shared-item index.
pivot_field_clear_itemspivot_field_clear_items(sheet: int, pivot_index: int, field_idx: int) -> NoneDrop every manual-filter item from pivot field field_idx.
pivot_field_set_item_visiblepivot_field_set_item_visible(sheet: int, pivot_index: int, field_idx: int, item_idx: int, visible: bool) -> NoneToggle the visibility of item item_idx on field field_idx.
pivot_field_add_subtotal_fnpivot_field_add_subtotal_fn(sheet: int, pivot_index: int, field_idx: int, agg: Union[PivotAggregation, int]) -> NoneAppend a subtotal-fn entry to pivot field field_idx.
pivot_field_clear_subtotal_fnspivot_field_clear_subtotal_fns(sheet: int, pivot_index: int, field_idx: int) -> NoneDrop every subtotal-fn entry from pivot field field_idx.
pivot_field_set_date_grouppivot_field_set_date_group(sheet: int, pivot_index: int, field_idx: int, granularity: Union[PivotDateGrouping, int], calendar: Union[PivotCalendar, int], start_year: int = ..., end_year: int = ..., interval_days: int = ..., start_serial: float = ..., end_serial: float = ...) -> NoneConfigure date-grouping on pivot field field_idx.
pivot_field_clear_date_grouppivot_field_clear_date_group(sheet: int, pivot_index: int, field_idx: int) -> NoneRemove the date-grouping config from pivot field field_idx.
pivot_field_set_number_formatpivot_field_set_number_format(sheet: int, pivot_index: int, field_idx: int, fmt: str) -> NoneSet the numFmtId of pivot field field_idx.
pivot_set_row_field_orderpivot_set_row_field_order(sheet: int, pivot_index: int, indices: Sequence[int]) -> NoneReplace the row-axis field order with indices.
pivot_set_col_field_orderpivot_set_col_field_order(sheet: int, pivot_index: int, indices: Sequence[int]) -> NoneReplace the column-axis field order with indices.
pivot_data_field_countpivot_data_field_count(sheet: int, pivot_index: int) -> intReturn the number of <dataField> entries on the pivot.
pivot_data_field_addpivot_data_field_add(sheet: int, pivot_index: int, spec: PivotDataFieldSpec) -> intAppend a data-field entry; return its index.
pivot_data_field_setpivot_data_field_set(sheet: int, pivot_index: int, data_field_idx: int, spec: PivotDataFieldSpec) -> NoneReplace the data-field entry at data_field_idx in place.
pivot_data_field_clearpivot_data_field_clear(sheet: int, pivot_index: int) -> NoneDrop every data-field entry from the pivot.
pivot_filter_countpivot_filter_count(sheet: int, pivot_index: int) -> intReturn the number of filters on the pivot; see pivot_filter_at.
pivot_filter_addpivot_filter_add(sheet: int, pivot_index: int, spec: PivotFilterSpec) -> NoneAppend a filter to the pivot; it is saved with it.
pivot_filter_atpivot_filter_at(sheet: int, pivot_index: int, filter_idx: int) -> PivotFilterSpecRead the filter at filter_idx without mutating it.
pivot_filter_clearpivot_filter_clear(sheet: int, pivot_index: int) -> NoneDrop every listed filter from the pivot.
pivot_filter_remove_atpivot_filter_remove_at(sheet: int, pivot_index: int, filter_idx: int) -> NoneRemove the filter at filter_idx.

ピボットキャッシュ ​

名前シグネチャ説明
pivot_cache_countpivot_cache_count() -> intReturn the number of pivot caches owned by the workbook.
pivot_cache_id_atpivot_cache_id_at(index: int) -> intReturn the cache id at flat index.
pivot_cache_createpivot_cache_create(requested_id: int = ...) -> intCreate a new empty pivot cache; return its assigned id.
get_pivot_cache_worksheet_sourceget_pivot_cache_worksheet_source(cache_id: int) -> Optional[PivotWorksheetSource]Return a cache's worksheet-source metadata, or None when absent.
set_pivot_cache_worksheet_sourceset_pivot_cache_worksheet_source(cache_id: int, source: Optional[PivotWorksheetSource]) -> NoneSet cache worksheet-source metadata; pass None to clear it.
pivot_cache_removepivot_cache_remove(cache_id: int) -> NoneRemove the pivot cache with id cache_id.
pivot_cache_field_countpivot_cache_field_count(cache_id: int) -> intReturn the number of fields on the cache.
pivot_cache_field_namepivot_cache_field_name(cache_id: int, field_idx: int) -> strRead the name of cache field field_idx.
pivot_cache_field_addpivot_cache_field_add(cache_id: int, name: str) -> intAppend a field to the cache; return its index.
pivot_cache_field_clearpivot_cache_field_clear(cache_id: int) -> NoneDrop every field (and record) from the cache.
pivot_cache_field_shared_item_countpivot_cache_field_shared_item_count(cache_id: int, field_idx: int) -> intReturn the shared-item count on cache field field_idx.
pivot_cache_field_add_shared_item_numberpivot_cache_field_add_shared_item_number(cache_id: int, field_idx: int, value: float) -> NoneAppend a numeric shared item to a cache field.
pivot_cache_field_add_shared_item_textpivot_cache_field_add_shared_item_text(cache_id: int, field_idx: int, value: str) -> NoneAppend a text shared item to a cache field.
pivot_cache_field_add_shared_item_boolpivot_cache_field_add_shared_item_bool(cache_id: int, field_idx: int, value: bool) -> NoneAppend a boolean shared item to a cache field.
pivot_cache_field_add_shared_item_blankpivot_cache_field_add_shared_item_blank(cache_id: int, field_idx: int) -> NoneAppend a blank shared item to a cache field.
pivot_cache_field_add_shared_item_errorpivot_cache_field_add_shared_item_error(cache_id: int, field_idx: int, error_code: int) -> NoneAppend an Excel error shared item to a cache field.
pivot_cache_field_clear_shared_itemspivot_cache_field_clear_shared_items(cache_id: int, field_idx: int) -> NoneDrop every shared item from a cache field.
pivot_cache_record_countpivot_cache_record_count(cache_id: int) -> intReturn the number of records on the cache.
pivot_cache_record_addpivot_cache_record_add(cache_id: int) -> intAppend an empty record to the cache; return its index.
pivot_cache_record_clearpivot_cache_record_clear(cache_id: int) -> NoneDrop every record from the cache.
pivot_cache_record_set_numberpivot_cache_record_set_number(cache_id: int, record_idx: int, field_idx: int, value: float) -> NoneSet cache cell (record_idx, field_idx) to a number.
pivot_cache_record_set_textpivot_cache_record_set_text(cache_id: int, record_idx: int, field_idx: int, value: str) -> NoneSet cache cell (record_idx, field_idx) to text.
pivot_cache_record_set_boolpivot_cache_record_set_bool(cache_id: int, record_idx: int, field_idx: int, value: bool) -> NoneSet cache cell (record_idx, field_idx) to a boolean.
pivot_cache_record_set_blankpivot_cache_record_set_blank(cache_id: int, record_idx: int, field_idx: int) -> NoneSet cache cell (record_idx, field_idx) to blank.
pivot_cache_record_set_errorpivot_cache_record_set_error(cache_id: int, record_idx: int, field_idx: int, error_code: int) -> NoneSet cache cell (record_idx, field_idx) to an Excel error.
pivot_cache_idpivot_cache_id(sheet: int, pivot_index: int) -> intReturn the cache_id of the pivot cache the pivot draws from.

メソッドの補足 ​

CellStyle は set_cell_style() と get_cell_style() が使う名前付きスタイルのレコードです。フィールドは name、xf_id、builtin_id、i_level、hidden、custom_builtin で、name と xf_id は必須です。それ以外はデータクラスの既定値を使います。カスタムスタイルでは builtin_id を既定値のままにしてください。xf_id は名前付きスタイルの XF テーブルを指し、セル単位の XF テーブルは指しません。

行と列のスタイル、clear_cell_xf_index() と set_cell_xf_index(..., 0) の違い、range_style_bases() → remap_range_style() による変更と、その取り消しに使う snapshot_range_style() / restore_range_style() は ワークブック操作 の規則に従います。get_theme() は major_scripts と minor_scripts を返します。スクリプト別フォントの規則は 表示とレイアウト を参照してください。

Python にはスカラーの evaluate_formula_text() がありません。evaluate_formula_array(sheet, row, col, formula) は結果全体を読み取り専用で返し、evaluate_cf_formula(sheet, row, col, anchor_row, anchor_col, formula) は条件付き書式の条件式を評価します。

get_iterative() は IterativeSettings(enabled, max_iterations, max_change) を返します。エンジンは max_iterations を 32767 までに制限し、制限後の値を返します。set_iterative_enabled(enabled) は保存済みの上限と閾値を保ったまま反復計算を切り替え、add_batch() はフォント、塗りつぶし、罫線、表示形式、XF を 1 回の呼び出しで登録します。

set_calc_mode(mode) は CalcMode を受け取ります。AUTO_NO_TABLE では、recalc_data_tables() を呼ぶまで recalc() はデータテーブルの結果を計算しません。full_precision()、calc_on_save()、ref_mode()、date1904() は対応する <calcPr> と <workbookPr> の設定を読み、それぞれに set_ 版があります。<calcPr> のその他の属性は再保存しても保持されます。

active_sheet() / set_active_sheet(sheet) はアクティブタブを読み書きします。設定すると tabSelected も移り、非表示シートは拒否されます。アクティブなシートを非表示にするか削除すると、右隣の次の表示シート、なければ左側で最も近い表示シートがアクティブになります。set_sheet_top_left() と set_sheet_pane_top_left() はビューと右下ペインのスクロール原点を設定し、get_sheet_selection() / set_sheet_selection() は各ペインの選択範囲を扱います。set_sheet_split(sheet, x_twips, y_twips) は、固定せずに twips 単位の位置でビューを分割します。分割は固定を置き換え、固定も分割を置き換え、0, 0 で分割を解除します。ビューに存在しないペインの選択は保存時に捨てられ、選択範囲のどれにも入らないアクティブセルは最初の範囲の左上へ移ります。get_sheet_view() は show_formulas と show_outline_symbols を返し、set_sheet_show_formulas() と set_sheet_show_outline_symbols() で設定できます。

set_row_collapsed() と set_column_collapsed() は、行・列の上書き設定の getter が返すアウトラインの collapsed フラグを設定します。outlineLevelRow と outlineLevelCol は、保存のたびに最も深いレベルから導出します。7 を超えるアウトラインレベルは FormulonError を送出します。

add_data_table()、get_data_table(sheet, row, col)、remove_data_table(sheet, row, col) は What-If データテーブル(<f t="dataTable">)を扱います。recalc() は、入力セルに値を順に代入し、それを読むセルを再計算して入力を元に戻すことで、1 変数(列入力または行入力)と 2 変数のテーブルを埋めます。結果セルへの書き込みは kPreconditionFailed の FormulonError になり、テーブルまたはその見出し行・列を横切る行・列の挿入と削除も同様です。結果セルは数式 getter で =TABLE(row_input,col_input) を返し、FORMULATEXT は {=TABLE(...)}、ISFORMULA は TRUE を返します。

list_shapes()、insert_shape()、update_shape()、remove_shape() は、シートの描画に含まれる xdr:sp の図形とテキストボックス、xdr:cxnSp のコネクタ、xdr:grpSp のグループを扱います。更新は指定したフィールドだけを書き換え、図形の残りの XML は保持します。レコードで表現できない図形は ShapePaint.OTHER または空のフィールドで列挙され、保存してもそのまま通過します。図形は画像と同様に行・列の編集に追従します。

list_sparkline_groups()、add_sparkline_group()、update_sparkline_group()、set_sparkline_group_sparklines()、remove_sparkline_group() は、シートの x14:sparklineGroups を扱います。更新しても、rightToLeft、uid、未知の拡張といったレコード外の属性と子要素は保持されます。

list_slicers()、add_slicer()、update_slicer()、remove_slicer() はテーブルスライサーを扱います。追加するとスライサーパーツ、キャッシュ、拡張エントリ、定義名、描画フレームが作られます。スライサーを削除すると、ほかに使うスライサーがなくなった時点でそのキャッシュも削除されます。テーブルやシートの削除、スライサーのフレーム下の行・列の削除では、それに結び付いたスライサーも削除されます。ピボットキャッシュ上のスライサーはそのまま通過し、列挙されません。テーブルスライサーの選択状態はテーブルの AutoFilter が保持します。

get_workbook_protection() / set_workbook_protection() は <workbookProtection> を読み書きし、get_protected_ranges()、add_protected_range()、update_protected_range()、remove_protected_range() はシートの <protectedRange> を扱います。保護範囲は行・列の編集に追従します。パスワードハッシュはホストが計算した値をそのまま保存し、レコードにない属性は保持します。どちらの保護もセル編集では強制されません。

table_rename(index, name, display_name=None) はテーブルの名前を変更し、セル、定義名、条件付き書式、入力規則、計算列と集計行の数式、グラフ系列にある構造化参照を書き換えます。そのテーブルを元にしたピボットキャッシュも追従します。table_set_style_info() はスタイル名と、最初の列・最後の列・行ストライプ・列ストライプの切り替えを設定し、table_set_column_totals() は 1 列の集計関数、ラベル、数式を設定します。集計行をオンにすると、各列の集計セルが書き込まれます。get_table_style()、set_table_style()、remove_table_style()、table_style_defaults()、set_table_style_defaults() は、カスタムの <tableStyles> と既定のテーブル・ピボットテーブルのスタイル名を扱い、pivot_style_info() / pivot_set_style_info() はピボットテーブルのスタイルを読み書きします。set_defined_name_attrs(name, local_sheet_id, ...) は名前のコメントと非表示フラグを設定し、名前の数式を置き換えても両方とも保持されます。

get_comment_visible() / set_comment_visible() は、従来のメモが表示状態かどうかを読み書きします。メモのボックス、表示状態、コメントパーツの作成者テーブルは再保存しても保持され、ボックスは行・列の編集でメモに追従します。get_show_phonetic() / set_show_phonetic() は、セルごとの「ふりがなを表示」フラグを読み書きします。保存ファイルでこのフラグを持つのは定数と空白セルだけで、数式セルには付きません。

add_sheet() と rename_sheet() は、空の名前、UTF-16 で 31 単位を超える名前、: \ / ? * [ ] を含む名前、アポストロフィで始まるまたは終わる名前、大文字小文字を同一視すると別のシート名と重なる名前を kInvalidSheetName の FormulonError で拒否します。win-* プロファイル(既定を含む)では、大文字小文字を問わず History も拒否し、mac-* プロファイルは受け付けます。表示中の唯一のシートを非表示にするか削除すると FormulonError を送出し、データテーブル、従来の配列ブロック、ピボットテーブルを横切る行・列の挿入と削除、またはそれらやテーブルをグリッドの端より先へ押し出す挿入も同様です。

set_sheet_visibility() は SheetVisibility.VISIBLE、HIDDEN、VERY_HIDDEN を受け取り、get_sheet_view() は tab_hidden に加えて解決済みの 3 状態を返します。set_range_xf_index() はセル書式(XF)インデックスを両端を含む矩形へ適用し、存在しないセルを書式付きの空セルとして作成します。

table_create() の column_names は ref の列数と一致させます。見出しセルは呼び出し側が書き込みます。table_update() は None を渡した項目を変更せず、既存テーブルの AutoFilter は範囲を変えても条件と拡張を保ちます。get_auto_filter_xml() / set_auto_filter_xml() はシートの AutoFilter を <autoFilter> の XML 断片のまま読み書きし、空文字列を渡すと削除します。行や列を挿入・削除すると、AutoFilter の ref と、モデル化した条件・並べ替えのオフセットもセルと一緒に移動します。解析しないワークシート XML はバイト列のまま保持します。

add_hyperlink_range() は両端を含む矩形に 1 つのハイパーリンクを追加し、読み出した Hyperlink には last_row と last_col が入ります。DataValidationInput で allow_blank を省略した場合の既定値は False です。空セルを許可する場合は allow_blank=True を指定してください。

条件付き書式の表示データは ColorScale、DataBar、IconSet で表します。DataBar は x14 の制御項目 gradient、axis_position(0 は自動、1 は中央、2 はなし)、negative_fill、border、negative_border、axis_color、direction(0 はシートの読み方向、1 は左から右、2 は右から左)を持ちます。省略した項目はモデルの既定値を使い、保存と読み込みをまたいで保持されます。

新しく作成したピボットキャッシュには、保存前にワークシートの参照元を設定してください。たとえば set_pivot_cache_worksheet_source(cache_id, PivotWorksheetSource(ref="A1:C10", sheet="Data")) です。参照元のない新規キャッシュは保存に失敗します。読み込んだキャッシュは参照元のメタデータを保持し、参照元がワークシート以外や外部データの場合もあります。pivot_field_add_item_at() はキャッシュの共有項目インデックスで手動フィルター項目を指定します。空白の項目を指定できるのはこの方法だけで、pivot_field_add_item() に空のラベルを渡しても指定できません。

get_cells_in_range(sheet, cell_range, cursor=None, limit=None) は、行・列の順序で (cells, next_cursor) を返します。各 Cell は row、col、formula、value を持ちます。next_cursor が None になるまで次の呼び出しへ渡してください。limit の省略または 0 は最大 65,536 件を選びます。数式セル、空白でない値、スピルの仮想セルを含み、スタイルだけを持つ空セルは含みません。list_invalid_cells() も同じページング規則に従います。

寸法メソッドは 96 DPI の画面向けモデルに GeometryMode.DISPLAY、ページ分割に使う DPI に依存しないモデルに GeometryMode.PRINT を指定します。get_display_text() と format_value() は、値が書式の表現可能な範囲を外れると DisplayStatus.OVERFLOW と ######## を返し、書式コードが不正な場合は DisplayStatus.INVALID_FORMAT として General 表示へフォールバックします。

probe_image() はワークブックを変更せず、PNG、JPEG、GIF、BMP の画像形式と寸法を読み取ります。list_drawing_objects() はシートのアンカー付きオブジェクトを文書順で返します。get_image() は画像バイト列をコピーし、insert_image() は既存の描画を保持します。remove_drawing() は画像またはグラフを削除し、他のオブジェクトがメディアを参照しなくなった場合にメディアも解放します。スレッドコメント API は返信と人物レコードを含み、コメントやメンションが参照している人物は削除できません。

AutoFilter の条件と行の表示状態は別に管理します。evaluate_auto_filter() で一致結果を確認し、apply_auto_filter() で非表示行を更新してください。clear_auto_filter() は範囲を残したまま条件を削除します。入力規則 API は値を保存せずに候補値を検証し、list_invalid_cells() は既存の違反を列挙します。

paginate(sheet) は page_count、print_area、horizontal_breaks、vertical_breaks、paper、margins、printable、scale、page_order、print_titles、pages、horizontal_break_manual、vertical_break_manual を持つ PaginationResult を返します。paper はポイント単位の寸法、向き、用紙コードを認識できたかを持ちます。pages の各 PageLayout は area_index、両端を含むセル範囲、原点、拡大縮小後の寸法を持ちます。印刷範囲の指定がない場合も print_area は空のままですが、ページ分割は使用範囲へフォールバックします。手動改ページのリストは対応する改ページリストと同じ順序です。

set_formula() は不正な数式を kParserUnexpectedToken として拒否し、既存の数式とキャッシュ値を変更しません。保存済みの XLSX / XLSB に不正な数式が含まれる場合は読み込みできますが、recalc() 後のセル値は #NAME? になります。単発の eval_formula() はアドホック評価のため、不正な入力を #NAME? の値として返します。

iter_cells(sheet) は、書式だけの空白セル、set_blank で書き込んだセル、スピル先のセルを含む書き込み済み座標を (row, col) の昇順で列挙します。未書き込みの隙間は含みません。列挙中はシートを変更しないでください。get_cells_in_range() とは異なり、明示的に書き込んだ空白セルも対象です。詳しくは ワークブック操作を参照してください。

保存時の診断 ​

save_with_diagnostics(fmt) は、保存した bytes と書き出し側が検出した損失・保存時に出力されなかった機能のカウンターを持つ SaveDiagnostics を返します。read_diagnostics() は、ワークブックの読み込み時に取得したカウンターを持つ ReadDiagnostics を返します。カウンターの対象は一部の損失だけです。すべて 0 であることは、記載された損失が発生しなかったことを示しますが、パッケージをバイト単位で比較したことや、診断イベントが一切なかったことは示しません。

結果フィールド意味
SaveDiagnosticsdowngraded_formula_countキャッシュ済みリテラルとして出力された数式セルの数。XLSX では常に 0 です。
deferred_feature_countレコードへ変換されなかったシート機能の数。XLSX では常に 0 です。
dropped_part_countいずれかの書き出し側が破棄した、そのまま保持していたパートの数。
dropped_relationship_count対象パートの破棄に伴って破棄された関連付けの数。dropped_part_count と同じ損失を表す場合があります。
renumbered_part_count書き出し側が割り当てたパート ID で出力されたテーブルの数。XLSB では常に 0 です。
ReadDiagnosticsundecoded_formula_countデコードできなかった保存済み数式の数。XLSB のみです。
undecoded_defined_name_countデコードできずにスキップされた定義名の数。XLSB のみです。
undecoded_part_countコンテンツタイプを解決できなかった XLSB パッケージパートの数。
skipped_feature_count参照が利用できずスキップされた OOXML の表示オーバーレイ項目の数。
unknown_content_type_countコンテンツタイプを認識できなかった OOXML ワークブックパートの数。
python
from formulon import Workbook, WorkbookFormat

with Workbook.create_default() as wb:
    saved = wb.save_with_diagnostics(WorkbookFormat.XLSB)
    print(saved.bytes, saved.downgraded_formula_count)
    loaded = Workbook.load(saved.bytes)
    try:
        print(loaded.read_diagnostics().undecoded_formula_count)
    finally:
        loaded.close()

dropped_part_count と dropped_relationship_count は、1 つのパートを破棄したときにどちらも増える場合があります。失われたオブジェクト数として合計しないでください。

時計の固定 ​

ワークブックが固定されていない場合、NOW()、TODAY()、ピボットの相対期間フィルターはホストの時計を読み取ります。これらの結果を 1 回の再計算で一致させる場合や、ホストをまたいで再現する場合は、ワークブックを 1 つの年月日・時分秒の値に固定してください。

python
from formulon import Workbook

with Workbook.create_default() as wb:
    wb.set_pinned_now(2026, 8, 19, 12, 0, 0)
    print(wb.pinned_now())  # CivilTime(year, month, day, hour, minute, second)
    wb.recalc()
    wb.clear_pinned_now()

pinned_now() は CivilTime オブジェクトを返し、ワークブックがホストの時計に従う場合は None を返します。set_pinned_now() は year 1900–9999、month 1–12、月ごとの実在する日、hour 0–23、minute / second 0–59 を検証します。不正な値は正規化せず、FormulonError を送出します。値はタイムスタンプではなく、年月日・時分秒の値として保持するため、タイムゾーンの解釈はありません。固定の設定・解除ではキャッシュ済みの数式値を再計算しないため、必要に応じて recalc() を明示的に呼び出してください。固定はファイル状態ではなくワークブックのモデル状態です。保存時には記録されず、読み込み直後のワークブックは固定されていません。

値 ​

Value.to_python() は空白、数値、真偽値、テキストを Python 型(None / float / bool / str)に変換します。エラー、配列、参照、ラムダは Value ラッパーのまま返るので、kind とデータを確認できます。

python
value = wb.get_value(0, 0, 0)
if value.kind is ValueKind.NUMBER:
    print(value.number)
elif value.kind is ValueKind.ERROR:
    print(formulon.error_display_name(value.error_code))

Value は構築時にペイロードを検証します。kind は ValueKind に変換され、その種類が取らないペイロードや欠けたペイロードは ValueError、型の違うペイロードは TypeError になります。そのため Value(ValueKind.NUMBER) や Value(ValueKind.BLANK, text="a") は失敗し、bool は数値として受け付けません。

Python の Value が持つのは error_code だけで、error_text というフィールドはありません。formulon.error_display_name(value.error_code) で #DIV/0! や #VALUE! の表示文字列を得られます。

エラー処理 ​

FormulonError はホスト側の失敗を表します。不正なバイト列、範囲外のインデックス、set_formula() に渡した不正なテキスト、close() 後の呼び出し、エンジン内部の失敗が該当します。例外は status(数値の fm_status_t)、status_name(kParserUnexpectedToken など)、message、context を持ちます。小数であったり、負のシート番号のように C ABI の整数の幅に収まらなかったりする整数引数は、エンジンを呼ぶ前に ValueError を送出します。パックされた整数引数も同じ方法で範囲を検査します。Excel のセルエラーは例外ではなく値です。

python
import formulon
from formulon import Workbook, ValueKind, FormulonError

try:
    with Workbook.load(blob) as wb:
        wb.recalc()
        v = wb.get_value(0, 0, 0)
        if v.kind is ValueKind.ERROR:
            handle_cell_error(v)
except FormulonError as e:
    handle_host_failure(e)

次に読むもの ​