技術記事

HotXLS Component: Delphi での workbook metadata and document properties

Delphi または C++Builder コードから直接 Excel ワークブックを作成、編集、検査、計算、エクスポートできます。HotXLS はソース付き Object Pascal スプレッドシートライブラリで、XLS/XLSX ワークフロー、デスクトップツール、バッチジョブ、レポート、Excel 自動化なしのサーバー側生成に適しています。

この記事は teams integrating workbook output with document management, search, audit, or customer-delivery systems 向けです。workbook metadata and document properties を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。

実務上のリスクは metadata is often copied from templates accidentally, causing wrong authors, stale revision labels, missing retention fields, or poor search results です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。

アーキテクチャ上の判断

Own metadata as delivery data. standard properties such as title, subject, author, company, category, and keywords / custom properties needed for customer, job, retention, version, or workflow state

  • standard properties such as title, subject, author, company, category, and keywords
  • custom properties needed for customer, job, retention, version, or workflow state
  • whether metadata can expose personal data, internal IDs, or confidential notes
  • revision, generated-by, and template-version strategy

実装フロー

Set properties from the business record. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. clear template metadata that should not reach generated output
  2. populate standard and custom properties from the business record
  3. validate required properties before saving or uploading the workbook
  4. include metadata in search or DMS hand-off checks
  5. audit final properties when support bundles are created

検証エビデンス

Metadata evidence for document management. Keep these fields with the output or support record.

  • standard property values, custom property names, and required-property status
  • template version, generator version, job identifier, and retention category
  • privacy review for metadata fields that may expose sensitive values
  • DMS or search-index acceptance result

Workbook metadata is visible outside Excel

Document properties are consumed by search indexes, records systems, portals, DMS workflows, and support staff. They should be generated deliberately rather than inherited accidentally from a designer's template file.

本番実装の要点

HotXLS Component: Delphi での workbook metadata and document properties は HotXLS 呼び出しの前後に置く明確なサービス契約として扱い、入力検証、ブック作成、出力確認、サポート証跡を分離します

  • ブックを作成する前にデータソース、セル範囲、出力形式を確定する
  • 行数、シート数、警告、出力先をレビュー可能な証跡として記録する
  • アプリ固有の処理は UI イベントではなくテスト可能な helper に閉じ込める
  • 保存済みファイルを別システムや顧客へ渡す前に再オープンまたは検査する

事前に試験すべき失敗パターン

  • SaveAs の成功だけでは業務契約が正しいとは言えません
  • サーバーと開発機ではフォント、権限、地域設定が異なることがあります
  • ログにパスワード、顧客データ、内部リンクを残してはいけません

詳しい Delphi サンプル

次の Delphi 例は、このテーマをサービス境界として実装する形を示し、ポリシー、ログ、検証をテスト可能な層に分けます

procedure StampWorkbookMetadata(const InputFile, OutputFile: string; const Props: TWorkbookDocumentProperties);
var
  Wb: TXLSXWorkbook;
  Cover: IXLSWorksheet;
begin
  RequireFileExists(InputFile);
  Wb := TXLSXWorkbook.Create;
  try
    Wb.Open(InputFile);
    ApplyDocumentProperties(Wb, Props);
    Cover := EnsureWorksheet(Wb, 'Document Info');
    Cover.Range['A1'].Value := 'Document owner';
    Cover.Range['B1'].Value := Props.Owner;
    Cover.Range['A2'].Value := 'Classification';
    Cover.Range['B2'].Value := Props.Classification;
    Cover.Range['A3'].Value := 'Retention profile';
    Cover.Range['B3'].Value := Props.RetentionProfile;
    Cover.Range['A1:B3'].ApplyBuiltinStyle(xbsGood);

    AssertMetadataPolicy(Wb, Props);
    WriteMetadataAudit(Wb, Props);

    if Wb.SaveAs(OutputFile) <> 1 then
      RaiseWorkbookSaveError(OutputFile);
  finally
    Wb.Free;
  end;
end;

本番チェックリスト

  • Run the workflow on an empty workbook, a normal customer workbook, and a worst-case workbook
  • Open the output with the target spreadsheet application or downstream importer
  • Log product version, template version, profile, row count, output path, elapsed time, and warning count
  • Keep passwords, temporary files, customer data, and support bundles under explicit retention rules
  • Add regression workbooks when a customer file exposes a new edge case

Product documentation

HotXLS Component