مقال تقني

HotXLS Component: Office-free workbook automation في Delphi

أنشئ وحرر وافحص واحسب وصدّر مصنفات Excel مباشرة من كود Delphi أو C++Builder. HotXLS مكتبة جداول Object Pascal أصلية مع المصدر لسير عمل XLS وXLSX، ومناسبة لأدوات سطح المكتب والمهام الدفعية وأنظمة التقارير وتوليد المستندات على الخادم دون أتمتة Microsoft Excel.

هذه المقالة موجّهة إلى teams replacing Excel COM automation in services, batch tools, installers, or desktop utilities. وهي تتعامل مع Office-free workbook automation كجزء من هندسة المستندات في بيئة الإنتاج، لا كاستدعاء سريع لمكوّن.

الخطر العملي هو أن Excel automation is often hidden infrastructure; replacing it requires explicit policies for calculation, templates, fonts, formats, and deployment. لذلك يحتاج المسار إلى عقد واضح وتشخيص قابل للملاحظة وملفات اختبار واقعية.

قرارات البنية

Remove desktop Office from the runtime contract. supported input and output formats such as XLS, XLSX, ODS, CSV, and HTML / template ownership, calculation expectations, and formatting policy

  • supported input and output formats such as XLS, XLSX, ODS, CSV, and HTML
  • template ownership, calculation expectations, and formatting policy
  • service account permissions, file locking, concurrency, and temporary storage
  • verification steps used instead of opening Excel during generation

مسار التنفيذ

Build workbook output as application logic. The order below keeps the workflow reviewable for Delphi and C++Builder teams.

  1. inventory existing COM automation behavior before replacing it
  2. move workbook generation into a service layer with explicit profiles
  3. load templates, fill data, calculate, validate, and save without launching Excel
  4. run output checks with workbook-level diagnostics and representative files
  5. deploy with file-system and service permissions tested under the real account

أدلة التحقق

Automation evidence for deployment. Keep these fields with the output or support record.

  • automation profile, template version, input format, output format, and calculation mode
  • service identity, output path, temporary storage, concurrency level, and elapsed time
  • warnings for unsupported Excel automation behaviors that were not replicated
  • open or validation result in target downstream applications

No Excel process means fewer surprises, not fewer decisions

Office-free automation avoids desktop session, COM, and installed Office dependencies. The application still needs to own workbook formats, calculation strategy, file locking, templates, and output verification.

ملاحظات تنفيذ للإنتاج

اجعل موضوع «HotXLS Component: Office-free workbook automation في Delphi» عقد خدمة واضحا حول استدعاءات HotXLS، مع فصل التحقق من الإدخال وكتابة المصنف وفحص الخرج وأدلة الدعم

  • حدد مصدر البيانات ونطاقات الخلايا وتنسيق الخرج قبل إنشاء المصنف
  • سجل عدد الصفوف والأوراق والتحذيرات ومسار الخرج في سجل دعم قابل للمراجعة
  • ضع التفاصيل الخاصة بالتطبيق داخل دوال مساعدة قابلة للاختبار بدلا من نشرها داخل حدث واجهة
  • افتح أو افحص الملف المحفوظ قبل تسليمه إلى نظام آخر أو إلى العميل

حالات فشل يجب اختبارها

  • نجاح SaveAs لا يثبت أن العقد التجاري بقي صحيحا
  • قد تختلف الخطوط والأذونات والإعدادات الإقليمية بين الخادم وجهاز التطوير
  • يجب ألا تكشف السجلات كلمات مرور أو بيانات عملاء أو روابط داخلية

مثال Delphi تفصيلي

يوضح المثال التالي حدود خدمة عملية لهذا الموضوع، مع إبقاء السياسات والسجلات والتحقق في طبقة يمكن اختبارها

procedure BuildNightlyWorkbookWithoutExcel(const OutputFile: string; const ReportDate: TDate);
var
  Wb: TXLSXWorkbook;
  Summary: IXLSWorksheet;
  Detail: IXLSWorksheet;
begin
  Wb := TXLSXWorkbook.Create;
  try
    Summary := Wb.Sheets[0];
    Summary.Name := 'Summary';
    Detail := AddWorksheet(Wb, 'Detail');

    WriteReportHeader(Summary, 'Nightly Operations', ReportDate);
    WriteSummaryMetrics(Summary, LoadSummaryMetrics(ReportDate));
    WriteDetailRows(Detail, LoadDetailRows(ReportDate));
    LinkSummaryToDetail(Summary, Detail);
    Wb.Calculate;

    ValidateServerEnvironment(['fonts', 'temp-path', 'write-access']);
    WriteAutomationAudit(Wb, 'no-excel-automation', ReportDate);

    if Wb.SaveAs(OutputFile) <> 1 then
      RaiseWorkbookSaveError(OutputFile);
  finally
    Wb.Free;
  end;
end;

قائمة فحص الإنتاج

  • 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