Articolo tecnico

HotXLS Component: XLSX AES-protected output in Delphi

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 delivering password-protected XLSX files from Delphi services or desktop applications. Tratta XLSX AES-protected output come ingegneria documentale di produzione, non come una semplice chiamata al componente.

Il rischio pratico è che protected workbook output can satisfy a password prompt but still fail policy if key handling, password delivery, viewer compatibility, and unsupported encrypted-read paths are unclear. Per questo il flusso richiede un contratto scritto, diagnostica osservabile e file di regressione realistici.

Decisioni architetturali

Separate workbook protection from file encryption. password generation, delivery, rotation, escrow, and retry policy / difference between workbook structure protection, sheet protection, and file encryption

  • password generation, delivery, rotation, escrow, and retry policy
  • difference between workbook structure protection, sheet protection, and file encryption
  • supported target applications and whether encrypted input reading is part of scope
  • temporary file and support-bundle handling for protected workbooks

Percorso di implementazione

Create protected output from a named security profile. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. generate the workbook content and validate it before applying file encryption
  2. select the AES protection profile and obtain the password through approved code paths
  3. save the protected XLSX to a controlled temporary destination
  4. test open behavior with target Excel versions or downstream consumers
  5. log security profile identifiers without logging secrets

Evidenze di validazione

Protection evidence for delivery and support. Keep these fields with the output or support record.

  • security profile, output format, protection mode, target viewer test, and output hash
  • password delivery channel identifier without password value
  • temporary path, cleanup result, and retention rule
  • viewer compatibility result and operator-facing failure reason

Password-protected XLSX still needs workflow policy

AES-protected output is a delivery decision. The application should know how passwords are generated, transmitted, rotated, and never logged; it should also verify that target viewers can open the result.

Note di implementazione per la produzione

Tratta HotXLS Component: XLSX AES-protected output 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 SaveProtectedXlsxReport(const OutputFile, Password: string; const Rows: TArray<TSecureRow>);
var
  Wb: TXLSXWorkbook;
  Sh: IXLSWorksheet;
  RowIndex: Integer;
  Row: TSecureRow;
  Policy: TEncryptionPolicy;
begin
  RequireStrongWorkbookPassword(Password);
  Policy := BuildEncryptionPolicy('customer-delivery', 256);
  Wb := TXLSXWorkbook.Create;
  try
    Sh := Wb.Sheets[0];
    Sh.Name := 'Secure Export';
    WriteHeaderRow(Sh, ['RecordId', 'Owner', 'Amount', 'Status']);

    RowIndex := 2;
    for Row in Rows do
    begin
      Sh.Range['A' + IntToStr(RowIndex)].Value := Row.RecordId;
      Sh.Range['B' + IntToStr(RowIndex)].Value := Row.Owner;
      Sh.Range['C' + IntToStr(RowIndex)].Value := Row.Amount;
      Sh.Range['D' + IntToStr(RowIndex)].Value := Row.Status;
      Inc(RowIndex);
    end;

    WriteEncryptionAuditSheet(Wb, Policy, RowIndex - 2);
    SaveAsEncryptedWorkbook(Wb, OutputFile, Password, Policy);
    VerifyEncryptedWorkbookCanOpen(OutputFile, Password);
    RegisterSecureDelivery(OutputFile, Policy);
  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

Product documentation

HotXLS Component