Text Rotation & Vertical Text
Since v1.6.0 cell text can be turned through Excel’s -90..90 degrees, or set to Japanese vertical writing (縦書き). Available in both editions.
The two are one control, exactly as in Excel’s alignment dialog: setting an angle turns vertical writing off, and turning vertical writing on clears the angle.
Rotating text
const ws = grid.worksheet
// Positive degrees read up to the right; negative read down to the right
ws.range('B1:F1').setTextRotation(45)
// 90° — a label turned on its side
ws.range('B1:F1').setTextRotation(90)
// Back to horizontal
ws.range('B1:F1').setTextRotation(0)
Values outside -90..90 are clamped, matching Excel’s own range.
This is the layout that makes a wide table of narrow numeric columns readable: the headers are long words, the data is four digits, and turning the headers 45° lets the columns stay narrow.
Vertical writing (縦書き)
ws.range('A1:A6').setVerticalText() // on
ws.range('A1:A6').setVerticalText(false) // off
Characters are stacked one per line from the top, and columns run right to left. Long vowel marks and brackets are turned to their vertical forms, and 、 / 。 sit at the top-right of the character box, as vertical Japanese typesetting requires.
This is what form labels like 年度 or 第一四半期 need when the column is one character wide.
Auto-fit measures the rotated outline
Width and height auto-fit measure the text after rotation, not before. A label turned 90° therefore gets a column only as wide as the row is tall — rather than a column wide enough for the horizontal text, which would defeat the purpose.
Wrapping applies in the direction the text actually runs.
Everywhere at once
Screen, xlsx, browser print and PDF export all produce the same placement. The style round-trips through Excel as <alignment textRotation> — vertical writing is Excel’s value 255.
| Target | Rotation | Vertical |
|---|---|---|
| Canvas (screen) | ✓ | ✓ |
| xlsx export / import | ✓ | ✓ (textRotation="255") |
| Browser print | ✓ | ✓ |
| PDF export | ✓ | ✓ |
Limits
- The cell editor does not rotate while you are typing. The text is drawn at its angle once the edit is committed.
- Rich text follows the angle, but falls back to horizontal under vertical writing.
Related
- Text rotation demo — slanted headers, 縦書き, and the full -90..90 range, live.
- Cell Styles — alignment, wrapping and the rest of the style model.
- Row & Column — auto-fit, which measures the rotated outline.
- PDF Export / Print to HTML — the same placement on paper.
Sorry to hear that. What could be improved?