الأشكال في المخططات

إضافة عنصر تحكم التسمية إلى التخطيط

توفر التصنيفات وسيلة لإعطاء معلومات للمستخدمين حول محتوى جدول البيانات. Aspose.Cells يسمح لك بإضافة ومعالجة التسميات حتى في المخططات.

الAspose.Cells.Drawing.ShapeCollection توفر class طريقة تسمىAddLabelInChart، تستخدم لإضافة عنصر تحكم تسمية إلى مخطط. فيما يلي قائمة بالمعلمات المستخدمة للطريقة:

  • أعلى - الإزاحة الرأسية للملصق من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • اليسار - الإزاحة الرأسية للملصق من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • ارتفاع - ارتفاع الملصق بوحدات 1/4000 من منطقة الرسم البياني.
  • العرض - عرض الملصق بوحدات 1/4000 من مساحة الرسم البياني.

طريقة إرجاعAspose.Cells.Drawing.Labelموضوع. المُلصَق فئة تمثل تسمية في الرسم البياني. لها بعض الأعضاء المهمين:

  • نص(خاصية) - تحدد سلسلة التسمية التوضيحية.
  • ملء (خاصية) - تحدد سمات لون التعبئة.

يوضح المثال التالي كيفية إضافة تسمية إلى المخطط. يستخدم المثال ملف المصمم (exp_piechart.xls) الذي يحتوي على مخطط بداخله. نستخدم هذا الملف لإدراج تسمية في الرسم البياني. يوجد أدناه الرمز الأصلي لإضافة تسمية إلى الرسم البياني. يتم إنشاء الإخراج التالي عند تنفيذ التعليمات البرمجية.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the existing file.
Workbook workbook = new Workbook(dataDir + "chart.xls");
// Get the designer chart in the second sheet.
Worksheet sheet = workbook.Worksheets[1];
Aspose.Cells.Charts.Chart chart = sheet.Charts[0];
// Add a new label to the chart.
Aspose.Cells.Drawing.Label label = chart.Shapes.AddLabelInChart(100, 100, 350, 900);
// Set the caption of the label.
label.Text = "A Label In Chart";
// Set the Placement Type, the way the
// Label is attached to the cells.
label.Placement = Aspose.Cells.Drawing.PlacementType.FreeFloating;
// Save the excel file.
workbook.Save(dataDir + "chart.out.xls");

إضافة عنصر تحكم مربع نص إلى التخطيط

تتمثل إحدى طرق تمييز المعلومات المهمة في التقرير في استخدام مربع نص. على سبيل المثال ، أدخل نصًا لتمييز اسم الشركة أو للإشارة إلى المنطقة الجغرافية التي تحقق أعلى مبيعات. الAspose.Cells.Drawing.ShapeCollection توفر class طريقة تسمىAddTextBoxInChart، والذي يستخدم لإضافة عنصر تحكم مربع نص إلى مخطط. فيما يلي قائمة المعلمات المستخدمة للطريقة:

  • أعلى - الإزاحة الرأسية لمربع النص من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • اليسار - الإزاحة الرأسية لمربع النص من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • ارتفاع ارتفاع مربع النص بوحدات 1/4000 من مساحة الرسم البياني.
  • العرض - عرض مربع النص بوحدات 1/4000 من مساحة الرسم البياني.

طريقة إرجاعAspose.Cells.Drawing.TextBox موضوع. المربع الكتابةيمثل class مربع نص في الرسم البياني.

يوضح المثال التالي كيفية إضافة مربع نص إلى مخطط. يستخدم المثال ملف المصمم السابق (exp_piechart.xls) الذي يحتوي على مخطط بداخله. نستخدم هذا الملف لإدراج مربع نص في المخطط لإظهار عنوان المخطط. يوجد أدناه الرمز الأصلي لإضافة مربع نص إلى المخطط.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the existing file.
Workbook workbook = new Workbook(dataDir + "chart.xls");
// Get the designer chart in the second sheet.
Worksheet sheet = workbook.Worksheets[1];
Aspose.Cells.Charts.Chart chart = sheet.Charts[0];
// Add a new textbox to the chart.
Aspose.Cells.Drawing.TextBox textbox0 = chart.Shapes.AddTextBoxInChart(100, 1100, 350, 2550);
// Fill the text.
textbox0.Text = "Sales By Region";
// Get the textbox text frame.
// Aspose.Cells.Drawing.MsoTextFrame textframe0 = textbox0.TextFrame;
// Set the textbox to adjust it according to its contents.
// textframe0.AutoSize = true;
// Set the font color.
textbox0.Font.Color = Color.Maroon;
// Set the font to bold.
textbox0.Font.IsBold = true;
// Set the font size.
textbox0.Font.Size = 14;
// Set font attribute to italic.
textbox0.Font.IsItalic = true;
// Get the filformat of the textbox.
Aspose.Cells.Drawing.FillFormat fillformat = textbox0.Fill;
// Get the lineformat type of the textbox.
Aspose.Cells.Drawing.LineFormat lineformat = textbox0.Line;
// Set the line weight.
lineformat.Weight = 2;
// Set the dash style to solid.
lineformat.DashStyle = Aspose.Cells.Drawing.MsoLineDashStyle.Solid;
// Save the excel file.
workbook.Save(dataDir + "chart.out.xls");

إضافة صورة إلى المخطط

Aspose.Cells يسمح لك بادراج صور في مخطط. على سبيل المثال ، أضف صورة للتأكيد أو لإعطاء معنى أكبر للمخطط أو محتوياته ، أو قم بإدراج ملف صورة العلامة التجارية.

الAspose.Cells.Drawing.ShapeCollection توفر class طريقة تسمىAddPictureInChart، والذي يستخدم لإضافة كائن صورة إلى المخطط. فيما يلي قائمة المعلمات المستخدمة للطريقة:

  • أعلى الإزاحة الرأسية للصورة من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • اليسار الإزاحة الرأسية للصورة من الزاوية اليسرى العليا بوحدات 1/4000 من منطقة الرسم البياني.
  • مجرى - كائن تيار يحتوي على بيانات الصورة.
  • العرض - مقياس عرض الصورة ، قيمة النسبة المئوية.
  • الارتفاع - مقياس ارتفاع الصورة ، قيمة النسبة المئوية.

تقوم الطريقة بإرجاع ملفAspose.Cells.Drawing.Picture موضوع. الصورةفئة تمثل كائن صورة في الرسم البياني.

يوضح المثال التالي كيفية إضافة صورة إلى المخطط. يستخدم المثال ملف المصمم السابق (exp_piechart.xls) الذي يحتوي على مخطط بداخله. نستخدم هذا الملف لإدراج صورة في الرسم البياني. يوجد أدناه الرمز الأصلي لإضافة صورة إلى الرسم البياني.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Open the existing file.
Workbook workbook = new Workbook(dataDir + "chart.xls");
// Get an image file to the stream.
FileStream stream = new FileStream(dataDir + "logo.jpg", FileMode.Open, FileAccess.Read);
// Get the designer chart in the second sheet.
Worksheet sheet = workbook.Worksheets[0];
Aspose.Cells.Charts.Chart chart = sheet.Charts[0];
// Add a new picture to the chart.
Aspose.Cells.Drawing.Picture pic0 = chart.Shapes.AddPictureInChart(50, 50, stream, 40, 40);
// Get the lineformat type of the picture.
Aspose.Cells.Drawing.LineFormat lineformat = pic0.Line;
// Set the dash style.
lineformat.DashStyle = Aspose.Cells.Drawing.MsoLineDashStyle.Solid;
// Set the line weight.
lineformat.Weight = 4;
// Save the excel file.
workbook.Save(dataDir + "chart.out.xls");

إضافة خانة اختيار في الرسم البياني

Aspose.Cells يسمح لك بإدراج مربعات الاختيار في ورقة المخطط باستخدامMsoDrawingType تعداد. يوضح المثال التالي إضافة خانة اختيار إلى ورقة المخطط.

تُظهر الصورة التالية ورقة المخطط مع مربع الاختيار في ملف الإخراج.

ما يجب القيام به: image_بديل_نص

الملف إلاخراجتم إنشاؤه بواسطة مقتطف الشفرة التالي مرفقًا كمرجع لك.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Adding a chart to the worksheet
int index = workbook.Worksheets.Add(SheetType.Chart);
Worksheet sheet = workbook.Worksheets[index];
sheet.Charts.AddFloatingChart(ChartType.Column, 0, 0, 1024, 960);
sheet.Charts[0].NSeries.Add("{1,2,3}", false);
// Add checkbox to the chart.
sheet.Charts[0].Shapes.AddShapeInChart(MsoDrawingType.CheckBox, PlacementType.Move, 400, 400, 1000, 600);
sheet.Charts[0].Shapes[0].Text = "CheckBox 1";
// Save the excel file.
workbook.Save(outputDir + "InsertCheckboxInChartSheet_out.xlsx");

موضوعات مسبقة