Japanese Era & Color Formats
Japanese era dates (令和/平成/昭和) and bracket color formats ([赤]/[Red]) for business documents — P&L statement demo with red-negative display.
How it works
This demo covers two Japan-specific number format features: Japanese era calendar dates (和暦) and bracket color codes ([Red]/[赤]) for positive/negative display in accounting documents.
- Era date formats convert a JavaScript Date or year number to 令和N年M月D日 automatically — supported eras: 令和, 平成, 昭和
- Bracket color formats change the text color based on the sign of the value: [赤] or [Red] makes negative numbers red, [青] or [Blue] makes them blue
- The P&L statement section shows ▲ negative display: format code [赤]▲#,##0;#,##0 gives red negatives with a triangle prefix common in Japanese accounting
- Positive/negative format codes are separated by semicolons: positiveFormat;negativeFormat
- All era calculations run client-side with no external library
Key APIs used
ws.setCellNumberFormat(row, col, formatCode) Apply a Japanese era format code (e.g. 'ggge年m月d日') or bracket color code (e.g. '[赤]▲#,##0;#,##0') to a cell
ws.cell(row, col).setValue(value) Set the raw numeric or Date value that the era/color format code will be applied to
ws.range(ref).merge() Merge section title cells across columns for the demo layout
Source Code
Related Documentation
Related Demos
Cell Types Dashboard
Progress bars, star ratings, sparkline charts, checkboxes, and hyperlinks — all rendered inside spreadsheet cells.
Data Filter & Sort
Click column header dropdowns to filter and sort rows. Switch between 300, 1K, and 10K rows to test performance.
Cell Styles
Font styles, colors, backgrounds, text alignment, and border options — a showcase of the Cell Style API.