Formatting values
A text component can carry a format that is applied to every {{ }} value in it:
{ "id": "total", "type": "text", "text": "{{ row.total }}", "format": { "type": "currency", "currency": "EUR", "decimals": 2 } }| Format | Options |
|---|---|
number |
decimals, thousandsSeparator, prefix, suffix |
currency |
currency (ISO 4217 code such as USD), decimals |
percent |
decimals. The value is a ratio: 0.25 becomes 25% |
date |
pattern, calendar |
Values that cannot be converted (for example text with a number format) are shown as they are.
Locale
Section titled “Locale”Formatting follows the report’s locale: the template’s locale (a BCP 47 tag such as de-DE or fa-IR, default en-US), or the locale prop of the viewer, which wins. It controls separators, currency symbols, month and weekday names, and digits: with fa-IR numbers and dates use Persian digits.
<ReportViewer template={template} data={data} locale="de-DE" />The same locale is used by formatNumber, formatCurrency, formatPercent and formatDate in expressions.
Date patterns
Section titled “Date patterns”Patterns support yyyy yy MMMM MMM MM M dd d EEEE EEE HH H hh h mm m ss s SSS a and 'quoted text'. Date-only strings such as "2026-03-01" are read as local midnight, so they never shift by a day.
{{ row.date }} with dd/MM/yyyy HH:mm → 01/03/2026 14:30{{ formatDate(today(), 'EEEE d MMMM yyyy') }} → Tuesday 13 October 2026Calendars
Section titled “Calendars”Dates are Gregorian unless you choose a calendar: gregory, persian, islamic, islamic-umalqura, hebrew, buddhist, japanese or roc. The Persian (Jalali) calendar is the one used in Iran and Afghanistan:
{ "type": "date", "pattern": "yyyy/MM/dd", "calendar": "persian" }In expressions, pass the calendar as the third argument:
{{ formatDate(row.date, 'd MMMM yyyy', 'persian') }}With fa-IR the first example gives ۱۴۰۵/۰۷/۲۱ for 13 October 2026. Excel cannot show other calendars in a date cell, so these dates are exported as text exactly as the report shows them.
Try it
Section titled “Try it”This Persian report uses the fa-IR locale for digits and the Persian calendar for dates:
import { useEffect, useState } from 'react';import { createFontMeasurer, type FontRegistration, type TextMeasurer } from '@ariana-reports/core';import { ReportViewer } from '@ariana-reports/react';import { persianData, persianTemplate } from './report-data';import { loadPersianFonts } from './fonts';
export default function ViewerPersian() { // The PDF needs the font files: register them in `pdf.fonts`, and measure text with them so line breaks match. const [fonts, setFonts] = useState<{ fonts: FontRegistration[]; measurer: TextMeasurer }>(); useEffect(() => { loadPersianFonts().then(async (fonts) => setFonts({ fonts, measurer: await createFontMeasurer(fonts) })); }, []); if (!fonts) return null; return <ReportViewer template={persianTemplate} data={persianData} zoomMode="fitWidth" uiLocale="fa" measurer={fonts.measurer} pdf={{ fonts: fonts.fonts }} />;}<script setup lang="ts">import { onMounted, shallowRef } from 'vue';import { createFontMeasurer, type FontRegistration, type TextMeasurer } from '@ariana-reports/core';import { ReportViewer } from '@ariana-reports/vue';import { persianData, persianTemplate } from './report-data';import { loadPersianFonts } from './fonts';
// The PDF needs the font files: register them in `pdf.fonts`, and measure text with them so line breaks match.const fonts = shallowRef<{ fonts: FontRegistration[]; measurer: TextMeasurer }>();onMounted(async () => { const files = await loadPersianFonts(); fonts.value = { fonts: files, measurer: await createFontMeasurer(files) };});</script>
<template> <ReportViewer v-if="fonts" :template="persianTemplate" :data="persianData" zoom-mode="fitWidth" ui-locale="fa" :measurer="fonts.measurer" :pdf="{ fonts: fonts.fonts }" /></template>{ "schemaVersion": 1, "name": "گزارش فروش", "unit": "mm", "locale": "fa-IR", "page": { "size": "A4", "orientation": "portrait", "margins": { "top": 12, "right": 12, "bottom": 12, "left": 12 } }, "dataSources": [ { "name": "sales" } ], "styles": { "title": { "fontFamily": "Vazirmatn", "fontSize": 18, "fontWeight": "bold", "textAlign": "right" }, "th": { "fontFamily": "Vazirmatn", "fontSize": 9, "fontWeight": "bold", "color": "#fff", "backgroundColor": "#334155", "padding": 1.5, "textAlign": "right" }, "td": { "fontFamily": "Vazirmatn", "fontSize": 9.5, "padding": 1.5, "textAlign": "right", "border": { "width": 0.4, "color": "#e2e8f0", "style": "solid", "sides": [ "bottom" ] } }, "sub": { "fontFamily": "Vazirmatn", "fontSize": 10, "fontWeight": "bold", "backgroundColor": "#e2e8f0", "padding": 1.5, "textAlign": "right" } }, "reportHeader": { "id": "rh", "height": 18, "components": [ { "id": "title", "type": "text", "x": 0, "y": 0, "width": 186, "height": 10, "text": "گزارش فروش", "styleName": "title" }, { "id": "sub", "type": "text", "x": 0, "y": 11, "width": 186, "height": 5, "text": "{{ count(sales) }} سفارش · تاریخ گزارش: {{ formatDate(today(), \"d MMMM yyyy\", \"persian\") }}", "style": { "fontFamily": "Vazirmatn", "fontSize": 9.5, "color": "#64748b", "textAlign": "right" } } ] }, "body": [ { "kind": "dataRegion", "id": "list", "dataSource": "sales", "header": { "id": "head", "height": 7, "components": [ { "id": "h1", "type": "text", "x": 0, "y": 0, "width": 40, "height": 7, "text": "تاریخ", "styleName": "th" }, { "id": "h2", "type": "text", "x": 40, "y": 0, "width": 40, "height": 7, "text": "قیمت واحد", "styleName": "th" }, { "id": "h3", "type": "text", "x": 80, "y": 0, "width": 20, "height": 7, "text": "تعداد", "styleName": "th" }, { "id": "h4", "type": "text", "x": 100, "y": 0, "width": 36, "height": 7, "text": "کالا", "styleName": "th" }, { "id": "h5", "type": "text", "x": 136, "y": 0, "width": 50, "height": 7, "text": "مشتری", "styleName": "th" } ] }, "detail": { "id": "row", "height": 7, "components": [ { "id": "c1", "type": "text", "x": 0, "y": 0, "width": 40, "height": 7, "text": "{{ row.date }}", "styleName": "td", "format": { "type": "date", "pattern": "yyyy/MM/dd", "calendar": "persian" } }, { "id": "c2", "type": "text", "x": 40, "y": 0, "width": 40, "height": 7, "text": "{{ row.price }}", "styleName": "td", "format": { "type": "number", "decimals": 0, "thousandsSeparator": true } }, { "id": "c3", "type": "text", "x": 80, "y": 0, "width": 20, "height": 7, "text": "{{ row.qty }}", "styleName": "td" }, { "id": "c4", "type": "text", "x": 100, "y": 0, "width": 36, "height": 7, "text": "{{ row.product }}", "styleName": "td" }, { "id": "c5", "type": "text", "x": 136, "y": 0, "width": 50, "height": 7, "text": "{{ row.customer }}", "styleName": "td" } ] }, "footer": { "id": "foot", "height": 10, "components": [ { "id": "f1", "type": "text", "x": 0, "y": 2, "width": 80, "height": 7, "text": "{{ sum(rows, r => r.qty * r.price) }}", "styleName": "sub", "format": { "type": "number", "decimals": 0, "thousandsSeparator": true } }, { "id": "f2", "type": "text", "x": 80, "y": 2, "width": 106, "height": 7, "text": "جمع کل (ریال)", "styleName": "sub" } ] } } ]}{ "sales": [ { "customer": "شرکت آریا", "product": "لپتاپ", "qty": 12, "price": 485000000, "date": "2026-03-21" }, { "customer": "فروشگاه پارس", "product": "مانیتور", "qty": 30, "price": 128500000, "date": "2026-03-23" }, { "customer": "شرکت آریا", "product": "کیبورد", "qty": 40, "price": 9800000, "date": "2026-03-25" }, { "customer": "دانشگستر", "product": "هدست", "qty": 25, "price": 17400000, "date": "2026-04-01" }, { "customer": "فروشگاه پارس", "product": "وبکم", "qty": 18, "price": 12300000, "date": "2026-04-03" } ]}