Teknik makale

HotXLS: sheet listing and lightweight workbook inspection

Excel çalışma kitaplarını doğrudan Delphi veya C++Builder kodundan oluşturun, düzenleyin, inceleyin, hesaplayın ve dışa aktarın. HotXLS; Microsoft Excel otomasyonu olmadan masaüstü araçları, batch işleri, raporlama sistemleri ve sunucu tarafı belge üretimi için tasarlanmış, XLS ve XLSX iş akışlarına yönelik kaynak kodlu yerel bir Object Pascal kütüphanesidir.

Bu yazı teams that need fast workbook triage before loading formulas, styles, and cell data için hazırlanmıştır. sheet listing and lightweight workbook inspection konusunu tek bir bileşen çağrısı olarak değil, üretim düzeyinde belge mühendisliği olarak ele alır.

Pratik risk şudur: opening full workbook content just to list sheets wastes time and memory, and it can expose unsupported features too late in the process. Bu nedenle akışın yazılı sözleşmeye, gözlemlenebilir tanılara ve gerçekçi regresyon dosyalarına ihtiyacı vardır.

Mimari kararlar

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

Uygulama akışı

Use sheet inventory as an intake gate. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. open the workbook in an inspection path that avoids unnecessary cell materialization
  2. read format, package metadata, sheet list, visibility, and rough dimensions
  3. classify the workbook as preview, audit, convert, reject, or full-load
  4. show sheet inventory to operators when routing depends on workbook structure
  5. log inspection facts before deeper processing mutates state

Doğrulama kanıtı

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.

Üretim uygulama notları

HotXLS: sheet listing and lightweight workbook inspection konusunu HotXLS çağrılarının çevresinde açık bir servis sözleşmesi olarak ele alın; giriş doğrulama, çalışma kitabı yazma, çıktı denetimi ve destek kanıtını ayırın

  • Çalışma kitabını oluşturmadan önce veri kaynağını, hücre aralıklarını ve çıktı biçimini belirleyin
  • Satır sayısı, sayfalar, uyarılar ve çıktı yolunu incelenebilir destek kaydına yazın
  • Uygulamaya özel ayrıntıları UI olaylarına değil test edilebilir helper'lara yerleştirin
  • Dosyayı başka sisteme veya müşteriye vermeden önce kaydedilmiş çıktıyı yeniden açın veya inceleyin

Prova edilmesi gereken hata kipleri

  • Başarılı SaveAs çağrısı iş sözleşmesinin doğru kaldığını kanıtlamaz
  • Sunucu ile geliştirici makinesinde yazı tipleri, izinler ve bölgesel ayarlar farklı olabilir
  • Loglar parola, müşteri verisi veya iç bağlantı açığa çıkarmamalıdır

Ayrıntılı Delphi örneği

Aşağıdaki Delphi örneği bu konu için pratik bir servis sınırı gösterir ve politika, günlükleme ve doğrulamayı test edilebilir katmanda tutar

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;

Üretim kontrol listesi

  • 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