Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -899,6 +904,7 @@ font.size = 20; // Cell A3 now has font size 20!
| underline | Font <u>underline</u> style | true, false, 'none', 'single', 'double', 'singleAccounting', 'doubleAccounting' |
| strike | Font <strike>strikethrough</strike> | true, false |
| outline | Font outline | true, false |
| vertAlign | Vertical align | 'superscript', 'subscript'

### Alignment

Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions lib/xlsx/xform/style/font-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}) },
Expand Down
23 changes: 23 additions & 0 deletions spec/unit/xlsx/xform/style/vertical-aligment-xform.spec.js
Original file line number Diff line number Diff line change
@@ -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: '<vertAlign val="superscript"/>',
parsedModel: 'superscript',
tests: ['render', 'renderIn', 'parse']
},
{
title: 'subscript',
create: function() { return new StringXform({ tag: 'vertAlign', attr: 'val' }); },
preparedModel: 'subscript ',
xml: '<vertAlign val="subscript"/>',
parsedModel: 'subscript',
tests: ['render', 'renderIn', 'parse']
}
];