Delphi または C++Builder コードから直接 Excel ワークブックを作成、編集、検査、計算、エクスポートできます。HotXLS はソース付き Object Pascal スプレッドシートライブラリで、XLS/XLSX ワークフロー、デスクトップツール、バッチジョブ、レポート、Excel 自動化なしのサーバー側生成に適しています。
この記事は teams producing many workbooks from services, schedulers, APIs, or report farms 向けです。streaming write and server batch jobs を単なるコンポーネント呼び出しではなく、本番向けのドキュメントエンジニアリングとして扱います。
実務上のリスクは batch generation can overload memory, leave temporary files, retry unsafe stages, or hide partial output unless job boundaries are explicit です。そのため、明確な契約、観測可能な診断、実際の顧客ファイルに近い回帰サンプルが必要です。
アーキテクチャ上の判断
Treat every workbook as an isolated job. job identifier, output destination, retry policy, timeout, and cancellation behavior / temporary file location, cleanup, quota, and retention for failed workbooks
- job identifier, output destination, retry policy, timeout, and cancellation behavior
- temporary file location, cleanup, quota, and retention for failed workbooks
- batch size, concurrency level, progress reporting, and back-pressure
- which validation can run before final upload or delivery
実装フロー
Stream output only after validation checkpoints are defined. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- assign a job identifier and output boundary before opening the workbook writer
- prepare styles, sheets, and headers before streaming row data
- write rows in batches and checkpoint progress for operators
- validate size, sheet count, row count, and key formulas before final delivery
- clean or retain temporary files according to success, cancellation, or failure
検証エビデンス
Batch evidence for operators. Keep these fields with the output or support record.
- job identifier, batch item count, row count, output size, elapsed time, and memory peak
- stage timings for data load, workbook write, validation, save, and upload
- temporary path, cleanup status, retry count, and cancellation reason
- operator-facing failure reason and whether retry is safe
Streaming is a resource policy
Streaming write helps scale workbook generation, but it also limits which parts of the workbook can be revisited later. The job design should decide what must be known before streaming begins.
本番実装の要点
HotXLS Component: Delphi での streaming write and server batch jobs は HotXLS 呼び出しの前後に置く明確なサービス契約として扱い、入力検証、ブック作成、出力確認、サポート証跡を分離します
- ブックを作成する前にデータソース、セル範囲、出力形式を確定する
- 行数、シート数、警告、出力先をレビュー可能な証跡として記録する
- アプリ固有の処理は UI イベントではなくテスト可能な helper に閉じ込める
- 保存済みファイルを別システムや顧客へ渡す前に再オープンまたは検査する
事前に試験すべき失敗パターン
- SaveAs の成功だけでは業務契約が正しいとは言えません
- サーバーと開発機ではフォント、権限、地域設定が異なることがあります
- ログにパスワード、顧客データ、内部リンクを残してはいけません
詳しい Delphi サンプル
次の Delphi 例は、このテーマをサービス境界として実装する形を示し、ポリシー、ログ、検証をテスト可能な層に分けます
procedure RunWorkbookBatch(const Jobs: TArray<TWorkbookJob>);
var
Job: TWorkbookJob;
JobResult: TWorkbookJobResult;
begin
for Job in Jobs do
begin
StartJobAudit(Job.Id, Job.OutputFile);
try
RequireWritableDestination(Job.OutputFile);
RequireTempQuota(Job.TempFolder, Job.ExpectedRows);
JobResult := WriteWorkbookJob(Job);
ValidateWorkbookForDelivery(JobResult.OutputFile, JobResult.ExpectedRows);
CompleteJobAudit(Job.Id, JobResult);
except
on E: Exception do
begin
MarkJobFailed(Job.Id, E.Message, CanRetryWorkbookJob(Job));
CleanupOrRetainTempFiles(Job, E);
raise;
end;
end;
end;
end;
function WriteWorkbookJob(const Job: TWorkbookJob): TWorkbookJobResult;
var
Wb: TXLSXWorkbook;
Sh: IXLSWorksheet;
begin
Wb := TXLSXWorkbook.Create;
try
Sh := Wb.Sheets[0];
Sh.Name := 'Batch Output';
StreamRowsIntoWorksheet(Sh, Job.Reader, Job.Progress);
WriteBatchMetricsSheet(Wb, Job);
if Wb.SaveAs(Job.OutputFile) <> 1 then
RaiseWorkbookSaveError(Job.OutputFile);
Result := BuildWorkbookJobResult(Job);
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