REPT Function (LibreOffice Calc)
The REPT function in LibreOffice Calc repeats a text string a specified number of times. It is essential for padding, visualization, fixed-width formatting, and building lightweight text-based charts.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✔ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✔ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the REPT Function Does â–¾
- Repeats a text string N times
- Useful for padding and alignment
- Useful for bar charts and progress indicators
- Works with text, numbers (converted to text), and formulas
- Supports dynamic repetition counts
It is designed to be simple, flexible, and surprisingly powerful.
Syntax â–¾
REPT(text; number_times)
Arguments
-
text:
The text string to repeat. -
number_times:
The number of repetitions (must be ≥ 0).
Basic Examples â–¾
Repeat a character 5 times
=REPT("*"; 5)
Returns "*****".
Repeat a word
=REPT("Hi "; 3)
Returns "Hi Hi Hi ".
Repeat a number (converted to text)
=REPT(7; 4)
Returns "7777".
Repeat a space for padding
=REPT(" "; 10)
Advanced Examples â–¾
Create a simple bar chart
=REPT("â–ˆ"; A1)
Create a progress bar (0–100%)
=REPT("â–ˆ"; A1/10)
(Assumes A1 is 0–100.)
Create a fixed-width padded label
=CONCAT(A1; REPT(" "; 20 - LEN(A1)))
Create a left-padded number
=CONCAT(REPT("0"; 5 - LEN(A1)); A1)
Create a rating indicator
=CONCAT(REPT("★"; A1); REPT("☆"; 5 - A1))
Create a visual heat bar
=REPT("â–“"; ROUND(A1 * 10))
Create a dotted leader for tables
=CONCAT(A1; REPT(". "; 30 - LEN(A1)); B1)
Create indentation
=CONCAT(REPT(" "; B1); A1)
Create a histogram row
=REPT("|"; A1)
Create a bullet list with indentation
=CONCAT(REPT(" "; B1 * 2); "• "; A1)
Create a dynamic underline
=REPT("─"; LEN(A1))
Create a masked string
=REPT("*"; LEN(A1))
Edge Cases and Behavior Details â–¾
number_times < 0 → Err:502
=REPT("A"; -1)
number_times = 0 → returns empty string
=REPT("A"; 0) → ""
number_times is fractional → truncated
=REPT("A"; 3.9) → "AAA"
text is empty → returns empty string
=REPT(""); 10 → ""
text is a number → converted to text
=REPT(5; 3) → "555"
REPT of an error propagates the error
=REPT(#N/A; 3) → #N/A
Maximum output length
LibreOffice limits cell text length (~1M characters).
REPT may return Err:512 if exceeded.
REPT does not trim or clean text
Use TRIM or CLEAN if needed.
Common Errors and Fixes â–¾
Err:502 — Invalid argument
Occurs when:
- number_times < 0
- number_times is non-numeric
- text is missing
REPT returns too many characters
Cause:
- number_times too large
- Unexpected LEN(text)
REPT returns nothing
Cause:
- number_times = 0
- text = ""
Best Practices â–¾
- Use REPT for padding, alignment, and fixed-width formatting
- Use REPT for lightweight bar charts and indicators
- Combine with LEN for dynamic padding
- Combine with CONCAT/TEXTJOIN for structured output
- Use REPT with TRIM/CLEAN for clean visualization
- Use REPT for masking and obfuscation
Related Patterns and Alternatives â–¾
- Use CONCAT and TEXTJOIN for assembly
- Use LEFT, RIGHT, MID for extraction
- Use SUBSTITUTE and REPLACE for editing
- Use LEN for dynamic repetition logic
- Use TRIM and CLEAN for normalization
By mastering REPT and its companion functions, you can build expressive, structured, and visually rich text‑based workflows in LibreOffice Calc.