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 teams that need fast workbook triage before loading formulas, styles, and cell data. Er behandelt sheet listing and lightweight workbook inspection als produktive Dokumenttechnik und nicht als kurzen Komponentenaufruf.
Das praktische Risiko besteht darin, dass opening full workbook content just to list sheets wastes time and memory, and it can expose unsupported features too late in the process. Deshalb braucht der Ablauf einen schriftlichen Vertrag, nachvollziehbare Diagnosen und reale Regressionsdateien.
Architekturentscheidungen
Inspect package facts before full parsing. which facts are required before full workbook load / handling for hidden sheets, very hidden sheets, chart sheets, and unsupported sheet types
- which facts are required before full workbook load
- handling for hidden sheets, very hidden sheets, chart sheets, and unsupported sheet types
- maximum package size, sheet count, and intake timeout
- routing rules for files that only need metadata versus full calculation
Implementierungsablauf
Use sheet inventory as an intake gate. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- open the workbook in an inspection path that avoids unnecessary cell materialization
- read format, package metadata, sheet list, visibility, and rough dimensions
- classify the workbook as preview, audit, convert, reject, or full-load
- show sheet inventory to operators when routing depends on workbook structure
- log inspection facts before deeper processing mutates state
Validierungsnachweise
Inspection evidence for routing decisions. Keep these fields with the output or support record.
- format, file size, sheet count, sheet order, visibility, and sheet type
- metadata such as creator, modified time, and application when available
- routing result and reason based on lightweight facts
- warnings for encrypted, damaged, macro-enabled, or oversized packages
Triage should be cheap and trustworthy
A lightweight inspection step should capture workbook format, sheet names, visibility, order, types, dimensions when available, and package-level warnings. That information is enough to route many files before deep processing.
Implementierungshinweise für die Produktion
Behandle HotXLS: sheet listing and lightweight workbook inspection 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 WriteWorkbookInspectionIndex(const SourceFile, OutputFile: string);
var
Wb: TXLSXWorkbook;
IndexSheet: IXLSWorksheet;
Sh: IXLSWorksheet;
SheetIndex: Integer;
RowIndex: Integer;
begin
RequireFileExists(SourceFile);
Wb := TXLSXWorkbook.Create;
try
Wb.Open(SourceFile);
IndexSheet := AddWorksheet(Wb, 'Inspection Index');
WriteHeaderRow(IndexSheet, ['No', 'Sheet', 'UsedRange', 'FormulaCells', 'Warnings']);
RowIndex := 2;
for SheetIndex := 0 to Wb.Sheets.Count - 1 do
begin
Sh := Wb.Sheets[SheetIndex];
IndexSheet.Range['A' + IntToStr(RowIndex)].Value := SheetIndex + 1;
IndexSheet.Range['B' + IntToStr(RowIndex)].Value := Sh.Name;
IndexSheet.Range['C' + IntToStr(RowIndex)].Value := GetUsedRangeAddress(Sh);
IndexSheet.Range['D' + IntToStr(RowIndex)].Value := CountFormulaCells(Sh);
IndexSheet.Range['E' + IntToStr(RowIndex)].Value := BuildSheetWarnings(Sh);
Inc(RowIndex);
end;
AddAutoFilterToHeader(IndexSheet, 'A1:E' + IntToStr(RowIndex - 1));
WriteInspectionAudit(Wb, SourceFile, RowIndex - 2);
if Wb.SaveAs(OutputFile) <> 1 then
RaiseWorkbookSaveError(OutputFile);
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