Delphi または C++Builder コードから直接 Excel ワークブックを作成、編集、検査、計算、エクスポートできます。HotXLS はソース付き Object Pascal スプレッドシートライブラリで、XLS/XLSX ワークフロー、デスクトップツール、バッチジョブ、レポート、Excel 自動化なしのサーバー側生成に適しています。
この記事は teams that need fast workbook triage before loading formulas, styles, and cell data 向けです。sheet listing and lightweight workbook inspection を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。
実務上のリスクは opening full workbook content just to list sheets wastes time and memory, and it can expose unsupported features too late in the process です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。
アーキテクチャ上の判断
Inspect package facts before full parsing. which facts are required before full workbook load / handling for hidden sheets, very hidden sheets, chart sheets, and unsupported sheet types
- which facts are required before full workbook load
- handling for hidden sheets, very hidden sheets, chart sheets, and unsupported sheet types
- maximum package size, sheet count, and intake timeout
- routing rules for files that only need metadata versus full calculation
実装フロー
Use sheet inventory as an intake gate. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- open the workbook in an inspection path that avoids unnecessary cell materialization
- read format, package metadata, sheet list, visibility, and rough dimensions
- classify the workbook as preview, audit, convert, reject, or full-load
- show sheet inventory to operators when routing depends on workbook structure
- log inspection facts before deeper processing mutates state
検証エビデンス
Inspection evidence for routing decisions. Keep these fields with the output or support record.
- format, file size, sheet count, sheet order, visibility, and sheet type
- metadata such as creator, modified time, and application when available
- routing result and reason based on lightweight facts
- warnings for encrypted, damaged, macro-enabled, or oversized packages
Triage should be cheap and trustworthy
A lightweight inspection step should capture workbook format, sheet names, visibility, order, types, dimensions when available, and package-level warnings. That information is enough to route many files before deep processing.
本番実装の要点
HotXLS Component: Delphi での sheet listing and lightweight workbook inspection は HotXLS 呼び出しの前後に置く明確なサービス契約として扱い、入力検証、ブック作成、出力確認、サポート証跡を分離します
- ブックを作成する前にデータソース、セル範囲、出力形式を確定する
- 行数、シート数、警告、出力先をレビュー可能な証跡として記録する
- アプリ固有の処理は UI イベントではなくテスト可能な helper に閉じ込める
- 保存済みファイルを別システムや顧客へ渡す前に再オープンまたは検査する
事前に試験すべき失敗パターン
- SaveAs の成功だけでは業務契約が正しいとは言えません
- サーバーと開発機ではフォント、権限、地域設定が異なることがあります
- ログにパスワード、顧客データ、内部リンクを残してはいけません
詳しい Delphi サンプル
次の Delphi 例は、このテーマをサービス境界として実装する形を示し、ポリシー、ログ、検証をテスト可能な層に分けます
procedure WriteWorkbookInspectionIndex(const SourceFile, OutputFile: string);
var
Wb: TXLSXWorkbook;
IndexSheet: IXLSWorksheet;
Sh: IXLSWorksheet;
SheetIndex: Integer;
RowIndex: Integer;
begin
RequireFileExists(SourceFile);
Wb := TXLSXWorkbook.Create;
try
Wb.Open(SourceFile);
IndexSheet := AddWorksheet(Wb, 'Inspection Index');
WriteHeaderRow(IndexSheet, ['No', 'Sheet', 'UsedRange', 'FormulaCells', 'Warnings']);
RowIndex := 2;
for SheetIndex := 0 to Wb.Sheets.Count - 1 do
begin
Sh := Wb.Sheets[SheetIndex];
IndexSheet.Range['A' + IntToStr(RowIndex)].Value := SheetIndex + 1;
IndexSheet.Range['B' + IntToStr(RowIndex)].Value := Sh.Name;
IndexSheet.Range['C' + IntToStr(RowIndex)].Value := GetUsedRangeAddress(Sh);
IndexSheet.Range['D' + IntToStr(RowIndex)].Value := CountFormulaCells(Sh);
IndexSheet.Range['E' + IntToStr(RowIndex)].Value := BuildSheetWarnings(Sh);
Inc(RowIndex);
end;
AddAutoFilterToHeader(IndexSheet, 'A1:E' + IntToStr(RowIndex - 1));
WriteInspectionAudit(Wb, SourceFile, RowIndex - 2);
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