Lookup and reference functions
WRAPROWS
Matches all 7 recorded answers
Recorded: 7 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | WRAPROWS |
| Bulgarian | WRAPROWS |
| Czech | ZABALŘÁDKY |
| Danish | FOLDRÆKKER |
| German | WRAPROWS |
| Greek | WRAPROWS |
| English (Australia) | WRAPROWS |
| English (United Kingdom) | WRAPROWS |
| English (United States) | WRAPROWS |
| Spanish | AJUSTARFILAS |
| Estonian | WRAPROWS |
| Finnish | RIVITÄRIV |
| French | ORGA.LIGNES |
| Hebrew | WRAPROWS |
| Croatian | WRAPROWS |
| Hungarian | SORTÖRDELÉS |
| Indonesian | WRAPROWS |
| Italian | WRAPROWS |
| Japanese | WRAPROWS |
| Korean | WRAPROWS |
| Lithuanian | WRAPROWS |
| Latvian | WRAPROWS |
| Norwegian | WRAPROWS |
| Dutch | OMLOOP.RIJEN |
| Polish | ZAWIŃ.WIERSZE |
| Portuguese (Brazil) | WRAPROWS |
| Portuguese (Portugal) | MOLDARLINS |
| Romanian | WRAPROWS |
| Russian | СВЕРНСТРОК |
| Slovak | WRAPROWS |
| Slovenian | WRAPROWS |
| Serbian (Latin) | WRAPROWS |
| Swedish | BRYTRAD |
| Thai | WRAPROWS |
| Turkish | SATIRSAR |
| Ukrainian | WRAPROWS |
| Vietnamese | WRAPROWS |
| Chinese (Simplified) | WRAPROWS |
| Chinese (Hong Kong) | WRAPROWS |
| Chinese (Traditional) | WRAPROWS |
Names from Microsoft's support site.
What it does
WRAPROWS(vector, wrap_count, [pad_with])
WRAPROWS turns a vector into a rectangle, filling it row by row.
Given a vector of N elements and a wrap count k, the result has k columns and ⌈N / k⌉
rows: the first k elements become row 1 (left to right), the next k become row 2, and so
on. When N is not a multiple of k, the final row is short and its remaining cells take the
pad_with value.
WRAPROWS({1,2,3,4,5}, 3) gives
1 2 3
4 5 #N/A
This is the arrangement people usually have in mind when they say "wrap": reading order, left
to right then down, like text in a paragraph. WRAPCOLS does the same job in the other
direction and is the one that surprises.
Two points about the argument's meaning:
wrap_countis the row width — how many values fit on a row — and the number of rows is derived. It is not "make mekrows".- The result's height grows with the input's length, so the output shape is not determined by the input's shape alone.
When wrap_count is greater than or equal to N, everything fits on one row and the result is
a single-row array with no padding.
Arguments
Microsoft documents WRAPROWS(vector, wrap_count, [pad_with]).
vector — required, and genuinely one-dimensional: a single row or a single column. A
rectangular input is documented as #VALUE! on the twin function's page, not silently
flattened.
wrap_count — required. The maximum number of values per row, and therefore the result's
column count. Documented as #NUM! when less than 1.
pad_with — optional, default #N/A. Placed in the trailing cells of the short final
row.
As on WRAPCOLS and VSTACK, the error-valued default is deliberate: padding that announces
itself cannot be mistaken for data. Supplying pad_with explicitly is preferable to wrapping
the whole call in IFERROR, which would also erase genuine #N/A values coming from the
source.
Try it
Quirks
Result and edge cases
The return kind is a two-dimensional array of wrap_count columns.
- Exact multiples produce no padding.
wrap_count ≥ Ngives a single row.wrap_count = 1gives a single column — one element per row.- A one-element vector gives a 1×1 array, which must stay array-shaped.
pad_withis placed verbatim, without coercion to the vector's type.- Errors and blanks inside
vectorare ordinary elements; a genuine#N/Ain the data is indistinguishable in the result from default padding. - Dynamic-array publication and
#SPILL!are host-side adaptation, described in the call pipeline.
Errors
The documented conditions for this pair, taken from the twin function's page:
| Error | Documented condition |
|---|---|
#VALUE! | vector is not a one-dimensional array |
#NUM! | wrap_count is less than 1 |
#N/A | Placed in each cell of the return array that has no result — the default padding |
The Handbook has not separately confirmed that the WRAPROWS page states these identically;
they are recorded here as the documented conditions for the pair.
How to implement
Notes for implementers
- Output shape is
⌈N / wrap_count⌉ × wrap_count. The ceiling and the final-row remainder are the two off-by-one sites. - Row-major fill is the defining behaviour and must not be reachable by flipping a flag on the column-major path without also flipping the shape derivation.
pad_withdefaults to an error value and is placed without coercion.- One-dimensionality is validated, not repaired.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
WRAPROWS · 3 lines · calc-func/src/catalogue/arrays.rs on GitHub14 wraprows_fn "WRAPROWS" (2, 3) [R "vector", V "wrap_count", V "pad_with"] |s, a, sv| {
run(s, a, sv, k::eval_wraprows_prepared)
}
eval_wraprows_prepared · 29 lines · calc-func/src/ported/dynamic_array_reshape_family.rs on GitHubpub fn eval_wraprows_prepared(
args: &[CalcValue],
) -> Result<CalcValue, DynamicArrayReshapeEvalError> {
let wrap_count = wrap_count(&args[1])?;
match args[0].core_ref() {
CoreRef::Number(_) | CoreRef::Text(_) | CoreRef::Logical(_) | CoreRef::Error(_) => {
return Ok(args[0].clone());
}
CoreRef::Array(_) | CoreRef::Reference(_) | CoreRef::Missing | CoreRef::Empty => {}
}
let source = wrap_vector(&args[0])?;
let pad_cell = args
.get(2)
.map(scalar_cell)
.unwrap_or(CalcValue::error(WorksheetErrorCode::NA));
let flat = flatten_cells(&source, false);
// A maximum width does not pad a vector that already fits in a single row.
let cols = wrap_count.min(flat.len());
let rows = flat.len().div_ceil(cols);
let mut cells = Vec::with_capacity(rows * cols);
let mut iter = flat.into_iter();
for _row in 0..rows {
for _col in 0..cols {
cells.push(iter.next().unwrap_or_else(|| pad_cell.clone()));
}
}
build_array(rows, cols, cells)
}
Kernels shared with other functions
preparedcatalogue/arraysprepared_onecatalogue/arraysresultcatalogue/arraysruncatalogue/arrayscoerce_prepared_to_numberported/dynamic_array_reshape_familyscalar_cellported/dynamic_array_reshape_familymaterialize_array_argported/dynamic_array_reshape_familyshapeported/dynamic_array_reshape_familygetported/dynamic_array_reshape_familyparse_integerported/dynamic_array_reshape_familyparse_positive_integerported/dynamic_array_reshape_familybuild_arrayported/dynamic_array_reshape_familyflatten_cellsported/dynamic_array_reshape_familywrap_countported/dynamic_array_reshape_familywrap_vectorported/dynamic_array_reshape_familymap_dynamic_array_reshape_error_to_wsported/dynamic_array_reshape_family
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
WRAPCOLSis the twin, filling column by column withwrap_countas the column height. The pair are not transposes of one another in the simple sense:WRAPROWS(v, k)andTRANSPOSE(WRAPCOLS(v, k))both havekcolumns and put the same elements in the same reading order, so for the samekthey agree — but that identity is worth verifying rather than assuming, and it fails to hold in the obvious way once padding enters.TOROW/TOCOLare the inverse direction: rectangle to vector.EXPANDpads an array to a target size with a chosen filler, which is the explicit form ofWRAPROWS's incidental padding.SEQUENCE(rows, cols)builds a numbered rectangle directly.MAKEARRAYbuilds a rectangle from aLAMBDA, which is the general form of everything in this corner of the family.- Readers confuse
WRAPROWSwithTRANSPOSE(which does not change the element count per line) and withHSTACK(which concatenates rather than reshapes).
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents