أنشئ وحرر وافحص واحسب وصدّر مصنفات Excel مباشرة من كود Delphi أو C++Builder. HotXLS مكتبة جداول Object Pascal أصلية مع المصدر لسير عمل XLS وXLSX، ومناسبة لأدوات سطح المكتب والمهام الدفعية وأنظمة التقارير وتوليد المستندات على الخادم دون أتمتة Microsoft Excel.
هذه المقالة موجّهة إلى teams producing many workbooks from services, schedulers, APIs, or report farms. وهي تتعامل مع streaming write and server batch jobs كجزء من هندسة المستندات في بيئة الإنتاج، لا كاستدعاء سريع لمكوّن.
الخطر العملي هو أن batch generation can overload memory, leave temporary files, retry unsafe stages, or hide partial output unless job boundaries are explicit. لذلك يحتاج المسار إلى عقد واضح وتشخيص قابل للملاحظة وملفات اختبار واقعية.
قرارات البنية
Treat every workbook as an isolated job. job identifier, output destination, retry policy, timeout, and cancellation behavior / temporary file location, cleanup, quota, and retention for failed workbooks
- job identifier, output destination, retry policy, timeout, and cancellation behavior
- temporary file location, cleanup, quota, and retention for failed workbooks
- batch size, concurrency level, progress reporting, and back-pressure
- which validation can run before final upload or delivery
مسار التنفيذ
Stream output only after validation checkpoints are defined. The order below keeps the workflow reviewable for Delphi and C++Builder teams.
- assign a job identifier and output boundary before opening the workbook writer
- prepare styles, sheets, and headers before streaming row data
- write rows in batches and checkpoint progress for operators
- validate size, sheet count, row count, and key formulas before final delivery
- clean or retain temporary files according to success, cancellation, or failure
أدلة التحقق
Batch evidence for operators. Keep these fields with the output or support record.
- job identifier, batch item count, row count, output size, elapsed time, and memory peak
- stage timings for data load, workbook write, validation, save, and upload
- temporary path, cleanup status, retry count, and cancellation reason
- operator-facing failure reason and whether retry is safe
Streaming is a resource policy
Streaming write helps scale workbook generation, but it also limits which parts of the workbook can be revisited later. The job design should decide what must be known before streaming begins.
ملاحظات تنفيذ للإنتاج
اجعل موضوع «HotXLS Component: streaming write and server batch jobs في Delphi» عقد خدمة واضحا حول استدعاءات HotXLS، مع فصل التحقق من الإدخال وكتابة المصنف وفحص الخرج وأدلة الدعم
- حدد مصدر البيانات ونطاقات الخلايا وتنسيق الخرج قبل إنشاء المصنف
- سجل عدد الصفوف والأوراق والتحذيرات ومسار الخرج في سجل دعم قابل للمراجعة
- ضع التفاصيل الخاصة بالتطبيق داخل دوال مساعدة قابلة للاختبار بدلا من نشرها داخل حدث واجهة
- افتح أو افحص الملف المحفوظ قبل تسليمه إلى نظام آخر أو إلى العميل
حالات فشل يجب اختبارها
- نجاح SaveAs لا يثبت أن العقد التجاري بقي صحيحا
- قد تختلف الخطوط والأذونات والإعدادات الإقليمية بين الخادم وجهاز التطوير
- يجب ألا تكشف السجلات كلمات مرور أو بيانات عملاء أو روابط داخلية
مثال Delphi تفصيلي
يوضح المثال التالي حدود خدمة عملية لهذا الموضوع، مع إبقاء السياسات والسجلات والتحقق في طبقة يمكن اختبارها
procedure RunWorkbookBatch(const Jobs: TArray<TWorkbookJob>);
var
Job: TWorkbookJob;
JobResult: TWorkbookJobResult;
begin
for Job in Jobs do
begin
StartJobAudit(Job.Id, Job.OutputFile);
try
RequireWritableDestination(Job.OutputFile);
RequireTempQuota(Job.TempFolder, Job.ExpectedRows);
JobResult := WriteWorkbookJob(Job);
ValidateWorkbookForDelivery(JobResult.OutputFile, JobResult.ExpectedRows);
CompleteJobAudit(Job.Id, JobResult);
except
on E: Exception do
begin
MarkJobFailed(Job.Id, E.Message, CanRetryWorkbookJob(Job));
CleanupOrRetainTempFiles(Job, E);
raise;
end;
end;
end;
end;
function WriteWorkbookJob(const Job: TWorkbookJob): TWorkbookJobResult;
var
Wb: TXLSXWorkbook;
Sh: IXLSWorksheet;
begin
Wb := TXLSXWorkbook.Create;
try
Sh := Wb.Sheets[0];
Sh.Name := 'Batch Output';
StreamRowsIntoWorksheet(Sh, Job.Reader, Job.Progress);
WriteBatchMetricsSheet(Wb, Job);
if Wb.SaveAs(Job.OutputFile) <> 1 then
RaiseWorkbookSaveError(Job.OutputFile);
Result := BuildWorkbookJobResult(Job);
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