الفئة: com & Activex
(ط) استخدام طريقة الإنشاء الديناميكي
قم أولاً بإنشاء كائن Excel ، باستخدام comobj:
var excelapp: variant ؛
excelapp: = createOleObject ('excel.application') ؛
1) عرض النافذة الحالية:
excelapp.visible: = true ؛
2) تغيير شريط عنوان Excel:
excelapp.caption: = "Application يستدعي Microsoft Excel" ؛
3) إضافة مصنف جديد:
excelapp.workbooks.add ؛
4) افتح مصنفًا موجودًا:
excelapp.workbooks.open ('c: /excel/demo.xls') ؛
5) قم بتعيين ورقة العمل الثانية كورقة عمل نشطة:
excelapp.worksheets [2].
أو
excelapp.workssheets ['sheet2'].
6) تعيين القيم للخلايا:
excelapp.cells [1،4] .value: = 'الصف الأول ، العمود الرابع' ؛
7) اضبط عرض العمود المحدد (الوحدة: عدد الأحرف) ، مع أخذ العمود الأول كمثال:
excelapp.activeshet.columns [1] .columnswidth: = 5 ؛
8) اضبط ارتفاع الصف المحدد (الوحدة: الجنيه) (1 رطل = 0.035 سم) ، واستخدم مثال السلوك الثاني:
excelapp.activeshet.rows [2] .RowHeight: = 1/0.035 ؛
9) إدراج كسر صفحة قبل السطر 8:
excelapp.worksheets [1] .Rows [8] .pagebreak: = 1 ؛
10) حذف كسر الصفحة قبل العمود 8:
excelapp.activeshet.columns [4] .pageBreak: = 0 ؛
11) حدد عرض خط الحدود:
excelapp.activeshet.range ['b3: d4'] .borders [2].
1-LEF 2-RIGHT 3-TOP 4-BOTTOM 5-SLANT ( /) 6 SLANT ( /)
12) امسح صيغة الخلايا للصف الأول والعمود الرابع:
excelapp.activeshet.cells [1،4] .clearcontents ؛
13) اضبط خصائص الخط في السطر الأول:
excelapp.activeshet.rows [1] .font.name: = 'lishu' ؛
excelapp.activeshet.rows [1] .font.color: = clblue ؛
excelapp.activeshet.rows [1] .font.bold: = true ؛
excelapp.activeshet.rows [1] .font.underline: = true ؛
14) جعل إعدادات الصفحة:
أ.
excelapp.activesheet.pagesetup.centerheader: = 'Report Demo' ؛
ب.
excelapp.activeshet.pagesetup.centerfooter: = 'page & p' ؛
ج.
excelapp.activeshet.pagesetup.headermargin: = 2/0.035 ؛
د.
excelapp.activesheet.pagesetup.headermargin: = 3/0.035 ؛
هـ.
excelapp.activesheet.pagesetup.topmargin: = 2/0.035 ؛
و.
excelapp.activesheet.pagesetup.bottommargin: = 2/0.035 ؛
G.Left Margin 2cm:
excelapp.activesheet.pagesetup.leftmargin: = 2/0.035 ؛
ح.
excelapp.activesheet.pagesetup.rightmargin: = 2/0.035 ؛
أنا.
excelapp.activeshet.pagesetup.centerhorizontally: = 2/0.035 ؛
J.
excelapp.activesheet.pagesetup.centervertival: = 2/0.035 ؛
كابل الخلايا المطبوعة:
excelapp.activeshet.pagesetup.printgridlines: = true ؛
15) عملية التشغيل:
أ.
excelapp.activeshet.used.range.copy ؛
ب.
excelapp.activeshet.range ['a1: e2'] .copy ؛
ج.
excelapp.activeshet.range. ['a1'] .pastespecial ؛
د.
excelapp.activeshet.range.pastespecial ؛
16) أدخل صف أو عمود:
أ.
ب.
17) حذف صف أو عمود:
أ.
ب.
18) ورقة عمل معاينة الطباعة:
excelapp.activeshet.printpreview ؛
19) ورقة عمل الطباعة:
excelapp.activeshet.printout ؛
20) توفير ورقة العمل:
إذا لم يكن excelapp.activework.saved ثم
excelapp.activeshet.printpreview ؛
21) حفظ ورقة العمل على النحو التالي:
excelapp.saveas ('c: /excel/demo1.xls') ؛
22) التخلي عن الادخار:
excelapp.activeworkbook.saved: = true ؛
23) أغلق المصنف:
excelapp.workbooks.close ؛
24) خروج Excel:
excelapp.quit ؛
(2) استخدام طريقة التحكم في دلفي
ضع excelapplication و excelworkbook و excelworksheet على التوالي.
1) فتح Excel
excelapplication1.connect ؛
2) عرض النافذة الحالية:
excelapplication1.visible [0]: = true ؛
3) تغيير شريط عنوان Excel:
excelapplication1.Caption: = "Application يستدعي Microsoft Excel" ؛
4) إضافة مصنف جديد:
excelworkbook1.connectto (excelapplication1.workbooks.add (فارغة ، 0)) ؛
5) إضافة ورقة عمل جديدة:
var temp_worksheet: _Worksheet ؛
يبدأ
temp_worksheet: = excelworkbook1.
ورقة عمل.
excelworksheet1.connectto (temp_worksheet) ؛
نهاية؛
6) افتح مصنفًا موجودًا:
excelapplication1.Workbooks.Open (C: /A.xls
فارغة ، فارغة ، فارغة ، فارغة ، فارغة ،
فارغة ، فارغة ، فارغة ، فارغة ، فارغة ،
فارغة ، فارغة ، فارغة ، فارغة ، 0)
7) قم بتعيين ورقة العمل الثانية كورقة عمل نشطة:
excelapplication1
excelapplication1.workssheets ['sheet2'].
8) تعيين القيم للخلايا:
excelapplication1.cells [1،4]. value: = 'first row ، العمود الرابع' ؛
9) اضبط عرض العمود المحدد (الوحدة: عدد الأحرف) ، مع أخذ العمود الأول كمثال:
excelapplication1.activeshet.columns [1] .Columnswidth: = 5 ؛
10) اضبط ارتفاع الصف المحدد (الوحدة: الجنيه) (1 رطل = 0.035 سم) ، واستخدم مثال السلوك الثاني:
excelapplication1.Activeshet.rows [2] .RowHeight: = 1/0.035 ؛
11) إدراج كسر صفحة قبل السطر 8:
excelapplication1.Worksheets [1] .Rows [8] .PageBreak: = 1 ؛
12) حذف كسر الصفحة قبل العمود 8:
excelapplication1.activeshet.columns [4] .pageBreak: = 0 ؛
13) حدد عرض خط الحدود:
excelapplication1.activeshet.range ['b3: d4'] .borders [2].
1-LEF 2-RIGHT 3-TOP 4-BOTTOM 5-SLANT ( /) 6 SLANT ( /)
14) امسح صيغة الخلايا للصف الأول والعمود الرابع:
excelapplication1.activeshet.cells [1،4] .clearContents ؛
15) اضبط خصائص الخط في السطر الأول:
excelapplication1.activeshet.rows [1] .font.name: = 'lishu' ؛
excelapplication1.activesheet.rows [1] .font.color: = clblue ؛
excelapplication1.activesheet.rows [1] .font.bold: = true ؛
excelapplication1.activeshet.rows [1] .font.underline: = true ؛
16) جعل إعدادات الصفحة:
أ.
excelapplication1.activeshet.pagesetup.centerheader: = 'Report Demo' ؛
ب.
excelapplication1.activeshet.pagesetup.centerfooter: = 'page & p' ؛
ج.
excelapplication1.activeshet.pagesetup.headermargin: = 2/0.035 ؛
د.
excelapplication1.activeshet.pagesetup.headermargin: = 3/0.035 ؛
هـ.
excelapplication1.activeshet.pagesetup.topmargin: = 2/0.035 ؛
و.
excelapplication1.activeshet.pagesetup.bottommargin: = 2/0.035 ؛
G.Left Margin 2cm:
excelapplication1.activesheet.pagesetup.leftmargin: = 2/0.035 ؛
ح.
excelapplication1.activeshet.pagesetup.rightmargin: = 2/0.035 ؛
أنا.
excelapplication1.activeshet.pagesetup.centerhorizontly: = 2/0.035 ؛
J.
excelapplication1.activeshet.pagesetup.centervertally: = 2/0.035 ؛
كابل الخلايا المطبوعة:
excelapplication1.activeshet.pagesetup.printgridlines: = true ؛
17) عملية التشغيل:
أ.
excelapplication1.activeshet.used.range.copy ؛
ب.
excelapplication1.activeshet.range ['a1: e2'] .copy ؛
ج.
excelapplication1.activeshet.range. ['a1'] .pastespecial ؛
د.
excelapplication1.activeshet.range.pastespecial ؛
18) أدخل صف أو عمود:
أ.
ب.
19) حذف صف أو عمود:
أ.
ب.
20) ورقة عمل معاينة الطباعة:
excelapplication1.activeshet.printpreview ؛
21) ورقة عمل الطباعة:
excelapplication1.activeshet.printout ؛
22) توفير ورقة العمل:
إذا لم يكن excelapplication1.activeworkbook.saved ثم
excelapplication1.activeshet.printpreview ؛
23) حفظ ورقة العمل على النحو التالي:
excelapplication1.saveas ('c: /excel/demo1.xls') ؛
24) التخلي عن الادخار:
excelapplication1.ActiveWorkbook.saved: = true ؛
25) أغلق المصنف:
excelapplication1.workbooks.close ؛
26) Exit Excel:
excelapplication1.quit ؛
excelapplication1.disconnect ؛
(3) استخدم Delphi للتحكم في مخططات Excel 2D
ضع excelapplication و excelworkbook و excelworksheet على التوالي
var shell1 ، acart ، المدى: البديل ؛
1) حدد ورقة العمل الأولى عندما يكون المصنف الأول
shell1: = excelapplication1.Workbooks [1].
2) إضافة رسم بياني ثنائي الأبعاد
Achart: = sheet1.ChartObjects.add (100،100،200،200) ؛
3) حدد شكل الرسم البياني ثنائي الأبعاد
Achart.Chart.Charttype: = 4 ؛
4) تعيين القيم إلى رسم بياني ثنائي الأبعاد
سلسلة: = acart.chart.seriesCollection ؛
المدى: = sheet1! r2c3: r3c9 ؛
series.add (المدى ، صحيح) ؛
5) أضف عنوان الرسم البياني ثنائي الأبعاد
Achart.Chart.hastitle: = true ؛
achart.chart.charttitle.characters.text: = 'Excle 2d Diagram'
6) تغيير حجم خط العنوان للرسم البياني ثنائي الأبعاد
Achart.chart.charttitle.font.size: = 6 ؛
7) أضف وصفًا إلى الشكل ثنائي الأبعاد
achart.chart.axes (xlcategory ، xlprimary) .hastitle: = true ؛
achart.chart.axes (xlcategory ، xlprimary) .AxiStitle.Characters.Text: = 'substript description' ؛
8) أضف علامة يسارية إلى الشكل ثنائي الأبعاد
Achart.Chart.Axes (xlvalue ، xlprimary) .hastitle: = true ؛
Achart.Chart.Axes (xlvalue ، xlprimary) .AxiStitle.Characters.Text: = 'left mark description' ؛
9) إضافة علامة يمين إلى الشكل ثنائي الأبعاد
Achart.Chart.Axes (xlvalue ، xlsecondary) .hastitle: = true ؛
achart.chart.axes (xlvalue ، xlsecondary) .AxiStitle.Characters.Text: = 'Right Mark Description' ؛
10) قم بتغيير حجم منطقة العرض من الرسم البياني ثنائي الأبعاد
Achart.Chart.plotarea.left: = 5 ؛
Achart.Chart.Plotarea.width: = 223 ؛
Achart.Chart.Plotarea.Height: = 108 ؛
11) أضف تعليمات إلى محور الإحداثيات للرسم البياني ثنائي الأبعاد
Achart.Chart.SeriesCollection [1] .Name: = 'Axis Description' ؛