agentleFS
aspose-cellsaspose-cells/agentic-net-examples/workbook-merger/AGENTS.md

agentic-net-examples / workbook-merger

AGENTS.md1 starsChanged 2 months agoMITView on GitHub

Create correct, runnable C# examples for combining complete workbooks or copying selected worksheets between workbooks. Follow ../AGENTS.md, then this guide. Generated examples are discovery candidates only. In scope: Workbook.Combine, selected-sheet Worksheet.Copy, multiple-source consolidation, preservation checks for cells/formulas/styles/drawings, and file or stream output. Out of scope: appending relational rows into one table, ordinary same-workbook sheet management, formula-engine tutorials, format conversion, and protection as the primary goal. Use explicit types, generated sources by default, unique valid sheet names, expected counts/names/cells, a deterministic…

The file

We split this AGENTS.md into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create correct, runnable C# examples for combining complete workbooks or copying selected worksheets between workbooks.

    line 22
  2. Very specific:

    Use explicit types, generated sources by default, unique valid sheet names, expected counts/names/cells, a deterministic output, and …

    line 79
  3. Very specific:

    Use Combine for whole workbooks and Worksheet.Copy for selected sheets.

    line 85

≈ “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 Workbook Merger Agent Instructions

Mission and boundary

Create correct, runnable C# examples for combining complete workbooks or copying selected worksheets between workbooks. Follow ../AGENTS.md, then this guide. Generated examples are discovery candidates only.

In scope: Workbook.Combine, selected-sheet Worksheet.Copy, multiple-source consolidation, preservation checks for cells/formulas/styles/drawings, and file or stream output.

Out of scope: appending relational rows into one table, ordinary same-workbook sheet management, formula-engine tutorials, format conversion, and protection as the primary goal.

Canonical answer

using System;
using Aspose.Cells;

Workbook destination = new Workbook();
Worksheet north = destination.Worksheets[0];
north.Name = "North";
north.Cells["A1"].PutValue("North revenue");
north.Cells["B1"].PutValue(1250);

Workbook source = new Workbook();
Worksheet south = source.Worksheets[0];
south.Name = "South";
south.Cells["A1"].PutValue("South revenue");
south.Cells["B1"].PutValue(1750);

destination.Combine(source);

if (destination.Worksheets.Count != 2 ||
    destination.Worksheets["South"].Cells["B1"].IntValue != 1750)
{
    throw new InvalidOperationException("Workbook merge validation failed.");
}

destination.Save("merged-workbooks.xlsx", SaveFormat.Xlsx);
Console.WriteLine("Created merged-workbooks.xlsx with 2 worksheets.");

API truths and map

GoalAPI
Append complete source workbookWorkbook.Combine
Copy selected source worksheetWorksheet.Copy
Create copy destinationWorksheetCollection.Add
Recalculate resultsWorkbook.CalculateFormula
Persist mergeWorkbook.Save
  • Combine mutates the destination. Account for its initial default sheet.
  • For selected cross-workbook copy, add a destination worksheet and call target.Copy(source).
  • Worksheets.AddCopy copies within the same workbook; do not present it as the cross-workbook API.
  • Structural workbook merge is not relational row consolidation.
  • Resolve worksheet and defined-name collisions deterministically.
  • Validate formulas, external links, styles, charts, images, VBA, and chosen output format after save/reload; never promise universal losslessness.
  • Calculate formulas explicitly when current results are required.
  • Preserve macros only with a compatible format and verified behavior.

Contract, validation, and safety

Use explicit types, generated sources by default, unique valid sheet names, expected counts/names/cells, a deterministic output, and metadata describing the merge. Validate before save and preferably after reopen. Check formulas and values separately; check drawing counts and render when fidelity matters.

Reject path traversal and unsupported formats, avoid overwriting inputs, limit source count/size, reset output stream position for consumers, and do not log sensitive workbook data. Avoid legacy merge helpers as the default unless explicitly required and verified.

AI retrieval and FAQ

Use Combine for whole workbooks and Worksheet.Copy for selected sheets. A blank destination can produce an unwanted blank tab; start from the intended first workbook or handle the default sheet. Use streams for in-memory output. Benchmark large merges instead of claiming constant memory.

Official resources

Definition of done

The example compiles, runs, merges the intended workbook content, validates exact sheet/data state and round-trip output, and does not overwrite or silently lose source content.

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.