Delphi または C++Builder コードから直接 Excel ワークブックを作成、編集、検査、計算、エクスポートできます。HotXLS はソース付き Object Pascal スプレッドシートライブラリで、XLS/XLSX ワークフロー、デスクトップツール、バッチジョブ、レポート、Excel 自動化なしのサーバー側生成に適しています。
この記事は teams generating or processing large XLS/XLSX workbooks in desktop utilities, services, or batch jobs 向けです。large workbook performance を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。
実務上のリスクは large-workbook workflows fail when shared strings, styles, formulas, memory buffers, and output streams are not managed as production resources です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。
アーキテクチャ上の判断
Plan memory, styles, and streaming together. maximum row count, column count, sheet count, and output file size / shared-string strategy, style reuse, formula volume, and image policy
- maximum row count, column count, sheet count, and output file size
- shared-string strategy, style reuse, formula volume, and image policy
- streaming write boundaries, temporary storage, progress, and cancellation
- Excel compatibility limits and downstream import limits
実装フロー
Measure workbook size during generation. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- create capacity fixtures that represent real customer data distribution
- reuse styles and strings instead of generating unique resources per cell
- write rows in controlled batches and flush output only at safe boundaries
- track memory, elapsed time, file size, and warning counts per stage
- open large output with the target application before increasing limits
検証エビデンス
Performance evidence for capacity planning. Keep these fields with the output or support record.
- row count, column count, sheet count, style count, shared-string count, and file size
- memory peak, elapsed time, batch size, temporary storage, and cancellation result
- formula count, image count, comment count, and relationship count
- target Excel or importer open time for representative output
Rows are not the only scale factor
Workbook size grows with cells, styles, shared strings, formulas, images, comments, and relationships. A performance plan should reduce redundant resources and choose streaming only where it fits the output contract.
本番実装の要点
HotXLS Component: Delphi での large workbook performance は HotXLS 呼び出しの前後に置く明確なサービス契約として扱い、入力検証、ブック作成、出力確認、サポート証跡を分離します
- ブックを作成する前にデータソース、セル範囲、出力形式を確定する
- 行数、シート数、警告、出力先をレビュー可能な証跡として記録する
- アプリ固有の処理は UI イベントではなくテスト可能な helper に閉じ込める
- 保存済みファイルを別システムや顧客へ渡す前に再オープンまたは検査する
事前に試験すべき失敗パターン
- SaveAs の成功だけでは業務契約が正しいとは言えません
- サーバーと開発機ではフォント、権限、地域設定が異なることがあります
- ログにパスワード、顧客データ、内部リンクを残してはいけません
詳しい Delphi サンプル
次の Delphi 例は、このテーマをサービス境界として実装する形を示し、ポリシー、ログ、検証をテスト可能な層に分けます
procedure WriteLargeLedgerWorkbook(const OutputFile: string; const Source: ILedgerReader);
var
Wb: TXLSXWorkbook;
Sh: IXLSWorksheet;
RowIndex: Integer;
Batch: TArray<TLedgerRow>;
Item: TLedgerRow;
Metrics: TWorkbookMetrics;
begin
Wb := TXLSXWorkbook.Create;
try
Sh := Wb.Sheets[0];
Sh.Name := 'Ledger';
WriteHeaderRow(Sh, ['Account', 'Date', 'Description', 'Debit', 'Credit', 'Balance']);
RowIndex := 2;
Metrics := StartWorkbookMetrics('large-ledger');
repeat
Batch := Source.ReadNextBatch(5000);
for Item in Batch do
begin
WriteLedgerRow(Sh, RowIndex, Item);
Inc(RowIndex);
end;
CheckMemoryAndTempQuota(Metrics, RowIndex - 2);
FlushProgressMetric(Metrics, RowIndex - 2);
until Length(Batch) = 0;
Sh.Range['A1:F1'].ApplyBuiltinStyle(xbsTitle);
AddSummarySheet(Wb, Metrics, RowIndex - 2);
AssertWorkbookSizePolicy(OutputFile, 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