Crea, modifica, ispeziona, calcola ed esporta cartelle di lavoro Excel direttamente da Delphi o C++Builder. HotXLS e una libreria nativa Object Pascal per XLS e XLSX, progettata per strumenti desktop, batch, report e generazione documenti senza automazione Microsoft Excel.
Questo articolo è rivolto a teams producing many workbooks from services, schedulers, APIs, or report farms. Tratta streaming write and server batch jobs come ingegneria documentale di produzione, non come una semplice chiamata al componente.
Il rischio pratico è che batch generation can overload memory, leave temporary files, retry unsafe stages, or hide partial output unless job boundaries are explicit. Per questo il flusso richiede un contratto scritto, diagnostica osservabile e file di regressione realistici.
Decisioni architetturali
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
Percorso di implementazione
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
Evidenze di validazione
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.
Note di implementazione per la produzione
Tratta HotXLS: streaming write and server batch jobs in Delphi come un contratto di servizio esplicito attorno alle chiamate HotXLS, separando validazione dell'input, scrittura della cartella, controllo dell'output ed evidenze di supporto
- Definire origine dati, intervalli di celle e formato di output prima di creare la cartella
- Registrare righe, fogli, avvisi e percorso di output in una prova verificabile
- Incapsulare i dettagli applicativi in helper testabili invece che in eventi UI
- Riaprire o ispezionare il file salvato prima di consegnarlo a un altro sistema o al cliente
Casi di errore da provare
- Un SaveAs riuscito non prova che il contratto di business sia corretto
- Font, permessi e impostazioni locali possono variare tra server e macchina di sviluppo
- I log non devono esporre password, dati cliente o link interni
Esempio Delphi dettagliato
L'esempio Delphi seguente mostra un confine di servizio pratico per questo tema, mantenendo policy, logging e validazione in un livello testabile
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;
Checklist di produzione
- 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