أنشئ وحرر وافحص واحسب وصدّر مصنفات Excel مباشرة من كود Delphi أو C++Builder. HotXLS مكتبة جداول Object Pascal أصلية مع المصدر لسير عمل XLS وXLSX، ومناسبة لأدوات سطح المكتب والمهام الدفعية وأنظمة التقارير وتوليد المستندات على الخادم دون أتمتة Microsoft Excel.
هذه المقالة موجّهة إلى teams generating analytical workbooks whose formulas must survive sheet movement, template changes, and user edits. وهي تتعامل مع defined names and cross-sheet formulas كجزء من هندسة المستندات في بيئة الإنتاج، لا كاستدعاء سريع لمكوّن.
الخطر العملي هو أن cross-sheet formulas are fragile when workbook-level names, sheet-level names, external links, and range movement are not governed. لذلك يحتاج المسار إلى عقد واضح وتشخيص قابل للملاحظة وملفات اختبار واقعية.
قرارات البنية
Use names as a stable formula interface. workbook-level versus sheet-level name scope / name syntax, collision handling, hidden names, and user-visible names
- workbook-level versus sheet-level name scope
- name syntax, collision handling, hidden names, and user-visible names
- formula references to generated ranges, moved sheets, and external workbooks
- recalculation policy after names or referenced ranges change
مسار التنفيذ
Resolve name scope before writing formulas. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- inventory existing names before adding generated names
- create stable names for generated ranges before writing dependent formulas
- qualify sheet-level names deliberately to avoid accidental workbook-level collisions
- update formulas after sheet insertion, deletion, or movement
- calculate and inspect formulas before delivering the workbook
أدلة التحقق
Formula evidence for maintainable workbooks. Keep these fields with the output or support record.
- name, scope, visible state, target reference, and owner profile
- formula text, resolved references, calculation result, and error state
- external-link references and whether they were preserved, updated, or blocked
- name collisions and remediation actions
Names are API surfaces inside the workbook
Defined names create a contract between formulas, templates, and generated data. Managing scope and references deliberately makes workbooks easier to maintain than hard-coded cell addresses scattered across sheets.
ملاحظات تنفيذ للإنتاج
اجعل موضوع «HotXLS Component: defined names and cross-sheet formulas في Delphi» عقد خدمة واضحا حول استدعاءات HotXLS، مع فصل التحقق من الإدخال وكتابة المصنف وفحص الخرج وأدلة الدعم
- حدد مصدر البيانات ونطاقات الخلايا وتنسيق الخرج قبل إنشاء المصنف
- سجل عدد الصفوف والأوراق والتحذيرات ومسار الخرج في سجل دعم قابل للمراجعة
- ضع التفاصيل الخاصة بالتطبيق داخل دوال مساعدة قابلة للاختبار بدلا من نشرها داخل حدث واجهة
- افتح أو افحص الملف المحفوظ قبل تسليمه إلى نظام آخر أو إلى العميل
حالات فشل يجب اختبارها
- نجاح SaveAs لا يثبت أن العقد التجاري بقي صحيحا
- قد تختلف الخطوط والأذونات والإعدادات الإقليمية بين الخادم وجهاز التطوير
- يجب ألا تكشف السجلات كلمات مرور أو بيانات عملاء أو روابط داخلية
مثال Delphi تفصيلي
يوضح المثال التالي حدود خدمة عملية لهذا الموضوع، مع إبقاء السياسات والسجلات والتحقق في طبقة يمكن اختبارها
procedure BuildNamedFormulaWorkbook(const OutputFile: string; const Assumptions: TAssumptionSet);
var
Wb: TXLSXWorkbook;
Inputs: IXLSWorksheet;
Summary: IXLSWorksheet;
begin
Wb := TXLSXWorkbook.Create;
try
Inputs := Wb.Sheets[0];
Inputs.Name := 'Inputs';
Summary := AddWorksheet(Wb, 'Summary');
WriteAssumptionTable(Inputs, Assumptions);
DefineWorkbookName(Wb, 'TaxRate', 'Inputs!$B$2');
DefineWorkbookName(Wb, 'DiscountRate', 'Inputs!$B$3');
Summary.Range['A1'].Value := 'Net revenue';
Summary.Range['B1'].Value := '=GrossRevenue*(1-DiscountRate)*(1-TaxRate)';
AssertRequiredNames(Wb, ['TaxRate', 'DiscountRate', 'GrossRevenue']);
Wb.Calculate;
AssertFormulaRangeHasValues(Summary, 'B1:B1');
WriteFormulaDependencyAudit(Wb);
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