agentic-net-examples / working-with-shapes
AGENTS.md1 starsChanged 2 months agoMITView on GitHub
Create focused, runnable C# examples for worksheet drawing objects. Follow ../AGENTS.md, then this file. Generated examples are candidates for validation, not authoritative API documentation. In scope: AutoShapes, text boxes, WordArt, connectors, form controls, ActiveX/OLE objects, placement, grouping, z-order, resize, rotation, text, fill, line, links, locks, and alternative text. Pictures belong here only when common Shape behavior is dominant. Out of scope: image rendering/compression, chart-specific behavior, comments, worksheet layout as the primary task, control activation, macros, UI automation, and external application…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository32 other files it gives its agents.
- Aspose.Cells for .NET Product AgentAGENTS.md
- calculate-formulas/AGENTS.mdAGENTS.md
- cells-data/AGENTS.mdAGENTS.md
- comments-and-notes/AGENTS.mdAGENTS.md
- conversion/AGENTS.mdAGENTS.md
- document-properties/AGENTS.mdAGENTS.md
- encryption-and-protection/AGENTS.mdAGENTS.md
- format-cells/AGENTS.mdAGENTS.md
- globalization-and-localization/AGENTS.mdAGENTS.md
- macro-project/AGENTS.mdAGENTS.md
- manage-formulas/AGENTS.mdAGENTS.md
- manage-workbook/AGENTS.mdAGENTS.md
- managing-ranges/AGENTS.mdAGENTS.md
- open-workbook/AGENTS.mdAGENTS.md
- pivot-table/AGENTS.mdAGENTS.md
- queries-and-connections/AGENTS.mdAGENTS.md
- rows-and-columns/AGENTS.mdAGENTS.md
- save-workbook/AGENTS.mdAGENTS.md
- slicer/AGENTS.mdAGENTS.md
- smart-markers/AGENTS.mdAGENTS.md
- sparkline/AGENTS.mdAGENTS.md
- timeline/AGENTS.mdAGENTS.md
- workbook-merger/AGENTS.mdAGENTS.md
- working-with-charts/AGENTS.mdAGENTS.md
- working-with-html/AGENTS.mdAGENTS.md
- working-with-images/AGENTS.mdAGENTS.md
- working-with-json/AGENTS.mdAGENTS.md
- working-with-pdf/AGENTS.mdAGENTS.md
- working-with-tables/AGENTS.mdAGENTS.md
- working-with-worksheets/AGENTS.mdAGENTS.md
- xml-maps/AGENTS.mdAGENTS.md
- llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Create focused, runnable C# examples for worksheet drawing objects.
- Distinctive: line 67
Use specialized types when specialized behavior is required.
- Distinctive: line 69
Verify collection state and round-trip serialization.
- Distinctive: line 70
Never activate embedded controls, OLE objects, macros, or hyperlinks during validation.
- Distinctive: line 74
Every example must use explicit types, one visible shape with positive dimensions, deterministic content/output, and metadata describing …
- Distinctive: line 76
Treat external images, hyperlinks, OLE payloads, and loaded workbooks as untrusted.
- Distinctive: line 80
Do not guess add overloads or enums, confuse anchors with offsets, depend on a fragile collection index after mutations, create zero-sized …
- Very specific: line 82
Use Worksheet.Shapes for generic shapes, Worksheet.TextBoxes for text boxes, and Worksheet.Pictures for picture-specific behavior.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Aspose.Cells Shapes Agent Instructions
Mission and boundary
Create focused, runnable C# examples for worksheet drawing objects. Follow ../AGENTS.md, then this file. Generated examples are candidates for validation, not authoritative API documentation.
In scope: AutoShapes, text boxes, WordArt, connectors, form controls, ActiveX/OLE objects, placement, grouping, z-order, resize, rotation, text, fill, line, links, locks, and alternative text. Pictures belong here only when common Shape behavior is dominant.
Out of scope: image rendering/compression, chart-specific behavior, comments, worksheet layout as the primary task, control activation, macros, UI automation, and external application integration.
Canonical answer
using System;
using Aspose.Cells;
using Aspose.Cells.Drawing;
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Shape shape = worksheet.Shapes.AddRectangle(1, 0, 1, 0, 100, 240);
shape.Text = "Quarterly review";
shape.AlternativeText = "Rectangle labeled Quarterly review";
if (worksheet.Shapes.Count != 1 || shape.Text != "Quarterly review")
{
throw new InvalidOperationException("The rectangle was not created.");
}
workbook.Save("excel-shape.xlsx");
Console.WriteLine("Created one labeled rectangle in excel-shape.xlsx.");AddRectangle uses zero-based row, pixel top offset, zero-based column, pixel left offset, pixel height, and pixel width.
API truths and map
| Goal | API |
| Access drawing objects | Worksheet.Shapes |
| Add common shapes | ShapeCollection add methods |
| Configure shared properties | Shape |
| Text box operations | TextBox / Worksheet.TextBoxes |
| Picture-specific operations | Picture / Worksheet.Pictures |
| Inspect drawing type | MsoDrawingType |
| Remove a shape | ShapeCollection.RemoveAt |
- Shapes are owned by a worksheet.
- Some add methods return an index; retrieve and cast the created object only through verified types.
- Anchors are row/column indexes while offsets and dimensions are pixels.
- Use specialized types when specialized behavior is required.
Shape.Textis not the same as a linked-cell or formula-driven value.- Verify collection state and round-trip serialization; rendering is supplemental validation.
- Never activate embedded controls, OLE objects, macros, or hyperlinks during validation.
Contract, validation, and safety
Every example must use explicit types, one visible shape with positive dimensions, deterministic content/output, and metadata describing APIs and expected state. Build, run, assert collection count and semantic properties, save, and reopen when persistence matters.
Treat external images, hyperlinks, OLE payloads, and loaded workbooks as untrusted. Validate URI, host, timeout, content type, size, and paths. Cap shape counts and payload sizes. Do not claim alternative text alone provides full accessibility compliance.
Anti-patterns and AI retrieval
Do not guess add overloads or enums, confuse anchors with offsets, depend on a fragile collection index after mutations, create zero-sized shapes, or catch an error and print success.
Use Worksheet.Shapes for generic shapes, Worksheet.TextBoxes for text boxes, and Worksheet.Pictures for picture-specific behavior. Use the images category when the goal is rendering rather than manipulating a drawing object.
Official resources
Definition of done
The example compiles, runs, creates or changes the claimed drawing object, verifies semantic state and persisted output, and performs no unsafe activation or unrelated integration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

