技術記事

HotXLS Component: Delphi での VBA payload and external link preservation

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

この記事は teams editing workbook content while preserving macro payloads and link relationships they do not own 向けです。VBA payload and external link preservation を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。

実務上のリスクは a workbook can save successfully while silently dropping VBA projects, changing link targets, or refreshing data connections against policy です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。

アーキテクチャ上の判断

Identify protected workbook assets before editing. whether macro-enabled workbooks are accepted, preserved, blocked, or converted / external link inventory, update policy, trusted domains, and refresh behavior

  • whether macro-enabled workbooks are accepted, preserved, blocked, or converted
  • external link inventory, update policy, trusted domains, and refresh behavior
  • which workbook edits are allowed without rewriting protected payloads
  • security warning, operator review, and audit-report requirements

実装フロー

Preserve opaque payloads unless policy says otherwise. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. inventory VBA projects, external links, data connections, and defined names before editing
  2. load worksheet data changes without executing or refreshing external content
  3. preserve opaque payloads where policy allows and mark blocked content clearly
  4. save in a format that supports the required payloads
  5. compare pre-save and post-save inventories before delivery

検証エビデンス

Preservation evidence for governed workbooks. Keep these fields with the output or support record.

  • macro presence, VBA project preservation status, and macro-enabled format decision
  • external link targets, trusted or blocked status, and refresh policy
  • payload inventory before and after save
  • operator decision for workbooks with governed content

Preservation is not execution

Preserving VBA payloads and external links means keeping workbook structures intact while clearly avoiding automatic trust or execution. The application should inventory what exists and decide what is allowed to change.

本番実装の要点

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

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

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

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

詳しい Delphi サンプル

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

procedure UpdateLinkedWorkbookWithoutBreakingMacros(const InputFile, OutputFile: string; const Update: TWorkbookUpdate);
var
  Wb: TXLSXWorkbook;
  BeforeState: TMacroLinkInventory;
  AfterState: TMacroLinkInventory;
begin
  RequireFileExists(InputFile);
  Wb := TXLSXWorkbook.Create;
  try
    Wb.Open(InputFile);
    BeforeState := CaptureMacroAndLinkInventory(Wb);
    AssertAllowedExternalLinks(BeforeState, Update.AllowedLinkHosts);

    SetNamedValue(Wb, 'RefreshDate', Update.RefreshDate);
    FillNamedTable(Wb, 'DataRefreshRows', Update.Rows);
    Wb.Calculate;

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

    AfterState := InspectMacroAndLinkInventory(OutputFile);
    AssertMacroModulesPreserved(BeforeState, AfterState);
    AssertExternalLinksPolicy(AfterState, Update.AllowedLinkHosts);
    WriteMacroLinkAudit(OutputFile, BeforeState, AfterState);
  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