From ed0cd9b2c1b2edbe46b6766c91e2c9f6fda1bbd7 Mon Sep 17 00:00:00 2001 From: Pieter Sheth-Voss Date: Thu, 21 May 2015 15:52:24 -0400 Subject: [PATCH] Add alignment; update README --- README.md | 5 +++++ bits/92_stylebuilder.js | 1 + example.js | 3 ++- xlsx.js | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03245fc..e5c862e 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,9 @@ is available. To change a value, be sure to delete `cell.w` (or set it to `undefined`) before attempting to export. The utilities will regenerate the `w` text from the number format (`cell.z`) and the raw value if possible. +**Note**: The .z attribute is now deprecated. Use the `.s` attribute to specify cell styles including number formats. +To specify a number format, use `s.numFmt`, e.g. `{v: 42145.822, s: { numFmt: "m/dd/yy"}}` described below. + ### Data Types The raw value is stored in the `v` field, interpreted based on the `t` field. @@ -511,9 +514,11 @@ top-level attributes: `fill`, `font`, `numFmt`, `alignment`, and `border`. | | | `"0.00%"` // string matching a built-in format, see StyleBuilder.SSF | | | `"0.0%"` // string specifying a custom format | | | `"0.00%;\\(0.00%\\);\\-;@"` // string specifying a custom format, escaping special characters +| | | `"m/dd/yy"` // string a date format using Excel's format notation | alignment | vertical | `"bottom"||"center"||"top"` | | horizontal | `"bottom"||"center"||"top"` | | wrapText | `true || false` +| | readingOrder | `2` // for right-to-left | | textRotation | Number from `0` to `180` or `255` (default is `0`) | | | `90` is rotated up 90 degrees | | | `45` is rotated up 45 degrees diff --git a/bits/92_stylebuilder.js b/bits/92_stylebuilder.js index 7d0de23..51a77a9 100644 --- a/bits/92_stylebuilder.js +++ b/bits/92_stylebuilder.js @@ -191,6 +191,7 @@ if (attributes.alignment.horizontal) { $alignment.attr('horizontal', attributes.alignment.horizontal);} if (attributes.alignment.vertical) { $alignment.attr('vertical', attributes.alignment.vertical);} if (attributes.alignment.indent) { $alignment.attr('indent', attributes.alignment.indent);} + if (attributes.alignment.readingOrder) { $alignment.attr('readingOrder', attributes.alignment.readingOrder);} if (attributes.alignment.wrapText) { $alignment.attr('wrapText', attributes.alignment.wrapText);} if (attributes.alignment.textRotation!=undefined) { $alignment.attr('textRotation', attributes.alignment.textRotation);} diff --git a/example.js b/example.js index 5318605..f0b068b 100644 --- a/example.js +++ b/example.js @@ -137,7 +137,8 @@ var workbook = new Workbook(XLSX) {v: "Vertical", s: {alignment: {textRotation: 255}}} ], [ - {v: "Font color test", s: { font: {fgColor: {rgb: "FFC6EFCE"}}}} + {v: "Font color test", s: { font: {fgColor: {rgb: "FFC6EFCE"}}}}, + {v: "right to left", s: {alignment: {readingOrder: 2}}} ] ]).mergeCells("Main", { "s": {"c": 0, "r": 0 }, diff --git a/xlsx.js b/xlsx.js index cc56ea6..1ef424a 100644 --- a/xlsx.js +++ b/xlsx.js @@ -12197,6 +12197,7 @@ var XmlNode = (function () { if (attributes.alignment.horizontal) { $alignment.attr('horizontal', attributes.alignment.horizontal);} if (attributes.alignment.vertical) { $alignment.attr('vertical', attributes.alignment.vertical);} if (attributes.alignment.indent) { $alignment.attr('indent', attributes.alignment.indent);} + if (attributes.alignment.readingOrder) { $alignment.attr('readingOrder', attributes.alignment.readingOrder);} if (attributes.alignment.wrapText) { $alignment.attr('wrapText', attributes.alignment.wrapText);} if (attributes.alignment.textRotation!=undefined) { $alignment.attr('textRotation', attributes.alignment.textRotation);}