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 exporting workbook data to integration feeds, web previews, reports, and legacy document flows. Het behandelt CSV, TSV, HTML, and RTF export als productiegerichte documentengineering, niet als een losse componentaanroep.
Het praktische risico is dat export formats lose workbook semantics in different ways, so data, encoding, formulas, styles, and selected ranges need explicit product policy. Daarom heeft de workflow een geschreven contract, observeerbare diagnose en representatieve regressiebestanden nodig.
Architectuurbeslissingen
Define the target format contract. selected sheets, ranges, headers, hidden rows, and filtered data policy / encoding, delimiter, quote, newline, decimal, and date formatting rules
- selected sheets, ranges, headers, hidden rows, and filtered data policy
- encoding, delimiter, quote, newline, decimal, and date formatting rules
- formula output as cached values, formulas, or blocked content
- style preservation expectations for HTML and RTF compared with workbook layout
Implementatiepad
Choose data fidelity before visual fidelity. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- select the export profile from the target system rather than from file extension alone
- normalize data types and locale-sensitive formats before writing delimited output
- escape delimiters, quotes, line breaks, and HTML-sensitive characters deliberately
- record which workbook features were dropped or simplified
- validate exported files with the downstream importer or browser target
Validatiebewijs
Export evidence for downstream consumers. Keep these fields with the output or support record.
- format, encoding, delimiter, selected range, row count, and column count
- formula handling, hidden-row policy, filter policy, and style-loss warnings
- downstream import result or web-preview verification
- sample records showing quote, newline, Unicode, date, and number behavior
Every export format is a tradeoff
CSV and TSV emphasize delimited data, HTML emphasizes presentation and web preview, and RTF emphasizes styled document interchange. The application should decide which workbook features are preserved, flattened, or rejected.
Implementatienotities voor productie
Behandel HotXLS Component: CSV, TSV, HTML, and RTF export 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 ExportWorkbookViews(const WorkbookFile, OutputFolder: string; const Profiles: TArray<TExportProfile>);
var
Wb: TXLSXWorkbook;
Profile: TExportProfile;
ExportPath: string;
begin
RequireFolder(OutputFolder);
Wb := TXLSXWorkbook.Create;
try
Wb.Open(WorkbookFile);
for Profile in Profiles do
begin
RequireExportRange(Wb, Profile.SheetName, Profile.RangeAddress);
ExportPath := BuildExportPath(OutputFolder, Profile);
case Profile.Format of
efCsv: ExportRangeAsCsv(Wb, Profile, ExportPath);
efTsv: ExportRangeAsTsv(Wb, Profile, ExportPath);
efHtml: ExportRangeAsHtml(Wb, Profile, ExportPath);
else
RaiseUnsupportedExportFormat(Profile.Format);
end;
ValidateExportRecordCount(Profile, ExportPath);
AppendExportManifest(OutputFolder, Profile, ExportPath);
end;
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