Add support for textRotation

This commit is contained in:
Pieter Sheth-Voss 2015-03-12 09:52:30 -04:00
parent c3af249415
commit aa8f3a759f
4 changed files with 20 additions and 10 deletions

@ -449,20 +449,27 @@ top-level attributes: `fill`, `font`, `numFmt`, `alignment`, and `border`.
| | | "0.00%;\\(0.00%\\);\\-;@" // string specifying a custom format, escaping special characters
| alignment | vertical | "bottom"||"center"||"top"
| | horizontal | "bottom"||"center"||"top"
| | textRotation | Number from 0 to 180 or 255 (default is 0)
| | | "90" is rotated up 90 degrees
| | | "45" is rotated up 45 degrees
| | | "135" is rotated down 45 degrees
| | | "180" is rotated down 180 degrees
| | | "255" is special, aligned vertically
| border | top | { style: BORDER_STYLE, color: COLOR_SPEC }
| | bottom | { style: BORDER_STYLE, color: COLOR_SPEC }
| | left | { style: BORDER_STYLE, color: COLOR_SPEC }
| | right | { style: BORDER_STYLE, color: COLOR_SPEC }
| | diagonal | { style: BORDER_STYLE, color: COLOR_SPEC }
| | diagonalUp | true||false
| | diagonalDown | true||false
| | left | { style: BORDER_STYLE, color: COLOR_SPEC }
| | right | { style: BORDER_STYLE, color: COLOR_SPEC }
| | diagonal | { style: BORDER_STYLE, color: COLOR_SPEC }
| | diagonalUp | true||false
| | diagonalDown | true||false
**COLOR_SPEC** Colors for `fill`, `font`, and `border` are specified as objects, either:
* `{ auto: 1}` specifying automatic values
* `{ rgb: "FFFFAA00" }` specifying a hex ARGB value
* `{ theme: "1", tint: "-0.25"}` specifying an integer index to a theme color and a tint value (default 0)
* `{indexed: 64}` default value for `fill.bgColor`
* `{ indexed: 64}` default value for `fill.bgColor`
** BORDER_STYLE** are piped directly to XML and may take on one of the following values:
* `thin`

@ -192,10 +192,11 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (attributes.alignment.vertical) { $alignment.attr('vertical', attributes.alignment.vertical);}
if (attributes.alignment.indent) { $alignment.attr('indent', attributes.alignment.indent);}
if (attributes.alignment.wrapText) { $alignment.attr('wrapText', attributes.alignment.wrapText);}
if (attributes.alignment.textRotation) { $alignment.attr('textRotation', attributes.alignment.textRotation);}
$xf.append($alignment).attr('applyAlignment',1)
}
this.$cellXfs.append($xf);
var count = +this.$cellXfs.children().length;

@ -57,6 +57,8 @@ var paths = {
var N1 = 'XLSX';
var N2 = 'XLSB';
function parsetest(x, wb, full, ext) {
ext = (ext ? " [" + ext + "]": "");
if(!full && ext) return;
@ -111,7 +113,7 @@ function parsetest(x, wb, full, ext) {
var csv = fixcsv(X.utils.make_csv(wb.Sheets[ws]));
var result = (file == csv);
if (!result) { // try again parsing the file ourselves
// somehow these workbooks are getting here having been parsed without {cellNF: true}
// somehow these workbooks are getting here having been parsec without {cellNF: true}
// so re-read them with {cellNF:true} and all works just great.
// THus these CSV tests seem to fail due to issue with test framework rather than XLSX itself
var wb1 = X.readFile(wb.FILENAME, {cellStyles:true, cellNF:true});
@ -167,7 +169,6 @@ describe('should parse test files', function() {
var wb = wbtable[dir + x];
if(!wb) wb = X.readFile(dir + x, opts);
var FILENAME = wb.FILENAME;
console.error(JSON.stringify(opts))
wb = X.read(X.write(wb, {type:"buffer", bookType:ext.replace(/\./,"")}), {WTF:opts.WTF, cellNF: true})
wb.FILENAME = FILENAME;

@ -5693,10 +5693,11 @@ if ((typeof 'module' != 'undefined' && typeof require != 'undefined') || (typeo
if (attributes.alignment.vertical) { $alignment.attr('vertical', attributes.alignment.vertical);}
if (attributes.alignment.indent) { $alignment.attr('indent', attributes.alignment.indent);}
if (attributes.alignment.wrapText) { $alignment.attr('wrapText', attributes.alignment.wrapText);}
if (attributes.alignment.textRotation) { $alignment.attr('textRotation', attributes.alignment.textRotation);}
$xf.append($alignment).attr('applyAlignment',1)
}
this.$cellXfs.append($xf);
var count = +this.$cellXfs.children().length;