Skip to main content
prompt GP ChatGPT

layout — Claude Code prompt: sort and format spreadsheet layouts

layout — a Claude Code prompt that defines operations for sorting ranges, merging cells, freezing headers and configuring print settings in spreadsheet files. Runs whenever the agent needs to reorder data or prepare a sheet for printing.

Apache-2.0 ★ 12,746 updated 2026-10-29

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/layout.md
Open on GitHub

What layout does

The layout prompt gives Claude Code a precise set of xlsx operations: sorting cell ranges, adjusting row heights and column widths, hiding helper columns, freezing header rows and configuring page setup before printing.

Sorting is stable and works on current values — numbers before text, blank cells always last regardless of sort direction, with number-aware string comparison (item2 < item10). Ranges up to 2000 cells expand into per-cell changes so the agent can display before/after values; ranges up to 200,000 cells apply as a single bulk write. A range containing formulas is rejected outright, because moving formula text silently shifts relative references — the prompt tells the agent to explain this and suggest converting the column to values first.

Page setup options (set_page_setup) apply only to imported xlsx files and are written on save: orientation, paper size, scale, margins, repeating title rows and manual page breaks. scale and fitToWidth/fitToHeight are mutually exclusive. To install, place the file at .claude/commands/layout.md in your repository.

What it helps with

  • sort a table by a column without tearing rows apart
  • freeze the header row so it stays visible while scrolling
  • hide helper columns that hold intermediate calculations
  • set repeating title rows and manual page breaks before printing
  • merge cells for a section header without breaking data sorting

Example prompts for the agent

  • Sort range A1:C100 by column B ascending, first row is a header
  • Freeze the top row of the sheet and hide column D
  • Set up A4 landscape printing and repeat row 1 on every printed page

How to install layout

Manually: put the files in place

.claude/commands/layout.md

Questions about layout

How do I install layout in Claude Code?

Place the prompt file at .claude/commands/layout.md inside your repository. Claude Code picks it up automatically.

What does the layout prompt do?

It defines a set of spreadsheet operations: sorting ranges, merging and unmerging cells, resizing rows and columns, hiding, freezing and configuring page setup for printing.

Why does layout reject a sort on a range that contains formulas?

Moving rows with relative references changes what those references point to. The prompt instructs the agent to tell the user and suggest converting the formula column to values first.

Source text

layout.md · Apache-2.0
# Sorting & layout guide (layout)

## Sorting

`{op:"sort_range", sheetId, range:"A1:C10", byColumn:"B", order:"asc"|"desc", hasHeader?:true}`

- Stable sort by **current values**: numbers < text < booleans; blank cells always sort last regardless of direction; string comparison is number-aware (item2 < item10).
- byColumn must fall within range; when hasHeader is true the first row does not participate in the sort.
- Ranges of ≤2000 cells expand into per-cell changes in the preview (with concurrency protection), so the user can see each cell's before/after values; the range must be loaded first (read_range loads it).
- Larger ranges (up to 200,000 cells) apply as one range-level operation: the executor loads each region itself and writes the reordered rows in bulk — no per-cell preview.
- Only values move; each cell's formatting stays at its position (unlike Excel, which drags formats along with rows). On a column with mixed number formats the moved values take on the format of the row they land in.
- **A range containing formulas is rejected outright** — moving formula text silently changes what relative references point at. Explain the reason to the user (you may suggest converting the formula column to values first); do not try to work around it.
- Sort the whole table together: range must cover all related columns — sorting a single column tears rows apart.

## Merging

- `{op:"merge_cells", sheetId, range:"A1:C1"}` — rejected if it overlaps an existing merged region; needs at least two cells.
- `{op:"unmerge_cells", sheetId, range}` — clears all merges intersecting the range.
- Merging is mainly for title rows/category headers; avoid merging in data regions (it breaks sorting and formula filling).
- For title-like content prefer "merge + center + fill color" over scattered standalone cells.

## Row height & column width

- `{op:"set_row_height", sheetId, row:2, count?:1, heightPoints:24}` — height in points (2–409).
- `{op:"set_col_width", sheetId, column:"B", count?:1, widthPx:120}` — width in pixels (10–2000).
- Give report title rows extra height (e.g. 24–28pt); size data columns so content doesn't overflow, and keep similar columns the same width.

## Hiding rows/columns

- `{op:"set_rows_hidden", sheetId, row:5, count?:1, hidden:true|false}` — row is 1-based; hidden:false unhides.
- `{op:"set_cols_hidden", sheetId, column:"C", count?:1, hidden:true|false}`
- Hiding doesn't delete data and formula references are unaffected; good for hiding helper-calculation columns. To delete data use delete_rows/delete_cols (mind the batching discipline).

## Freeze panes

`{op:"set_freeze", sheetId, rows:1, columns:0}` — freezes the top rows rows and left columns columns; `rows:0, columns:0` unfreezes. Takes effect on the canvas immediately and is written into the file on save. Typical use: freeze the header row with `rows:1`.

## Page setup (printing)

`{op:"set_page_setup", sheetId, orientation?, paperSize?, scale?, fitToWidth?, fitToHeight?, margins?, printGridlines?, printHeadings?, printArea?, printTitles?, header?, footer?, rowBreaks?, colBreaks?}` — at least one property, only works on imported xlsx files, written on save:

- `orientation`: "portrait" | "landscape"
- `paperSize`: OOXML paper code (1=Letter, 8=A3, 9=A4, 11=A5)
- `scale`: print scaling 10–400(%); **mutually exclusive** with fitToWidth/fitToHeight (fit means "fit to N pages wide/tall", 0=automatic)
- `margins`: "normal" | "wide" | "narrow"
- `printGridlines` / `printHeadings`: print gridlines / row-column headings
- `printArea`: "A1:H40" sets the print area, null clears it
- `printTitles`: "1:1" repeats those rows at the top of every printed page, null clears
- `header` / `footer`: `{left?, center?, right?}` printed text; Excel codes work (&P page, &N pages, &D date, &F file name, &A sheet name); null clears
- `rowBreaks` / `colBreaks`: 1-based row/column numbers after which a new page starts; the list replaces the manual breaks, [] clears them
- Settings are only written into the file (take effect when printing); the canvas does not show pagination.

© genspark-ai · Apache-2.0 · genspark-ai/genoffice

Similar prompts

All prompts for Office documents →

From the same set65

The whole set →
course-slides course-slides converts handouts and lesson plans into structured slide decks with clear bullet points and complete speaker scripts. CX Codex +1 ★ 12,746repo stars email-drafter The email-drafter skill writes business emails and follow-up sequences in several tones. It can produce the user’s language, English, or separate bilingual versions. CX Codex +1 ★ 12,746repo stars lesson-plan Builds a classroom-ready lesson plan from the topic and the class profile: objectives, timed stages, activities, assessment and tiered homework. Delivered as a Word document. CX Codex +1 ★ 12,746repo stars interview-coach interview-coach builds targeted interview questions, STAR response scripts, and mock follow-up scenarios from your resume and target job description. CX Codex +1 ★ 12,746repo stars expense-report expense-report turns a stack of receipts into an expense claim workbook, with a line-by-line breakdown and a sheet listing what breaks the policy. CX Codex +1 ★ 12,746repo stars quiz-maker quiz-maker generates complete tests and quizzes by topic and difficulty, delivering ready-to-use Word documents with answer keys and error analyses. CX Codex +1 ★ 12,746repo stars business-plan This skill turns a project idea and source material into a Word business plan with market, product, competition, finance, and team sections. CX Codex +1 ★ 12,746repo stars budget-planner budget-planner turns a business plan or project spend into an Excel budget with account lines, a monthly spread, summaries and a separate assumptions sheet. CX Codex +1 ★ 12,746repo stars

More in the catalog

Project sponsors

Companies that keep this analytics open