How to personalize document generation using expressions
Docu Merge supports expressions which will help you customize and generate dynamic documents from the Template.
The syntax for the expression is of the form {{ <some value> }}
.
It supports two types of expressions, namely static expression and dynamic expression.
Static Expression
The static expressions are predefined expressions available to each Google Sheet. List of supported static expressions and their meaning is given below.
List of Supported Static Expressions And their meaning:
{{ Unique Id }}
: This expression generates a new unique id (UUID) ,every time it is used.{{ DATE }}
: Generates a date in the formatMM-dd-yyyy
. Example :11-13-2023{{ DATE UK }}
: Generates a date in the formatdd-MM-yyyy
. Example :23-11-2023{{ DATE JP }}
: Generates a date in the formatyyyy-MM-dd
. Example :2023-11-23{{ FULL DATE }}
: Generates a date in the formatMMMM d, yyyy hh:mm:ss a
. Example: December 5, 2023 02:08:55 PM{{ DATE PATTERN }}
: This can be used to generate any pattern you want .Please check section Custom Date Patterns.{{ Time }}
: Generates current time time in the formathh:mm a
.Example: 2:08 PM{{ Year }}
: Generates Current Year in the formatyyyy
.Example: 2024{{ Spreadsheet Name }}
: Generates the Current Spreadsheet Name .{{ Spreadsheet Id }}
: Generates the Current Spreadsheet Id .{{ Sheet Name }}
: Generates the Active Sheet Name in the Active Spreadsheet .{{ Sheet Id }}
: Generates the Active Sheet Id in the Active Spreadsheet .
Dealing with Time zones
All the Date and Time expressions use the Time zone of the Google Sheet . By default, Google Sheets uses the time zone setting of your Google account.
Change Google sheet Time zone
To change the default timezone of your Google Sheet, follow these steps:
- Open your Google Sheet from Google Drive.
- Go to the File menu and select Settings.
- In the Time zone section, choose your preferred timezone.
- Click Save to apply the changes.
Supported Custom Date Patterns
Using this expression you can formulate Date in any pattern you want if the existing predefined patterns do not fullfill your requirement.
Syntax: {{ DATE PATTERN , <Custom Pattern Goes Here> }}
Pattern Letters and their Meaning
Letter | Date or Time Component | Example Output |
---|---|---|
G | Era designator | AD |
y | Year | 1996; 96 |
Y | Week year | 2009; 09 |
M | Month in year (context-sensitive) | July; Jul; 07 |
L | Month in year (standalone form) | July; Jul; 07 |
w | Week in year | 27 |
W | Week in month | 2 |
D | Day in year | 189 |
d | Day in month | 10 |
F | Day of week in month | 2 |
E | Day name in week | Tuesday; Tue |
u | Day number of week | 1 (1 = Monday, ..., 7 = Sunday) |
a | Am/pm marker | PM |
H | Hour in day (0-23) | 0 |
k | Hour in day (1-24) | 24 |
K | Hour in am/pm (0-11) | 0 |
h | Hour in am/pm (1-12) | 12 |
m | Minute in hour | 30 |
s | Second in minute | 55 |
S | Millisecond | 978 |
z | Time zone (General time zone) | Pacific Standard Time; PST; GMT-08:00 |
Z | Time zone (RFC 822) | -0800 |
X | Time zone (ISO 8601) | -08; -0800; -08:00 |
Pattern Letters in the above table can be combined to generate various date patterns .See some examples below on how they can be used.
Examples:
Example Output | Pattern |
---|---|
Tuesday, 5 December 2023 AD | EEEE, d MMMM yyyy G |
2023-12-05 14:08:55 | yyyy-MM-dd HH:mm:ss |
12/5/23, 2:08 PM | MM/dd/yy, h:mm a |
December 5, 2023, 02:08:55 PM | MMMM d, yyyy, hh:mm:ss a |
05-Dec-2023 14:08 | dd-MMM-yyyy HH:mm |
Tue, 5 Dec 23 | EEE, d MMM yy |
2023 W49 D2 | YYYY 'W'ww 'D'd |
14:08:55 PST | HH:mm:ss z |
2:08 PM Pacific Standard Time | h:mm a zzzz |
2023-12-05T14:08:55-08:00 | yyyy-MM-dd'T'HH:mm:ssXXX |
12/05/2023 14:08:55 GMT-08:00 | MM/dd/yyyy HH:mm:ss Z |
2023-339 (Day of the Year) | yyyy-DDD |
5th day of December, 2023 | d'th day of' MMMM, yyyy |
Hour 2 of the 24-hour day, Minute 8 | 'Hour' H 'of the 24-hour day, Minute' m |
Tuesday, 5th December, 2:08 PM AD | EEEE, d'th' MMMM, h:mm a G |
ISO DateTime: 2023-12-05T14:08:55.123Z | yyyy-MM-dd'T'HH:mm:ss.SSS'Z' |
Dynamic Expression
The firs row in your Google sheet must contain user friendly names in each cell that can be used as dynamic expression. All subsequent rows will be processed and for each row the corresponding value to the first cell will be used to replace the expression.