agentleFS
aspose-cellsaspose-cells/agentic-net-examples/working-with-shapes/AGENTS.md

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…

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
  1. Very specific:

    Create focused, runnable C# examples for worksheet drawing objects.

    line 22
  2. Distinctive:

    Use specialized types when specialized behavior is required.

    line 67
  3. Distinctive:

    Verify collection state and round-trip serialization.

    line 69
  4. Distinctive:

    Never activate embedded controls, OLE objects, macros, or hyperlinks during validation.

    line 70
  5. Distinctive:

    Every example must use explicit types, one visible shape with positive dimensions, deterministic content/output, and metadata describing …

    line 74
  6. Distinctive:

    Treat external images, hyperlinks, OLE payloads, and loaded workbooks as untrusted.

    line 76
  7. Distinctive:

    Do not guess add overloads or enums, confuse anchors with offsets, depend on a fragile collection index after mutations, create zero-sized …

    line 80
  8. Very specific:

    Use Worksheet.Shapes for generic shapes, Worksheet.TextBoxes for text boxes, and Worksheet.Pictures for picture-specific behavior.

    line 82

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

GoalAPI
Access drawing objectsWorksheet.Shapes
Add common shapesShapeCollection add methods
Configure shared propertiesShape
Text box operationsTextBox / Worksheet.TextBoxes
Picture-specific operationsPicture / Worksheet.Pictures
Inspect drawing typeMsoDrawingType
Remove a shapeShapeCollection.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.Text is 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.