Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ec71b5c
Add example: load-an-existing-workbook-and-import-asposecellscharts-n…
agent-aspose-cells-examples May 20, 2026
0754534
Add example: add-a-line-sparkline-to-column-b-using-data-range-a1a10-…
agent-aspose-cells-examples May 20, 2026
a86628b
Add example: create-a-column-sparkline-in-cell-c5-based-on-values-fro…
agent-aspose-cells-examples May 20, 2026
a1c3a02
Add example: insert-a-winloss-sparkline-at-cell-e2-referencing-data-i…
agent-aspose-cells-examples May 20, 2026
25b377c
Add example: apply-3d-formatting-with-thirty-degree-rotation-to-spark…
agent-aspose-cells-examples May 20, 2026
da4da97
Add example: set-sparkline-markers-to-display-high-points-using-red-c…
agent-aspose-cells-examples May 20, 2026
85cbade
Add example: delete-the-second-sparkline-in-the-first-sparkline-group…
agent-aspose-cells-examples May 20, 2026
ea495d2
Add example: read-the-value-of-the-third-sparkline-in-the-second-spar…
agent-aspose-cells-examples May 20, 2026
99d836a
Add example: batch-create-sparklines-for-rows-one-through-twenty-each…
agent-aspose-cells-examples May 20, 2026
4139a01
Add example: configure-sparkline-axis-minimum-and-maximum-to-fixed-nu…
agent-aspose-cells-examples May 20, 2026
8d3d15d
Add example: enable-display-of-both-first-and-last-points-in-line-spa…
agent-aspose-cells-examples May 20, 2026
dfdab01
Add example: set-sparkline-to-show-negative-points-using-custom-blue-…
agent-aspose-cells-examples May 20, 2026
7d7d874
Add example: apply-custom-line-weight-of-two-points-to-sparkline-grou…
agent-aspose-cells-examples May 20, 2026
e30c54d
Add example: set-sparkline-group-to-display-markers-for-both-high-and…
agent-aspose-cells-examples May 20, 2026
2d6ec76
Add example: remove-all-sparklines-from-active-worksheet-by-invoking-…
agent-aspose-cells-examples May 20, 2026
85e9a13
Add example: iterate-through-each-sparkline-collect-average-values-an…
agent-aspose-cells-examples May 20, 2026
af3ee10
Add example: validate-that-sparkline-data-range-does-not-contain-erro…
agent-aspose-cells-examples May 20, 2026
4c5f33a
Add example: save-the-modified-workbook-with-new-sparklines-to-an-xls…
agent-aspose-cells-examples May 20, 2026
c956c12
Add example: export-a-specific-sparkline-as-a-png-image-file-to-desig…
agent-aspose-cells-examples May 20, 2026
33e7d84
Add example: render-a-sparkline-to-a-memory-stream-for-embedding-into…
agent-aspose-cells-examples May 20, 2026
e248623
Add example: clone-an-existing-sparkline-group-and-place-the-clone-in…
agent-aspose-cells-examples May 20, 2026
7138e98
Add example: set-sparkline-3d-depth-property-to-higher-value-to-enhan…
agent-aspose-cells-examples May 20, 2026
5cdce17
Add example: adjust-sparkline-lighting-to-soft-mode-for-improved-appe…
agent-aspose-cells-examples May 20, 2026
f800627
Add example: change-sparkline-material-to-plastic-to-affect-surface-s…
agent-aspose-cells-examples May 20, 2026
70a5351
Add example: apply-custom-background-color-to-sparkline-chart-area-to…
agent-aspose-cells-examples May 20, 2026
5a5fcb8
Add example: enable-display-of-empty-cells-as-zero-values-in-sparklin…
agent-aspose-cells-examples May 20, 2026
332105e
Add example: configure-sparkline-to-ignore-hidden-cells-while-calcula…
agent-aspose-cells-examples May 20, 2026
192df3d
Add example: move-a-sparkline-from-original-location-to-new-cell-rang…
agent-aspose-cells-examples May 20, 2026
9ea829e
Add example: set-sparkline-group-orientation-to-vertical-for-columnty…
agent-aspose-cells-examples May 20, 2026
cf59091
Add example: create-a-sparkline-referencing-data-from-another-workshe…
agent-aspose-cells-examples May 20, 2026
ef9b166
Add example: handle-null-values-in-source-data-range-gracefully-when-…
agent-aspose-cells-examples May 20, 2026
ad6ece3
Add example: enable-sparkline-markers-only-for-outlier-points-exceedi…
agent-aspose-cells-examples May 20, 2026
72291d0
Add example: serialize-sparkline-group-settings-to-json-string-for-la…
agent-aspose-cells-examples May 20, 2026
ccec643
Add example: deserialize-sparkline-configuration-from-json-file-and-a…
agent-aspose-cells-examples May 20, 2026
fb9a30c
Add example: write-a-unit-test-verifying-that-adding-a-sparkline-incr…
agent-aspose-cells-examples May 20, 2026
3fd0ff6
Add example: benchmark-performance-of-creating-five-thousand-sparklin…
agent-aspose-cells-examples May 20, 2026
5f6c178
Update agents.md
agent-aspose-cells-examples May 31, 2026
6d9dcc6
Merge remote-tracking branch 'origin/release/26.5.0' into v3/sparkline
agent-aspose-cells-examples May 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11459,6 +11459,116 @@
"file": "iterate-through-each-sparkline-collect-average-values-and-store-results-in-a-list.cs",
"title": "Iterate through each sparkline, collect average values, and store results in a list."
},
{
"category": "sparkline",
"file": "add-a-line-sparkline-to-column-b-using-data-range-a1a10-via-sparklinecollectionadd.cs",
"title": "Add a line sparkline to column B using data range A1:A10 via SparklineCollection.Add."
},
{
"category": "sparkline",
"file": "adjust-sparkline-lighting-to-soft-mode-for-improved-appearance-in-excel-2010-files.cs",
"title": "Adjust sparkline lighting to 'Soft' mode for improved appearance in Excel 2010 files."
},
{
"category": "sparkline",
"file": "apply-3d-formatting-with-thirty-degree-rotation-to-sparkline-group-located-at-g1.cs",
"title": "Apply 3D formatting with thirty-degree rotation to sparkline group located at G1."
},
{
"category": "sparkline",
"file": "apply-custom-background-color-to-sparkline-chart-area-to-match-workbook-theme-colors.cs",
"title": "Apply custom background color to sparkline chart area to match workbook theme colors."
},
{
"category": "sparkline",
"file": "apply-custom-line-weight-of-two-points-to-sparkline-group-situated-in-cell-k7.cs",
"title": "Apply custom line weight of two points to sparkline group situated in cell K7."
},
{
"category": "sparkline",
"file": "batch-create-sparklines-for-rows-one-through-twenty-each-using-corresponding-column-data-range.cs",
"title": "Batch create sparklines for rows one through twenty, each using corresponding column data range."
},
{
"category": "sparkline",
"file": "benchmark-performance-of-creating-five-thousand-sparklines-in-a-large-workbook-to-assess-scalability.cs",
"title": "Benchmark performance of creating five thousand sparklines in a large workbook to assess scalability."
},
{
"category": "sparkline",
"file": "change-sparkline-material-to-plastic-to-affect-surface-shading-and-give-subtle-glossy-effect.cs",
"title": "Change sparkline material to 'Plastic' to affect surface shading and give subtle glossy effect."
},
{
"category": "sparkline",
"file": "clone-an-existing-sparkline-group-and-place-the-clone-into-a-different-worksheet.cs",
"title": "Clone an existing sparkline group and place the clone into a different worksheet."
},
{
"category": "sparkline",
"file": "configure-sparkline-axis-minimum-and-maximum-to-fixed-numeric-values-for-consistent-scaling.cs",
"title": "Configure sparkline axis minimum and maximum to fixed numeric values for consistent scaling."
},
{
"category": "sparkline",
"file": "configure-sparkline-to-ignore-hidden-cells-while-calculating-values-to-reflect-only-visible-data.cs",
"title": "Configure sparkline to ignore hidden cells while calculating values to reflect only visible data."
},
{
"category": "sparkline",
"file": "create-a-column-sparkline-in-cell-c5-based-on-values-from-d5d15-range.cs",
"title": "Create a column sparkline in cell C5 based on values from D5:D15 range."
},
{
"category": "sparkline",
"file": "create-a-sparkline-referencing-data-from-another-worksheet-named-datasheet-for-crosssheet-trends.cs",
"title": "Create a sparkline referencing data from another worksheet named 'DataSheet' for cross\u2011sheet trends."
},
{
"category": "sparkline",
"file": "delete-the-second-sparkline-in-the-first-sparkline-group-using-sparklinegroupremoveat-method.cs",
"title": "Delete the second sparkline in the first sparkline group using SparklineGroup.RemoveAt method."
},
{
"category": "sparkline",
"file": "deserialize-sparkline-configuration-from-json-file-and-apply-settings-to-newly-created-workbook.cs",
"title": "Deserialize sparkline configuration from JSON file and apply settings to newly created workbook."
},
{
"category": "sparkline",
"file": "enable-display-of-both-first-and-last-points-in-line-sparkline-located-at-i4.cs",
"title": "Enable display of both first and last points in line sparkline located at I4."
},
{
"category": "sparkline",
"file": "enable-display-of-empty-cells-as-zero-values-in-sparkline-at-cell-m9-for-accurate-totals.cs",
"title": "Enable display of empty cells as zero values in sparkline at cell M9 for accurate totals."
},
{
"category": "sparkline",
"file": "enable-sparkline-markers-only-for-outlier-points-exceeding-predefined-threshold-to-highlight-anomalies.cs",
"title": "Enable sparkline markers only for outlier points exceeding predefined threshold to highlight anomalies."
},
{
"category": "sparkline",
"file": "export-a-specific-sparkline-as-a-png-image-file-to-designated-output-directory.cs",
"title": "Export a specific sparkline as a PNG image file to designated output directory."
},
{
"category": "sparkline",
"file": "handle-null-values-in-source-data-range-gracefully-when-generating-sparkline-to-avoid-rendering-errors.cs",
"title": "Handle null values in source data range gracefully when generating sparkline to avoid rendering errors."
},
{
"category": "sparkline",
"file": "insert-a-winloss-sparkline-at-cell-e2-referencing-data-in-f2f12-range.cs",
"title": "Insert a win/loss sparkline at cell E2 referencing data in F2:F12 range."
},
{
"category": "sparkline",
"file": "iterate-through-each-sparkline-collect-average-values-and-store-results-in-a-list.cs",
"title": "Iterate through each sparkline, collect average values, and store results in a list."
},
{
"category": "sparkline",
"file": "load-an-existing-workbook-and-import-asposecellscharts-namespace-for-sparkline-operations.cs",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Aspose.Cells;
using Aspose.Cells.Charts;

class Program
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

// Populate sample data in the range A1:A10
for (int i = 0; i < 10; i++)
{
// Row index i, column index 0 corresponds to column A
worksheet.Cells[i, 0].PutValue(i + 1);
}

// Add a sparkline group of type Line to the worksheet
int groupIndex = worksheet.SparklineGroups.Add(SparklineType.Line);
SparklineGroup sparklineGroup = worksheet.SparklineGroups[groupIndex];

// Add a sparkline that uses the data range A1:A10
// Place the sparkline in column B (index 1) at the first row (index 0)
sparklineGroup.Sparklines.Add("A1:A10", 0, 1);

// Save the workbook to a file
workbook.Save("SparklineLine.xlsx");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Drawing;
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Drawing;

class AdjustSparklineLighting
{
static void Main()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Populate sample data for the sparkline
sheet.Cells["A1"].PutValue(5);
sheet.Cells["B1"].PutValue(2);
sheet.Cells["C1"].PutValue(1);
sheet.Cells["D1"].PutValue(3);

// Define the location where the sparkline will be placed
CellArea location = new CellArea
{
StartRow = 0,
EndRow = 0,
StartColumn = 4,
EndColumn = 4
};

// Add a sparkline group (Line type) with the data range A1:D1
int groupIndex = sheet.SparklineGroups.Add(SparklineType.Line, "A1:D1", false, location);
SparklineGroup group = sheet.SparklineGroups[groupIndex];

// Add a sparkline to the group
group.Sparklines.Add(sheet.Name + "!A1:D1", 0, 4);

// NOTE:
// Aspose.Cells does not expose a direct property to modify the lighting of a sparkline.
// Lighting (e.g., LightRigType.Soft) is applicable to 3‑D shape formatting, which is
// available for chart series and other shapes, but not for sparkline groups.
// Therefore, the sparkline lighting cannot be set to 'Soft' via the current API.

// Save the workbook as an Excel 2010 file
workbook.Save("SparklineWithSoftLighting.xlsx", SaveFormat.Xlsx);
}
}
113 changes: 113 additions & 0 deletions sparkline/agents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
category: sparkline
framework: .NET
parent: ../agents.md
version: v2
---

# Persona

You are a C# developer specializing in Sparklines using Aspose.Cells for .NET.

Generate simple, correct, production-quality examples that demonstrate ONE sparkline scenario at a time.

---

# Scope

- Standalone .cs examples
- One operation per example
- Fully runnable with dotnet run
- No external dependencies

---

# Required Namespaces

using System;
using Aspose.Cells;

---

# Key APIs

- SparklineGroup
- SparklineCollection
- SparklineGroupCollection
- Worksheet.SparklineGroups
- SparklineType

---

# Common Pattern

1. Create workbook
2. Add sample numeric data
3. Create sparkline
4. Configure sparkline properties
5. Save workbook
6. Print success message

---

# Sparkline Rules

- Use valid numeric source ranges
- Use SparklineType appropriate to the scenario
- Ensure destination cells are visible
- One example = one sparkline operation

---

# Input Strategy

- Do NOT rely on external XLSX files
- Create all sample data programmatically
- Keep examples self-contained

---

# Output Rules

- Always generate output.xlsx
- Ensure workbook is saved successfully
- Output files are written to the working directory

---

# Common Tasks

- Create line sparkline
- Create column sparkline
- Create win/loss sparkline
- Modify sparkline settings
- Access sparkline groups

---

# Common Mistakes

❌ var workbook = new Workbook();
✅ Workbook workbook = new Workbook();

❌ Create sparklines without source data
✅ Populate worksheet data before creating sparklines

❌ Workbook workbook = new Workbook("input.xlsx");
✅ Workbook workbook = new Workbook();

---

# Code Simplicity

- Keep examples concise
- Avoid unnecessary abstractions

---

# General Rules

Refer to the root agents.md for:
- Boundaries
- Testing requirements
- Build and run instructions
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Aspose.Cells;
using Aspose.Cells.Charts;

class Sparkline3DExample
{
static void Main()
{
try
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

// Populate sample data for the sparkline (A1:A5)
for (int i = 0; i < 5; i++)
{
sheet.Cells[i, 0].PutValue(i + 1); // Values 1‑5 in column A
}

// Define the location range for the sparkline group (G1:G5)
// Column G = index 6 (0‑based), rows 0‑4
CellArea location = new CellArea
{
StartRow = 0,
EndRow = 4,
StartColumn = 6,
EndColumn = 6
};

// Add a sparkline group of type Line with the data range A1:A5
int groupIndex = sheet.SparklineGroups.Add(SparklineType.Line, "A1:A5", false, location);
SparklineGroup group = sheet.SparklineGroups[groupIndex];

// Note: Sparkline groups do not support 3‑D formatting.

// Save the workbook
workbook.Save("Sparkline3DExample.xlsx");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
Loading