Artículo técnico

HotXLS: charts, images, and drawing objects 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 developers generating visual Excel reports, dashboards, or template-based workbooks in Delphi. Presenta charts, images, and drawing objects como una práctica de ingeniería documental para producción, no como una llamada aislada al componente.

El riesgo principal es que visual workbook elements fail when anchors, sheet changes, chart ranges, image DPI, and drawing identifiers are treated as decorative afterthoughts. Por eso el flujo necesita contrato escrito, diagnósticos observables y archivos de regresión reales.

Decisiones de arquitectura

Treat drawings as workbook data. chart data range ownership and whether ranges expand with inserted rows / image source, DPI, compression, transparency, and alternate text policy

  • chart data range ownership and whether ranges expand with inserted rows
  • image source, DPI, compression, transparency, and alternate text policy
  • object anchoring behavior when cells resize, hide, or move
  • whether existing drawings are preserved, replaced, or regenerated from templates

Flujo de implementación

Bind visuals to stable ranges and anchors. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. prepare named ranges or stable addresses before creating chart objects
  2. normalize image dimensions and compression before insertion
  3. place drawings with the intended cell anchor and movement behavior
  4. recalculate or refresh chart ranges after data changes
  5. open the workbook in the target Excel version and inspect layout at print scale

Evidencia de validación

Visual-output evidence for workbook support. Keep these fields with the output or support record.

  • chart type, source range, sheet name, and series count
  • image dimensions, DPI, compression mode, anchor cell, and object identifier
  • drawing preservation or regeneration decision for each template object
  • viewer compatibility notes for Excel, LibreOffice, or downstream conversion

A chart depends on workbook structure

Charts, pictures, and shapes are connected to sheets, cell anchors, relationships, and sometimes formulas. A reliable workflow keeps those relationships stable when rows, columns, templates, or sheet order change.

Notas de implementación para producción

Trata HotXLS: charts, images, and drawing objects 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 BuildSalesDashboardWorkbook(const OutputFile, LogoFile: string; const Rows: TArray<TSalesRow>);
var
  Wb: TXLSXWorkbook;
  Sh: IXLSWorksheet;
  RowIndex: Integer;
  Row: TSalesRow;
begin
  Wb := TXLSXWorkbook.Create;
  try
    Sh := Wb.Sheets[0];
    Sh.Name := 'Dashboard';
    Sh.Range['A1'].Value := 'Quarter';
    Sh.Range['B1'].Value := 'Revenue';
    Sh.Range['C1'].Value := 'Margin';
    Sh.Range['D1'].Value := 'Pipeline';

    RowIndex := 2;
    for Row in Rows do
    begin
      Sh.Range['A' + IntToStr(RowIndex)].Value := Row.Quarter;
      Sh.Range['B' + IntToStr(RowIndex)].Value := Row.Revenue;
      Sh.Range['C' + IntToStr(RowIndex)].Value := Row.Margin;
      Sh.Range['D' + IntToStr(RowIndex)].Value := Row.Pipeline;
      Inc(RowIndex);
    end;

    Sh.Range['A1:D1'].ApplyBuiltinStyle(xbsTitle);
    Sh.Range['A2:D' + IntToStr(RowIndex - 1)].ApplyBuiltinStyle(xbsGood);
    AddColumnChart(Sh, 'A1:D' + IntToStr(RowIndex - 1), 'F3:M18');
    AddImageIfPresent(Sh, LogoFile, 'F1');
    WriteWorkbookAudit(Wb, 'dashboard', 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