Erstellen, bearbeiten, pruefen, berechnen und exportieren Sie Excel-Arbeitsmappen direkt aus Delphi- oder C++Builder-Code. HotXLS ist eine native Object-Pascal-Bibliothek fuer XLS und XLSX, entwickelt fuer Desktop-Tools, Batchauftraege, Berichte und Dokumenterzeugung ohne Microsoft-Excel-Automatisierung.
Dieser Artikel richtet sich an developers exporting workbook data to integration feeds, web previews, reports, and legacy document flows. Er behandelt CSV, TSV, HTML, and RTF export als produktive Dokumenttechnik und nicht als kurzen Komponentenaufruf.
Das praktische Risiko besteht darin, dass export formats lose workbook semantics in different ways, so data, encoding, formulas, styles, and selected ranges need explicit product policy. Deshalb braucht der Ablauf einen schriftlichen Vertrag, nachvollziehbare Diagnosen und reale Regressionsdateien.
Architekturentscheidungen
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
Implementierungsablauf
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
Validierungsnachweise
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.
Implementierungshinweise für die Produktion
Behandle HotXLS Component: CSV, TSV, HTML, and RTF export in Delphi als klaren Servicevertrag rund um die HotXLS-Aufrufe, mit getrennten Schritten für Eingabeprüfung, Arbeitsmappenaufbau, Ausgabekontrolle und Support-Evidenz
- Datenquelle, Zellbereiche und Ausgabeformat festlegen, bevor die Arbeitsmappe erzeugt wird
- Zeilenanzahl, Blattanzahl, Warnungen und Ausgabepfad in ein prüfbares Support-Protokoll schreiben
- Anwendungsspezifische Details in testbare Helper kapseln, statt sie in UI-Ereignissen zu verteilen
- Die gespeicherte Datei erneut öffnen oder prüfen, bevor sie an ein anderes System oder an Kunden geht
Fehlerfälle, die getestet werden sollten
- Ein erfolgreicher SaveAs-Aufruf beweist noch nicht, dass der fachliche Vertrag stimmt
- Schriftarten, Rechte und regionale Einstellungen können auf Servern anders sein als auf Entwicklerrechnern
- Logs dürfen keine Passwörter, Kundendaten oder internen Links offenlegen
Ausführliches Delphi-Beispiel
Das folgende Beispiel zeigt eine praktische Servicegrenze für dieses Thema und hält Policy, Logging und Validierung testbar getrennt
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;
Produktionscheckliste
- 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