{
  "category": "Lookup and reference functions",
  "display_name": "WRAPROWS",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.WRAPROWS",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 7 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 7 recorded answers",
    "workbook_corpus": {
      "cells": 7,
      "matched": 7
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/arrays.rs#L697-L699",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/dynamic_array_reshape_family.rs#L572-L600"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/arrays::prepared",
        "catalogue/arrays::prepared_one",
        "catalogue/arrays::result",
        "catalogue/arrays::run",
        "ported/dynamic_array_reshape_family::coerce_prepared_to_number",
        "ported/dynamic_array_reshape_family::scalar_cell",
        "ported/dynamic_array_reshape_family::materialize_array_arg",
        "ported/dynamic_array_reshape_family::shape",
        "ported/dynamic_array_reshape_family::get",
        "ported/dynamic_array_reshape_family::parse_integer",
        "ported/dynamic_array_reshape_family::parse_positive_integer",
        "ported/dynamic_array_reshape_family::build_array",
        "ported/dynamic_array_reshape_family::flatten_cells",
        "ported/dynamic_array_reshape_family::wrap_count",
        "ported/dynamic_array_reshape_family::wrap_vector",
        "ported/dynamic_array_reshape_family::map_dynamic_array_reshape_error_to_ws"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/arrays.rs#L697-L699",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 7 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.WRAPROWS.json",
  "name": "WRAPROWS",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n\n- **`WRAPCOLS`** is the twin, filling column by column with `wrap_count` as the column height.\n  The pair are *not* transposes of one another in the simple sense: `WRAPROWS(v, k)` and\n  `TRANSPOSE(WRAPCOLS(v, k))` both have `k` columns and put the same elements in the same\n  reading order, so for the same `k` they agree — but that identity is worth verifying rather\n  than assuming, and it fails to hold in the obvious way once padding enters.\n- **`TOROW` / `TOCOL`** are the inverse direction: rectangle to vector.\n- **`EXPAND`** pads an array to a target size with a chosen filler, which is the explicit form\n  of `WRAPROWS`'s incidental padding.\n- **`SEQUENCE(rows, cols)`** builds a numbered rectangle directly.\n- **`MAKEARRAY`** builds a rectangle from a `LAMBDA`, which is the general form of everything\n  in this corner of the family.\n- Readers confuse `WRAPROWS` with `TRANSPOSE` (which does not change the element count per\n  line) and with `HSTACK` (which concatenates rather than reshapes).\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n- Output shape is `⌈N / wrap_count⌉ × wrap_count`. The ceiling and the final-row remainder are\n  the two off-by-one sites.\n- Row-major fill is the defining behaviour and must not be reachable by flipping a flag on the\n  column-major path without also flipping the shape derivation.\n- `pad_with` defaults to an error value and is placed without coercion.\n- One-dimensionality is validated, not repaired.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nThe return kind is a two-dimensional array of `wrap_count` columns.\n\n- **Exact multiples** produce no padding.\n- **`wrap_count ≥ N`** gives a single row.\n- **`wrap_count = 1`** gives a single column — one element per row.\n- **A one-element vector** gives a 1×1 array, which must stay array-shaped.\n- **`pad_with` is placed verbatim**, without coercion to the vector's type.\n- **Errors and blanks inside `vector`** are ordinary elements; a genuine `#N/A` in the data is\n  indistinguishable in the result from default padding.\n- Dynamic-array publication and `#SPILL!` are host-side adaptation, described in\n  [the call pipeline](../model/03-call-pipeline.md).\n\n\n\n### Errors\n\n\nThe documented conditions for this pair, taken from the twin function's page:\n\n| Error | Documented condition |\n|---|---|\n| `#VALUE!` | `vector` is not a one-dimensional array |\n| `#NUM!` | `wrap_count` is less than 1 |\n| `#N/A` | Placed in each cell of the return array that has no result — the default padding |\n\nThe Handbook has not separately confirmed that the `WRAPROWS` page states these identically;\nthey are recorded here as the documented conditions for the pair.\n\n\n",
    "sources": "- Microsoft, *WRAPROWS function* —\n  <https://support.microsoft.com/en-us/office/wraprows-function-796825f3-975a-4cee-9c84-1bbddf60ade0>\n  (syntax and the row-by-row placement rule). Not retrieved for this page; the behaviour above\n  is stated as documented behaviour and should be re-checked against the page.\n- Microsoft, *WRAPCOLS function* —\n  <https://support.microsoft.com/en-us/office/wrapcols-function-d038b05a-57b7-4ee0-be94-ded0792511e2>\n  (retrieved for this page; the twin's argument semantics, the `#N/A` default for `pad_with`,\n  and the `#VALUE!` and `#NUM!` conditions recorded above for the pair).\n- Handbook `content/model/01-value-universe.md` and `content/model/03-call-pipeline.md`.\n- Handbook `data/functions/FUNC.WRAPROWS.json` (signature, arity, classification axes).\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`WRAPROWS` turns a vector into a rectangle, filling it **row by row**.\n\nGiven a vector of `N` elements and a wrap count `k`, the result has `k` columns and `⌈N / k⌉`\nrows: the first `k` elements become row 1 (left to right), the next `k` become row 2, and so\non. When `N` is not a multiple of `k`, the final row is short and its remaining cells take the\n`pad_with` value.\n\n`WRAPROWS({1,2,3,4,5}, 3)` gives\n\n    1   2   3\n    4   5   #N/A\n\nThis is the arrangement people usually have in mind when they say \"wrap\": reading order, left\nto right then down, like text in a paragraph. `WRAPCOLS` does the same job in the other\ndirection and is the one that surprises.\n\nTwo points about the argument's meaning:\n\n- **`wrap_count` is the row *width*** — how many values fit on a row — and the number of rows\n  is derived. It is not \"make me `k` rows\".\n- **The result's height grows with the input's length**, so the output shape is not determined\n  by the input's shape alone.\n\nWhen `wrap_count` is greater than or equal to `N`, everything fits on one row and the result is\na single-row array with no padding.\n\n\n\n### Arguments\n\n\nMicrosoft documents `WRAPROWS(vector, wrap_count, [pad_with])`.\n\n**`vector`** — required, and genuinely one-dimensional: a single row or a single column. A\nrectangular input is documented as `#VALUE!` on the twin function's page, not silently\nflattened.\n\n**`wrap_count`** — required. The maximum number of values per row, and therefore the result's\ncolumn count. Documented as `#NUM!` when less than 1.\n\n**`pad_with`** — optional, **default `#N/A`**. Placed in the trailing cells of the short final\nrow.\n\nAs on `WRAPCOLS` and `VSTACK`, the error-valued default is deliberate: padding that announces\nitself cannot be mistaken for data. Supplying `pad_with` explicitly is preferable to wrapping\nthe whole call in `IFERROR`, which would also erase genuine `#N/A` values coming from the\nsource.\n\n\n"
  },
  "signature": {
    "display": "WRAPROWS(vector, wrap_count, [pad_with])",
    "parameters": [
      {
        "description": null,
        "name": "vector",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "wrap_count",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "pad_with",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 2
      },
      "category": "Lookup and reference functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "A row or column of values folded into rows of a given length",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Wraps the provided row or column of values by rows after a specified number of elements",
        "microsoft_url": "https://support.microsoft.com/en-us/office/wraprows-function-796825f3-975a-4cee-9c84-1bbddf60ade0"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "WRAPROWS"
        },
        {
          "locale": "bg-BG",
          "name": "WRAPROWS"
        },
        {
          "locale": "cs-CZ",
          "name": "ZABALŘÁDKY"
        },
        {
          "locale": "da-DK",
          "name": "FOLDRÆKKER"
        },
        {
          "locale": "de-DE",
          "name": "WRAPROWS"
        },
        {
          "locale": "el-GR",
          "name": "WRAPROWS"
        },
        {
          "locale": "en-AU",
          "name": "WRAPROWS"
        },
        {
          "locale": "en-GB",
          "name": "WRAPROWS"
        },
        {
          "locale": "en-US",
          "name": "WRAPROWS"
        },
        {
          "locale": "es-ES",
          "name": "AJUSTARFILAS"
        },
        {
          "locale": "et-EE",
          "name": "WRAPROWS"
        },
        {
          "locale": "fi-FI",
          "name": "RIVITÄRIV"
        },
        {
          "locale": "fr-FR",
          "name": "ORGA.LIGNES*"
        },
        {
          "locale": "he-IL",
          "name": "WRAPROWS"
        },
        {
          "locale": "hr-HR",
          "name": "WRAPROWS"
        },
        {
          "locale": "hu-HU",
          "name": "SORTÖRDELÉS"
        },
        {
          "locale": "id-ID",
          "name": "WRAPROWS"
        },
        {
          "locale": "it-IT",
          "name": "WRAPROWS"
        },
        {
          "locale": "ja-JP",
          "name": "WRAPROWS"
        },
        {
          "locale": "ko-KR",
          "name": "WRAPROWS"
        },
        {
          "locale": "lt-LT",
          "name": "WRAPROWS"
        },
        {
          "locale": "lv-LV",
          "name": "WRAPROWS"
        },
        {
          "locale": "nb-NO",
          "name": "WRAPROWS"
        },
        {
          "locale": "nl-NL",
          "name": "OMLOOP.RIJEN"
        },
        {
          "locale": "pl-PL",
          "name": "ZAWIŃ.WIERSZE"
        },
        {
          "locale": "pt-BR",
          "name": "WRAPROWS"
        },
        {
          "locale": "pt-PT",
          "name": "MOLDARLINS"
        },
        {
          "locale": "ro-RO",
          "name": "WRAPROWS"
        },
        {
          "locale": "ru-RU",
          "name": "СВЕРНСТРОК"
        },
        {
          "locale": "sk-SK",
          "name": "WRAPROWS"
        },
        {
          "locale": "sl-SI",
          "name": "WRAPROWS"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "WRAPROWS"
        },
        {
          "locale": "sv-SE",
          "name": "BRYTRAD"
        },
        {
          "locale": "th-TH",
          "name": "WRAPROWS"
        },
        {
          "locale": "tr-TR",
          "name": "SATIRSAR"
        },
        {
          "locale": "uk-UA",
          "name": "WRAPROWS"
        },
        {
          "locale": "vi-VN",
          "name": "WRAPROWS"
        },
        {
          "locale": "zh-CN",
          "name": "WRAPROWS"
        },
        {
          "locale": "zh-HK",
          "name": "WRAPROWS"
        },
        {
          "locale": "zh-TW",
          "name": "WRAPROWS"
        }
      ],
      "signature": {
        "display": "WRAPROWS(vector, wrap_count, [pad_with])",
        "parameters": [
          {
            "description": null,
            "name": "vector",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "wrap_count",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "pad_with",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "WRAPROWS",
      "version_marker": null,
      "xlcall": null
    },
    "microsoft": "https://support.microsoft.com/en-us/office/wraprows-function-796825f3-975a-4cee-9c84-1bbddf60ade0"
  },
  "try_it": {
    "formula": "=WRAPROWS({1;2;3;4},2)"
  },
  "url": "https://handbook.dnacalc.com/functions/WRAPROWS.html",
  "variants": [],
  "versions": []
}