أنشئ وحرر وافحص واحسب وصدّر مصنفات Excel مباشرة من كود Delphi أو C++Builder. HotXLS مكتبة جداول Object Pascal أصلية مع المصدر لسير عمل XLS وXLSX، ومناسبة لأدوات سطح المكتب والمهام الدفعية وأنظمة التقارير وتوليد المستندات على الخادم دون أتمتة Microsoft Excel.
هذه المقالة موجّهة إلى developers delivering workbooks that users review, print, and partly edit under controlled rules. وهي تتعامل مع protection, page setup, and printing كجزء من هندسة المستندات في بيئة الإنتاج، لا كاستدعاء سريع لمكوّن.
الخطر العملي هو أن sheet protection and print settings are easy to apply but hard to support when editable ranges, headers, page breaks, scaling, and printer assumptions are undocumented. لذلك يحتاج المسار إلى عقد واضح وتشخيص قابل للملاحظة وملفات اختبار واقعية.
قرارات البنية
Define edit and print intent together. locked cells, editable ranges, sheet protection password, and allowed user actions / print area, repeat rows and columns, headers, footers, margins, scaling, and orientation
- locked cells, editable ranges, sheet protection password, and allowed user actions
- print area, repeat rows and columns, headers, footers, margins, scaling, and orientation
- manual versus automatic page breaks and how generated rows affect them
- whether protection is advisory workflow control or part of a stronger governance model
مسار التنفيذ
Apply protection after layout is final. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- finish data generation and layout expansion before enabling protection
- mark editable ranges and validate that formulas and headers remain locked
- apply page setup, print titles, margins, scaling, and page breaks
- open print preview in the target workbook application
- record the protection and print profile used for support
أدلة التحقق
Workbook evidence for print and protection disputes. Keep these fields with the output or support record.
- protected sheets, editable ranges, allowed actions, and password policy identifier
- print area, repeat titles, margins, orientation, scaling, and page count
- manual page breaks and dynamic row expansion results
- preview or printed-output verification for representative data volumes
Protection is workflow guidance, not security alone
Workbook protection helps guide user edits, while page setup controls physical output. They interact: locked cells, print areas, headers, scaling, and page breaks should all match the business document contract.
ملاحظات تنفيذ للإنتاج
اجعل موضوع «HotXLS Component: protection, page setup, and printing في Delphi» عقد خدمة واضحا حول استدعاءات HotXLS، مع فصل التحقق من الإدخال وكتابة المصنف وفحص الخرج وأدلة الدعم
- حدد مصدر البيانات ونطاقات الخلايا وتنسيق الخرج قبل إنشاء المصنف
- سجل عدد الصفوف والأوراق والتحذيرات ومسار الخرج في سجل دعم قابل للمراجعة
- ضع التفاصيل الخاصة بالتطبيق داخل دوال مساعدة قابلة للاختبار بدلا من نشرها داخل حدث واجهة
- افتح أو افحص الملف المحفوظ قبل تسليمه إلى نظام آخر أو إلى العميل
حالات فشل يجب اختبارها
- نجاح SaveAs لا يثبت أن العقد التجاري بقي صحيحا
- قد تختلف الخطوط والأذونات والإعدادات الإقليمية بين الخادم وجهاز التطوير
- يجب ألا تكشف السجلات كلمات مرور أو بيانات عملاء أو روابط داخلية
مثال Delphi تفصيلي
يوضح المثال التالي حدود خدمة عملية لهذا الموضوع، مع إبقاء السياسات والسجلات والتحقق في طبقة يمكن اختبارها
procedure BuildProtectedPrintWorkbook(const OutputFile: string; const Rows: TArray<TPrintRow>);
var
Wb: TXLSWorkbook;
Sh: IXLSWorksheet;
RowIndex: Integer;
Row: TPrintRow;
begin
Wb := TXLSWorkbook.Create;
try
Sh := Wb.Sheets[1];
Sh.Name := 'Print Pack';
WriteHeaderRow(Sh, ['Item', 'Owner', 'Due', 'Amount']);
RowIndex := 2;
for Row in Rows do
begin
Sh.Range['A' + IntToStr(RowIndex)].Value := Row.ItemName;
Sh.Range['B' + IntToStr(RowIndex)].Value := Row.Owner;
Sh.Range['C' + IntToStr(RowIndex)].Value := Row.DueDate;
Sh.Range['D' + IntToStr(RowIndex)].Value := Row.Amount;
Inc(RowIndex);
end;
Sh.Range['A1:D1'].ApplyBuiltinStyle(xbsTitle);
ConfigurePrintArea(Sh, 'A1:D' + IntToStr(RowIndex - 1));
ConfigurePageSetup(Sh, poLandscape, psFitToWidth);
LockFormulaCellsOnly(Sh);
ProtectWorksheetForReview(Sh, 'review-password');
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