diff --git a/README.md b/README.md index c27c8cfda..f2647f74d 100644 --- a/README.md +++ b/README.md @@ -877,6 +877,11 @@ ws.getCell('A2').font = { italic: true }; +// for the vertical align +ws.getCell('A3').font = { + vertAlign: 'superscript' +}; + // note: the cell will store a reference to the font object assigned. // If the font object is changed afterwards, the cell font will change also... var font = { name: 'Arial', size: 12 }; @@ -899,6 +904,7 @@ font.size = 20; // Cell A3 now has font size 20! | underline | Font underline style | true, false, 'none', 'single', 'double', 'singleAccounting', 'doubleAccounting' | | strike | Font strikethrough | true, false | | outline | Font outline | true, false | +| vertAlign | Vertical align | 'superscript', 'subscript' ### Alignment diff --git a/index.d.ts b/index.d.ts index 3a28909c9..5e21195b5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -226,6 +226,7 @@ export interface Font { bold: boolean; italic: boolean; underline: boolean | 'none' | 'single' | 'double' | 'singleAccounting' | 'doubleAccounting'; + vertAlign: 'superscript' | 'subscript'; strike: boolean; outline: boolean; } diff --git a/lib/xlsx/xform/style/font-xform.js b/lib/xlsx/xform/style/font-xform.js index 46234fe77..55da9b847 100644 --- a/lib/xlsx/xform/style/font-xform.js +++ b/lib/xlsx/xform/style/font-xform.js @@ -30,6 +30,7 @@ var FontXform = module.exports = function(options) { extend: { prop: 'extend', xform: new BooleanXform({tag: 'extend', attr: 'val'}) }, family: { prop: 'family', xform: new IntegerXform({tag: 'family', attr: 'val'}) }, outline: { prop: 'outline', xform: new BooleanXform({tag: 'outline', attr: 'val'}) }, + vertAlign: { prop: 'vertAlign', xform: new StringXform({ tag: 'vertAlign', attr: 'val' }) }, scheme: { prop: 'scheme', xform: new StringXform({tag: 'scheme', attr: 'val'}) }, shadow: { prop: 'shadow', xform: new BooleanXform({tag: 'shadow', attr: 'val'}) }, strike: { prop: 'strike', xform: new BooleanXform({tag: 'strike', attr: 'val'}) }, diff --git a/spec/unit/xlsx/xform/style/vertical-aligment-xform.spec.js b/spec/unit/xlsx/xform/style/vertical-aligment-xform.spec.js new file mode 100644 index 000000000..ff17ad9b9 --- /dev/null +++ b/spec/unit/xlsx/xform/style/vertical-aligment-xform.spec.js @@ -0,0 +1,23 @@ +'use strict'; + +var StringXform = require('../../../../../lib/xlsx/xform/simple/string-xform'); +var testXformHelper = require('./../test-xform-helper'); + +var expectations = [ + { + title: 'superscript', + create: function() { return new StringXform({ tag: 'vertAlign', attr: 'val' }); }, + preparedModel: 'superscript', + xml: '', + parsedModel: 'superscript', + tests: ['render', 'renderIn', 'parse'] + }, + { + title: 'subscript', + create: function() { return new StringXform({ tag: 'vertAlign', attr: 'val' }); }, + preparedModel: 'subscript ', + xml: '', + parsedModel: 'subscript', + tests: ['render', 'renderIn', 'parse'] + } +];