Maak, bewerk, inspecteer, bereken en exporteer Excel-workbooks rechtstreeks vanuit Delphi- of C++Builder-code. HotXLS is een native Object Pascal-spreadsheetbibliotheek met broncode voor XLS- en XLSX-workflows, ontworpen voor desktoptools, batchtaken, rapportagesystemen en server-side documentgeneratie zonder Microsoft Excel-automatisering.
Dit artikel is bedoeld voor developers delivering workbooks that users review, print, and partly edit under controlled rules. Het behandelt protection, page setup, and printing als productiegerichte documentengineering, niet als een losse componentaanroep.
Het praktische risico is dat sheet protection and print settings are easy to apply but hard to support when editable ranges, headers, page breaks, scaling, and printer assumptions are undocumented. Daarom heeft de workflow een geschreven contract, observeerbare diagnose en representatieve regressiebestanden nodig.
Architectuurbeslissingen
Define edit and print intent together. locked cells, editable ranges, sheet protection password, and allowed user actions / print area, repeat rows and columns, headers, footers, margins, scaling, and orientation
- locked cells, editable ranges, sheet protection password, and allowed user actions
- print area, repeat rows and columns, headers, footers, margins, scaling, and orientation
- manual versus automatic page breaks and how generated rows affect them
- whether protection is advisory workflow control or part of a stronger governance model
Implementatiepad
Apply protection after layout is final. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- finish data generation and layout expansion before enabling protection
- mark editable ranges and validate that formulas and headers remain locked
- apply page setup, print titles, margins, scaling, and page breaks
- open print preview in the target workbook application
- record the protection and print profile used for support
Validatiebewijs
Workbook evidence for print and protection disputes. Keep these fields with the output or support record.
- protected sheets, editable ranges, allowed actions, and password policy identifier
- print area, repeat titles, margins, orientation, scaling, and page count
- manual page breaks and dynamic row expansion results
- preview or printed-output verification for representative data volumes
Protection is workflow guidance, not security alone
Workbook protection helps guide user edits, while page setup controls physical output. They interact: locked cells, print areas, headers, scaling, and page breaks should all match the business document contract.
Implementatienotities voor productie
Behandel HotXLS: protection, page setup, and printing in Delphi als een expliciet servicecontract rond de HotXLS-aanroepen, met gescheiden invoercontrole, werkmapopbouw, uitvoercontrole en supportbewijs
- Leg gegevensbron, celbereiken en uitvoerformaat vast voordat de werkmap wordt gemaakt
- Log rijenaantal, bladen, waarschuwingen en uitvoerpad in controleerbaar supportbewijs
- Plaats applicatiespecifieke details in testbare helpers in plaats van UI-events
- Open of inspecteer het opgeslagen bestand voordat het naar een ander systeem of klant gaat
Foutscenario's om te oefenen
- Een geslaagde SaveAs bewijst niet dat het zakelijke contract klopt
- Lettertypen, rechten en regionale instellingen kunnen verschillen tussen server en ontwikkelmachine
- Logs mogen geen wachtwoorden, klantgegevens of interne links onthullen
Uitgebreid Delphi-voorbeeld
Het volgende Delphi-voorbeeld toont een praktische servicegrens voor dit onderwerp en houdt beleid, logging en validatie testbaar gescheiden
procedure BuildProtectedPrintWorkbook(const OutputFile: string; const Rows: TArray<TPrintRow>);
var
Wb: TXLSWorkbook;
Sh: IXLSWorksheet;
RowIndex: Integer;
Row: TPrintRow;
begin
Wb := TXLSWorkbook.Create;
try
Sh := Wb.Sheets[1];
Sh.Name := 'Print Pack';
WriteHeaderRow(Sh, ['Item', 'Owner', 'Due', 'Amount']);
RowIndex := 2;
for Row in Rows do
begin
Sh.Range['A' + IntToStr(RowIndex)].Value := Row.ItemName;
Sh.Range['B' + IntToStr(RowIndex)].Value := Row.Owner;
Sh.Range['C' + IntToStr(RowIndex)].Value := Row.DueDate;
Sh.Range['D' + IntToStr(RowIndex)].Value := Row.Amount;
Inc(RowIndex);
end;
Sh.Range['A1:D1'].ApplyBuiltinStyle(xbsTitle);
ConfigurePrintArea(Sh, 'A1:D' + IntToStr(RowIndex - 1));
ConfigurePageSetup(Sh, poLandscape, psFitToWidth);
LockFormulaCellsOnly(Sh);
ProtectWorksheetForReview(Sh, 'review-password');
if Wb.SaveAs(OutputFile) <> 1 then
RaiseWorkbookSaveError(OutputFile);
finally
Wb.Free;
end;
end;
Productiechecklist
- 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