أدخل خط سباركلين
Contents
[
Hide
]
أدخل خط مؤشر
Sparkline هو مخطط صغير في خلية ورقة عمل يوفر تمثيلًا مرئيًا للبيانات. استخدم خطوط المؤشرات لإظهار الاتجاهات في سلسلة من القيم ، مثل الزيادات أو النقصان الموسمية ، أو الدورات الاقتصادية ، أو لتمييز القيم القصوى والدنيا. ضع خط مؤشر بالقرب من بياناته للحصول على أكبر تأثير. هناك ثلاثة أنواع من خط المؤشر: الخطي والعمودي والمكدس.
من السهل إنشاء خط مؤشر باستخدام Aspose.Cells بأكواد الأمثلة التالية:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
// Instantiating a Workbook object | |
Workbook book = new Workbook(); | |
Worksheet sheet = book.Worksheets[0]; | |
sheet.Cells["A1"].PutValue(5); | |
sheet.Cells["B1"].PutValue(2); | |
sheet.Cells["C1"].PutValue(1); | |
sheet.Cells["D1"].PutValue(3); | |
// Define the CellArea | |
CellArea ca = new CellArea(); | |
ca.StartColumn = 4; | |
ca.EndColumn = 4; | |
ca.StartRow = 0; | |
ca.EndRow = 0; | |
int idx = sheet.SparklineGroups.Add(Aspose.Cells.Charts.SparklineType.Line, sheet.Name + "!A1:D1", false, ca); | |
SparklineGroup group = sheet.SparklineGroups[idx]; | |
group.Sparklines.Add(sheet.Name + "!A1:D1", 0, 4); | |
#region Customize Sparklines | |
// Create CellsColor | |
CellsColor clr = book.CreateCellsColor(); | |
clr.Color = Color.Orange; | |
group.SeriesColor = clr; | |
// set the high points are colored green and the low points are colored red | |
group.ShowHighPoint = true; | |
group.ShowLowPoint = true; | |
group.HighPointColor.Color = Color.Green; | |
group.LowPointColor.Color = Color.Red; | |
// set line weight | |
group.LineWeight = 1.0; | |
// you also can choose a nice visual style | |
// group.PresetStyle = SparklinePresetStyleType.Style10; | |
#endregion Customize Sparklines | |
// Saving the Excel file | |
book.Save(dataDir + "output.xlsx"); |