أنشئ وحرر وافحص واحسب وصدّر مصنفات Excel مباشرة من كود Delphi أو C++Builder. HotXLS مكتبة جداول Object Pascal أصلية مع المصدر لسير عمل XLS وXLSX، ومناسبة لأدوات سطح المكتب والمهام الدفعية وأنظمة التقارير وتوليد المستندات على الخادم دون أتمتة Microsoft Excel.
هذه المقالة موجّهة إلى teams generating or processing large XLS/XLSX workbooks in desktop utilities, services, or batch jobs. وهي تتعامل مع large workbook performance كجزء من هندسة المستندات في بيئة الإنتاج، لا كاستدعاء سريع لمكوّن.
الخطر العملي هو أن large-workbook workflows fail when shared strings, styles, formulas, memory buffers, and output streams are not managed as production resources. لذلك يحتاج المسار إلى عقد واضح وتشخيص قابل للملاحظة وملفات اختبار واقعية.
قرارات البنية
Plan memory, styles, and streaming together. maximum row count, column count, sheet count, and output file size / shared-string strategy, style reuse, formula volume, and image policy
- maximum row count, column count, sheet count, and output file size
- shared-string strategy, style reuse, formula volume, and image policy
- streaming write boundaries, temporary storage, progress, and cancellation
- Excel compatibility limits and downstream import limits
مسار التنفيذ
Measure workbook size during generation. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- create capacity fixtures that represent real customer data distribution
- reuse styles and strings instead of generating unique resources per cell
- write rows in controlled batches and flush output only at safe boundaries
- track memory, elapsed time, file size, and warning counts per stage
- open large output with the target application before increasing limits
أدلة التحقق
Performance evidence for capacity planning. Keep these fields with the output or support record.
- row count, column count, sheet count, style count, shared-string count, and file size
- memory peak, elapsed time, batch size, temporary storage, and cancellation result
- formula count, image count, comment count, and relationship count
- target Excel or importer open time for representative output
Rows are not the only scale factor
Workbook size grows with cells, styles, shared strings, formulas, images, comments, and relationships. A performance plan should reduce redundant resources and choose streaming only where it fits the output contract.
ملاحظات تنفيذ للإنتاج
اجعل موضوع «HotXLS Component: large workbook performance في Delphi» عقد خدمة واضحا حول استدعاءات HotXLS، مع فصل التحقق من الإدخال وكتابة المصنف وفحص الخرج وأدلة الدعم
- حدد مصدر البيانات ونطاقات الخلايا وتنسيق الخرج قبل إنشاء المصنف
- سجل عدد الصفوف والأوراق والتحذيرات ومسار الخرج في سجل دعم قابل للمراجعة
- ضع التفاصيل الخاصة بالتطبيق داخل دوال مساعدة قابلة للاختبار بدلا من نشرها داخل حدث واجهة
- افتح أو افحص الملف المحفوظ قبل تسليمه إلى نظام آخر أو إلى العميل
حالات فشل يجب اختبارها
- نجاح SaveAs لا يثبت أن العقد التجاري بقي صحيحا
- قد تختلف الخطوط والأذونات والإعدادات الإقليمية بين الخادم وجهاز التطوير
- يجب ألا تكشف السجلات كلمات مرور أو بيانات عملاء أو روابط داخلية
مثال Delphi تفصيلي
يوضح المثال التالي حدود خدمة عملية لهذا الموضوع، مع إبقاء السياسات والسجلات والتحقق في طبقة يمكن اختبارها
procedure WriteLargeLedgerWorkbook(const OutputFile: string; const Source: ILedgerReader);
var
Wb: TXLSXWorkbook;
Sh: IXLSWorksheet;
RowIndex: Integer;
Batch: TArray<TLedgerRow>;
Item: TLedgerRow;
Metrics: TWorkbookMetrics;
begin
Wb := TXLSXWorkbook.Create;
try
Sh := Wb.Sheets[0];
Sh.Name := 'Ledger';
WriteHeaderRow(Sh, ['Account', 'Date', 'Description', 'Debit', 'Credit', 'Balance']);
RowIndex := 2;
Metrics := StartWorkbookMetrics('large-ledger');
repeat
Batch := Source.ReadNextBatch(5000);
for Item in Batch do
begin
WriteLedgerRow(Sh, RowIndex, Item);
Inc(RowIndex);
end;
CheckMemoryAndTempQuota(Metrics, RowIndex - 2);
FlushProgressMetric(Metrics, RowIndex - 2);
until Length(Batch) = 0;
Sh.Range['A1:F1'].ApplyBuiltinStyle(xbsTitle);
AddSummarySheet(Wb, Metrics, RowIndex - 2);
AssertWorkbookSizePolicy(OutputFile, RowIndex - 2);
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