HotXLS ドキュメント

XLSX ファサードの追加 API メンバー

このページでは、HTML エクスポートオプションや、XLSX セル参照または XML ペイロードテキストを直接操作する呼び出し元向けのヘルパー関数など、 lxHandleXで宣言されている小さな公開 API メンバーを説明します

HTML エクスポートオプション

property FormulaArrayMemoryLimit: Int64;
      
次のような生成数式配列が割り当てるペイロードに上限を設定します MUNIT デフォルトは 64 MiB で、並列再計算ワーカーに適用され、 Double element

HTML export options

type
  TXLSXHtmlExportOptions = class
    constructor Create;
    property Title: WideString;
    property WriteDocument: Boolean;
    property IncludeStyles: Boolean;
    property IncludeBOM: Boolean;
    property TableClass: WideString;
  end;
      
TitleSets the document title when WriteDocument WriteDocument が True のとき文書タイトルを設定する
WriteDocumentTrue のとき完全な HTML document を書き出す False のとき table fragment だけを書く
IncludeStyles生成される HTML に CSS とインラインスタイル情報を含めるかを制御する
IncludeBOMControls whether ファイル と stream output starts 使用 UTF-8 BOM
TableClass追加します CSS クラス 名前 へ generated <table> element

XLSX 参照ヘルパー関数

function XlsxColumnLabel(Col: Integer): WideString;
function XlsxCellRef(Row, Col: Integer): WideString;
function XlsxColumnIndex(const ColumnLabel: WideString): Integer;
function XlsxParseCellRef(const Ref: WideString; out Row, Col: Integer): Boolean;
function XlsxParseRangeRef(const Ref: WideString; out Row1, Col1, Row2, Col2: Integer): Boolean;
      
XlsxColumnLabelConverts 1-ベース 列 インデックス へ A1-スタイル 列 label such as A, Z, または AA
XlsxCellRefBuilds A1-スタイル セル リファレンス から 1-ベース 行 と 列 番号
XlsxColumnIndexConverts A1-スタイル 列 label へ 1-ベース 列 インデックス
XlsxParseCellRef単一の A1 形式セル参照を解析し、行と列の座標を返します
XlsxParseRangeRefParses rectangular A1-スタイル 範囲 と 返します inclusive 1-ベース bounds

XLSX XML エスケープヘルパー関数

function XlsxEscapeText(const Value: WideString): WideString;
function XlsxEscapeAttr(const Value: WideString): WideString;
      
XlsxEscapeText は XML テキストノードのコンテンツをエスケープし、 XlsxEscapeAttr は XML 属性値をエスケープして Excel が正確に読み戻す必要がある属性の空白を保持します

使用例

このヘルプ ファイル全体で説明している高度な XLSX メンバーは、次のプレーンな型を受け渡しします。宣言は lxHandleX

{ Find and replace }
TXLSXFindFlag = (lxfMatchCase, lxfWholeCell, lxfSearchFormulas,
  lxfUseWildcards, lxfBackward, lxfByColumns);
TXLSXFindOptions = set of TXLSXFindFlag;
TXLSXReplaceAction = (raReplace, raSkip, raAbort);
TXLSXReplaceEvent = function(ARow, ACol: Integer;
  const ACurrentText: WideString; var ANewText: WideString):
  TXLSXReplaceAction of object;

{ Progress and recalculation policy }
TXLSXProgressPhase = (xlsxProgressReading, xlsxProgressWriting,
  xlsxProgressCalculating, xlsxProgressExporting);
TXLSXProgressState = (ppsBegin, ppsWork, ppsEnd);
TXLSXRecalcMode = (xrmManual, xrmIfDirty, xrmAlways);
TXLSXPasswordEvent = procedure(Sender: TObject;
  var PassWord: WideString) of object;

{ Custom document properties (docProps/custom.xml) }
TXLSXCustomPropType = (xcptText, xcptNumber, xcptDate, xcptBoolean);
TXLSXCustomProperty = class
  Name: WideString;
  PropType: TXLSXCustomPropType;
{ + TextValue, NumberValue, DateValue, BoolValue accessors }
end;

{ Table styles, fills, sorts, external links, controls, sparklines }
TXLSXTableStyleSectionKind = (xltssWholeTable, xltssHeaderRow,
  xltssTotalRow, xltssFirstColumn, xltssLastColumn, xltssFirstRowStripe,
  xltssSecondRowStripe, xltssFirstColumnStripe, xltssSecondColumnStripe,
  xltssFirstHeaderCell, xltssLastHeaderCell, xltssFirstTotalCell,
  xltssLastTotalCell { + subtotal and subheading slots });
TXLSXFillPattern = (xlsxFillNone, xlsxFillSolid, xlsxFillGray125
  { + the remaining ECMA-376 pattern values });
TXLSXGradientKind = (xlsxGradientNone, xlsxGradientLinear, xlsxGradientPath);
TXLSXSortBy = (xlsxBsValue, xlsxBsCellColor, xlsxBsFontColor, xlsxBsIcon);
TXLSXSortMethod = (xlsxSmNone, xlsxSmStroke, xlsxSmPinYin);
TXLSXExternalLinkKind = (xlsxExternalLinkUnknown, xlsxExternalLinkWorkbook,
  xlsxExternalLinkDde { + the remaining link kinds });
TXLSXFormControlType = (xfcButton, xfcCheckBox, xfcRadioButton, xfcComboBox,
  xfcListBox);
TXLSXSparklineAxisType = (xlsxSparklineAxisIndividual,
  xlsxSparklineAxisGroup, xlsxSparklineAxisCustom);
TXLSXSparklineEmptyCells = (xlsxSparklineEmptyGap, xlsxSparklineEmptyZero,
  xlsxSparklineEmptySpan);

{ Chart authoring and layout }
TXLSXChartBarGrouping = (xlsxBarGroupClustered, xlsxBarGroupStacked,
  xlsxBarGroupPercentStacked);
TXLSXChartMarkerSymbol = (xlsxMarkerAuto, xlsxMarkerCircle, xlsxMarkerDash,
  xlsxMarkerDiamond, xlsxMarkerDot, xlsxMarkerPlus, xlsxMarkerSquare,
  xlsxMarkerStar, xlsxMarkerTriangle, xlsxMarkerX, xlsxMarkerNone);
TXLSXChartDataLabelPos = (xlsxDlblPosDefault, xlsxDlblPosCenter,
  xlsxDlblPosInEnd, xlsxDlblPosOutEnd, xlsxDlblPosBestFit, xlsxDlblPosLeft,
  xlsxDlblPosRight, xlsxDlblPosTop, xlsxDlblPosBottom, xlsxDlblPosInBase);
TXLSXChartMutable = class;     { mutable base of the chart model nodes }
TXLSXChartLayoutRect = record
  Left, Top, Right, Bottom: Double;
end;
TXLSXChartResolvedLayout = record
  ChartRect: TXLSXChartLayoutRect;
  TitleRect: TXLSXChartLayoutRect;
  LegendRect: TXLSXChartLayoutRect;
  PlotOuterRect: TXLSXChartLayoutRect;
  PlotInnerRect: TXLSXChartLayoutRect;
  { + per-axis title rectangles and visibility flags }
end;

{ Pagination keep-together blocks }
TXLSXKeepTogetherRange = record
  Row1, Row2: Integer;
  Level: Integer;
  ReplaceBiggerLevels: Boolean;
end;
TXLSXKeepTogetherCols = record
  Col1, Col2: Integer;
  Level: Integer;
  ReplaceBiggerLevels: Boolean;
end;

{ Diagnostics records }
TXLSXValidationIssue = record
  Row, Col: Integer;
  ValidationIndex: Integer;
  Reason: WideString;
end;
TXLSXUnknownFunctionInfo = record
  Sheet: Integer;
  Row, Col: Integer;
  Name: WideString;
  LocationKind: TXLSFormulaSymbolLocationKind;
  DefinedNameIndex: Integer;
  DefinedName: WideString;
end;
TXLSXRowMajorOrder = record
  CellOrder: array of Integer;
  RowStarts: array of Integer;
  MaxRow: Integer;
end;
      
Find and replaceTXLSXWorksheet.FindText / FindTextIn accept TXLSXFindOptions (大文字/小文字の区別、セル全体の一致、数式の検索、ワイルドカード、後方検索、列単位) を受け付け、 ReplaceText takes a TXLSXReplaceEvent whose result selects raReplace, raSkip, or raAbort per match, with a writable ANewText for per-cell substitutions
Progress and savingTXLSXWorkbook.OnProgress / OnProgressEx deliver TXLSXProgressPhase and (extended form) TXLSXProgressState with an Abort flag; RecalcBeforeSave is a TXLSXRecalcMode シリアライズ前の再計算を、manual、dirty-only、always のいずれかで選択します。 OnPassword is a TXLSXPasswordEvent that supplies open and write passwords
Custom propertiesTXLSXWorkbook.CustomProperties is a TXLSXCustomProperties collection with typed AddText / AddNumber / AddDate / AddBoolean creators, FindByName, Delete, and Clear, plus Count and Items enumeration; each TXLSXCustomProperty tags its value with a TXLSXCustomPropType matching the ECMA-376 variant mapping
Style overlaysTXLSXStyleOverlays は、保存済みスタイルの上に範囲ごとの上書きを管理します Add creates one, ApplyToCell restyles a single cell, Resolve, ResolveRowDefault, and ResolveColumnDefault answer style lookups during load, HasVirtualStyle reports generated styles, MaxVirtualRow bounds virtual rows, ApplyStructuralEdit は行や列の編集後にオーバーレイをシフトし、 Clear, Count, and Items maintain the collection。ColumnCandidateCount(ACol) と ColumnCandidate(ACol, Index) は、列範囲がその列に達するオーバーレイをリスト順にたどります。インデックス化されているのは列だけなので、行範囲は呼び出し側が引き続き検査する必要があります
Styles, fills, and overlaysTXLSXFill exposes Pattern, GradientKind, and GradientStops through TXLSXFillPattern, TXLSXGradientKind, and TXLSXGradientStop; TXLSXWorksheet.StyleOverlays is a TXLSXStyleOverlays collection whose TXLSXStyleOverlay エントリは、矩形、影響を受ける書式部分、上書きするセル スタイルを保持します
Tables, sorts, and linksCustom table styles (TXLSXWorkbook.CustomTableStyles) build section formatting from TXLSXTableStyleSectionKind slots: the collection offers Add, FindByName, Delete, Clear, Count, and Items, while each TXLSXCustomTableStyle exposes Name, SectionSize, PivotStyle, and TableStyleFlag and answers HasSection / ResolveSection のルックアップに応答します。ソート条件はキーを TXLSXSortBy and text ordering with TXLSXSortMethod; TXLSXExternalLink.Kind is a TXLSXExternalLinkKind and each link lists TXLSXExternalDefinedName entries with Name and RefersTo
Custom XML partsTXLSXWorkbook.CustomXmlParts preserves item-specific custom XML: Add, Delete, and Clear maintain the parts, each TXLSXCustomXmlPart carries its payload in Xml plus an ItemId and a SchemaRefs string list of schema relationships (AddSchemaRef で追加)、保持されたパーツは保存時もそのままラウンドトリップされます
Cell style payloadsTXLSXCellStylePayload は、個々のセルにアタッチされる、共有可能な不変のスタイル バンドルです Acquire / Release manage its reference count, Clone copies it, IsDefault tests the default style, and InternKey は同一のペイロードを識別するので、ストレージがそれらを重複排除できます
Controls, drawings, and sparklinesTXLSXWorksheet.FormControls is a TXLSXFormControls collection of TXLSXFormControl objects — each exposes ControlType, Caption, MacroName, LinkedCell, and its Items list — typed by TXLSXFormControlType, with TXLSXFormControlItems がコントロールごとの項目テキストを保持します。描画オブジェクトの種別は TXLSXDrawingObjectKind スパークラインのグループは、軸スケーリングと空セルの動作を TXLSXSparklineAxisType and TXLSXSparklineEmptyCells
Chartsプロット グループと系列は、棒のグループ化、マーカー記号、データ ラベルの位置を TXLSXChartBarGrouping, TXLSXChartMarkerSymbol, and TXLSXChartDataLabelPos enums; the chart model nodes share the TXLSXChartMutable base class, and TXLSXChartLayoutResolver.ResolveChart fills a TXLSXChartResolvedLayout of TXLSXChartLayoutRect チャート、タイトル、凡例、プロット領域、軸タイトルの各矩形に使われます
Pagination keep blocksKeepRowsTogether / KeepColumnsTogether on the XLSX pagination surface maintain TXLSXKeepTogetherRange and TXLSXKeepTogetherCols レコードを保持し、改ページ計画が 1 つのブロックを 1 ページに収めるようにします
DiagnosticsTXLSXWorksheet.CheckDataValidations returns TXLSXValidationIssue レコード (セル、入力規則インデックス、理由) を返します。 TXLSXWorkbook.ScanUnknownFunctions returns TXLSXUnknownFunctionInfo レコードで、セルと定義名の中の未実装呼び出しを特定します。 TXLSXCells.GetStorageStatistics fills a TXLSXCellStorageStatistics レコードに、セル数、行ブロック、ペイロードごとのバイト数、スタイル付き空白の統計を格納します。 TXLSXWorksheet.BuildRowMajorCellOrder returns a TXLSXRowMajorOrder は、値の入ったセルのメモリ内走査順序を記述します
TXLSXWorkbook.FormulaLocale は、数式の解析とシリアライズに使われるロケール タグの読み書きを行い、クラシック ワークブックの数式ロケール処理と同じ動作になります

Table slicers

テーブル スライサー (Excel 2013+) は、2 つのコレクションを通じて書き出しおよび照会されます TXLSXWorksheet.Slicers holds the per-sheet slicer views (TXLSXSlicer) and TXLSXWorkbook.SlicerCaches holds the shared data sources (TXLSXSlicerCache)

property TXLSXWorksheet.Slicers: TXLSXSlicers;
property TXLSXWorkbook.SlicerCaches: TXLSXSlicerCaches;

{ TXLSXSlicers }
function Add(ATable: TXLSXTable; const AColumnName: WideString): TXLSXSlicer; overload;
function Add(ATable: TXLSXTable; const AColumnName: WideString;
  ARow1, ACol1, ARow2, ACol2: Integer): TXLSXSlicer; overload;
function IndexByName(const AName: WideString): Integer;
function FindByName(const AName: WideString): TXLSXSlicer;
procedure Delete(Index: Integer);
procedure Clear;
property Count: Integer;
property Items[Index: Integer]: TXLSXSlicer;

{ TXLSXSlicer view }
property Name: WideString;          { workbook-unique }
property CacheName: WideString;
property Cache: TXLSXSlicerCache;
property Caption: WideString;
property StartItem: Integer;
property ColumnCount: Integer;
property ColumnWidth: WideString;
property ShowCaption: Integer;
property StyleName: WideString;
property LockedPosition: Integer;
property RowHeight: WideString;
property RowHeightEmu: Integer;
procedure SetBounds(ARow1, ACol1, ARow2, ACol2: Integer);
property FromRow, FromCol, ToRow, ToCol: Integer;   { anchor cell corners }
property FromRowOff, FromColOff, ToRowOff, ToColOff: Integer; { EMU offsets }
property AnchorType: TXLSXAnchorEditAs;
property HasAnchor: Boolean;

{ TXLSXSlicers, load-path entry }
function AddInternal: TXLSXSlicer;

{ TXLSXSlicerCache }
property Name: WideString;          { e.g. Slicer_Region }
property SourceName: WideString;    { source table column / pivot field }
property IsTableCache: Boolean;
property IsPivot: Boolean;
property IsNonOlapPivot: Boolean;
property ItemCount: Integer;
property ItemCacheIndex[Index: Integer]: Integer;
property ItemSelected[Index: Integer]: Boolean;
function SetSelectedItems(const CacheItemIndices: array of Integer): Integer;
function ClearSelection: Integer;
property TableId: Integer;
property TableColumnId: Integer;
property SortOrder: WideString;     { '' | ascending | descending }
property CrossFilter: WideString;   { '' | none | showItemsWithDataAtTop | showItemsWithNoData }
property CustomListSort: Integer;   { -1 absent, else 0/1 }

{ TXLSXSlicerCaches }
function Add: TXLSXSlicerCache;
function FindByName(const AName: WideString): TXLSXSlicerCache;
function IndexOfName(const AName: WideString): Integer;
function FindForTableColumn(ATableId, ATableColumnId: Integer): TXLSXSlicerCache;
procedure Delete(Index: Integer);
procedure Clear;
property Count: Integer;
property Items[Index: Integer]: TXLSXSlicerCache;
      

Slicers.Add(Table, ColumnName) はスライサーをエンドツーエンドで構築します。次の名前を持つバッキング キャッシュを登録または再利用し、 Slicer_<column>, reserves the matching #N/A defined name, writes the worksheet slicerList 拡張を書き出し、ビューは markup-compatibility の描画アンカーで固定されます。このアンカーのフォールバック通知が古い Excel バージョンをカバーします。2 番目のオーバーロードではビューの矩形が固定され、省略時はテーブルの右側のデフォルト アンカーが使用されます

読み込まれたビューとキャッシュはオープン時に読み戻され、共有キャッシュはビュー間で再利用され、キャッシュの最後のビューを削除するとキャッシュも削除されます。認識できない属性と拡張は元の表現のまま保持され、テーブル バインディングは保存済みのテーブル ID を追跡し、サポート対象のピボット接続は保存済みのシート ID を追跡します

サポート対象のインポート済み非 OLAP ピボット キャッシュは、IsNonOlapPivot、ItemCount、ItemCacheIndex、ItemSelected、SetSelectedItems、ClearSelection を通じて、型付きメンバーの検査と保護付き選択変更を公開します。共有ビューの動作、失敗時のアトミック性、インポートされた同一フィールド マスクの境界については、ピボット スライサー選択を参照してください

サポート対象外のピボット キャッシュは元のバイトのまま保持されます。ファイルから読み込んだスライサー ビューは、描画オブジェクトとしても TXLSXDrawingObject.Slicer

Example

var
  Ref: WideString;
  Row, Col: Integer;
begin
  Ref := XlsxCellRef(10, 5);
  if XlsxParseCellRef(Ref, Row, Col) then
    Worksheet.Cells.Item[Row, Col].Value := 'Checked';
end;
    

I/O コールバック、シリアライザーのスタイル プール、暗号化ファイルの検証、ワークスペース依存関係グラフの契約については、ワークブック インフラストラクチャ API を参照してください