Artículo técnico

HotXLS Component: large workbook performance in Delphi

Cree, edite, inspeccione, calcule y exporte libros de Excel directamente desde código Delphi o C++Builder. HotXLS es una biblioteca nativa Object Pascal para XLS y XLSX, disenada para herramientas de escritorio, trabajos por lotes, informes y generacion de documentos sin automatización de Microsoft Excel.

Este artículo está dirigido a teams generating or processing large XLS/XLSX workbooks in desktop utilities, services, or batch jobs. Presenta large workbook performance como una práctica de ingeniería documental para producción, no como una llamada aislada al componente.

El riesgo principal es que large-workbook workflows fail when shared strings, styles, formulas, memory buffers, and output streams are not managed as production resources. Por eso el flujo necesita contrato escrito, diagnósticos observables y archivos de regresión reales.

Decisiones de arquitectura

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

Flujo de implementación

Measure workbook size during generation. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. create capacity fixtures that represent real customer data distribution
  2. reuse styles and strings instead of generating unique resources per cell
  3. write rows in controlled batches and flush output only at safe boundaries
  4. track memory, elapsed time, file size, and warning counts per stage
  5. open large output with the target application before increasing limits

Evidencia de validación

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.

Notas de implementación para producción

Trata HotXLS Component: large workbook performance in Delphi como un contrato de servicio claro alrededor de las llamadas a HotXLS, separando validación de entrada, escritura del libro, comprobación de salida y evidencias de soporte

  • Define origen de datos, rangos de celdas y formato de salida antes de crear el libro
  • Registra filas, hojas, advertencias y ruta de salida en una evidencia revisable
  • Encapsula los detalles propios de la aplicación en helpers comprobables, no en eventos de interfaz
  • Vuelve a abrir o inspecciona el archivo guardado antes de entregarlo a otro sistema o al cliente

Fallos que conviene ensayar

  • Que SaveAs devuelva éxito no demuestra que el contrato de negocio siga siendo correcto
  • Fuentes, permisos y configuración regional pueden cambiar entre servidor y equipo de desarrollo
  • Los logs no deben exponer contraseñas, datos de clientes ni enlaces internos

Ejemplo Delphi detallado

El siguiente ejemplo Delphi muestra una frontera de servicio práctica para este tema y mantiene políticas, registro y validación en una capa comprobable

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;

Lista de salida a producción

  • 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