Artykuł techniczny

HotXLS Component: ODS open, save, and round-trip in Delphi

Twórz, edytuj, sprawdzaj, obliczaj i eksportuj skoroszyty Excel bezpośrednio z kodu Delphi lub C++Builder. HotXLS to natywna biblioteka Object Pascal z kodem źródłowym dla przepływów XLS i XLSX, przeznaczona do narzędzi desktopowych, zadań batch, systemów raportowych i generowania dokumentów po stronie serwera bez automatyzacji Microsoft Excel.

Ten artykuł jest przeznaczony dla teams accepting OpenDocument Spreadsheet files while still producing Excel-compatible workflows. Traktuje ODS open, save, and round-trip jako produkcyjną inżynierię dokumentów, a nie pojedyncze wywołanie komponentu.

Praktyczne ryzyko polega na tym, że round-trip support can preserve values but still lose formulas, styles, charts, or page settings when feature gaps are not reported. Dlatego przepływ wymaga spisanego kontraktu, obserwowalnej diagnostyki i realistycznych plików regresyjnych.

Decyzje architektoniczne

Classify ODS compatibility before editing. accepted ODS sources, supported feature set, and blocked feature categories / formula, style, chart, image, conditional formatting, and page setup handling

  • accepted ODS sources, supported feature set, and blocked feature categories
  • formula, style, chart, image, conditional formatting, and page setup handling
  • save format after editing and whether the user expects ODS or XLSX output
  • warning policy for unsupported or approximated features

Przebieg implementacji

Track what is preserved, converted, or dropped. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. inspect the ODS package and create a feature inventory before editing
  2. map sheets, cells, formulas, styles, images, and charts to supported workbook objects
  3. apply edits while preserving original intent where possible
  4. save output in the chosen format and compare key sheets with the source
  5. attach a compatibility report when features are converted or dropped

Dowody walidacji

Round-trip evidence for customer trust. Keep these fields with the output or support record.

  • source format, sheet count, formula count, style count, chart count, and image count
  • preserved, converted, approximated, and dropped feature counts
  • output format, warning summary, and key-cell comparison
  • viewer compatibility notes for LibreOffice and Excel when relevant

OpenDocument and Excel models overlap but differ

ODS support should identify which workbook features map cleanly, which require conversion, and which need warnings. A professional workflow gives users evidence instead of pretending every spreadsheet model is identical.

Uwagi wdrożeniowe dla produkcji

Traktuj HotXLS Component: ODS open, save, and round-trip in Delphi jako jawny kontrakt usługi wokół wywołań HotXLS, oddzielając walidację wejścia, zapis skoroszytu, kontrolę wyniku i dowody dla wsparcia

  • Ustal źródło danych, zakresy komórek i format wyjściowy przed utworzeniem skoroszytu
  • Zapisuj liczbę wierszy, arkusze, ostrzeżenia i ścieżkę wyjściową w możliwym do sprawdzenia logu
  • Szczegóły aplikacji zamykaj w testowalnych helperach zamiast w zdarzeniach UI
  • Otwórz lub sprawdź zapisany plik przed przekazaniem go do innego systemu lub klienta

Tryby awarii do przećwiczenia

  • Udany SaveAs nie dowodzi, że kontrakt biznesowy nadal jest poprawny
  • Czcionki, uprawnienia i ustawienia regionalne mogą różnić się między serwerem a maszyną deweloperską
  • Logi nie mogą ujawniać haseł, danych klientów ani linków wewnętrznych

Szczegółowy przykład Delphi

Poniższy przykład Delphi pokazuje praktyczną granicę usługi dla tego tematu, z polityką, logowaniem i walidacją w warstwie możliwej do testowania

procedure RoundTripOdsWorkbook(const InputOds, OutputOds: string);
var
  Wb: TXLSXWorkbook;
  BeforeState: TWorkbookInventory;
  AfterState: TWorkbookInventory;
begin
  RequireFileExists(InputOds);
  Wb := TXLSXWorkbook.Create;
  try
    Wb.Open(InputOds);
    BeforeState := CaptureWorkbookInventory(Wb);
    NormalizeFeaturesForOdsOutput(Wb);
    WriteCompatibilitySheet(Wb, BeforeState, 'ods-round-trip');

    if Wb.SaveAs(OutputOds) <> 1 then
      RaiseWorkbookSaveError(OutputOds);

    AfterState := InspectSavedWorkbook(OutputOds);
    CompareRoundTripInventory(BeforeState, AfterState, [
      'sheet-count',
      'used-ranges',
      'formula-cells',
      'visible-styles'
    ]);
  finally
    Wb.Free;
  end;
end;

Lista produkcyjna

  • 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