From 11c9f41a9b778958554119d871c25e526c5bee50 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Sun, 27 Dec 2020 22:29:26 +0300 Subject: [PATCH 01/12] Running tests on Windows using node --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c30f2547..5a4d2cd7 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ "url": "https://github.com/natergj/excel4node/labels/bug" }, "scripts": { - "test": "NODE_ENV=test ./node_modules/tape/bin/tape -r babel-register ./tests/*.test.js", - "cover": "NODE_ENV=test nyc tape -r babel-register ./tests/*.test.js", - "build": "./node_modules/babel-cli/bin/babel.js source --presets babel-preset-env -s --out-dir distribution", - "watch": "./node_modules/babel-cli/bin/babel.js source -w --presets babel-preset-env -s --out-dir distribution", + "test": "node .\\node_modules\\tape\\bin\\tape -r babel-register .\\tests\\*.test.js", + "cover": "node nyc tape -r babel-register .\\tests/*.test.js", + "build": "node ./node_modules/babel-cli/bin/babel.js source --presets babel-preset-env -s --out-dir distribution", + "watch": "node ./node_modules/babel-cli/bin/babel.js source -w --presets babel-preset-env -s --out-dir distribution", "document": "jsdoc ./source -r -d docs", "prepublish": "npm run build; npm run test" }, From 445ca794c4d3f38e02b826ef988d0be559d30390 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 28 Dec 2020 04:03:45 +0300 Subject: [PATCH 02/12] Added header footer images to the excel file generation process --- .gitignore | 4 +- package.json | 1 + sample2.js | 68 ++++++++++ sampleFiles/logo copy.png | Bin 0 -> 3988 bytes sampleFiles/signatures2.png | Bin 0 -> 30659 bytes source/lib/drawing/headerFooterPicture.js | 143 ++++++++++++++++++++++ source/lib/drawing/index.js | 8 +- source/lib/workbook/builder.js | 125 +++++++++++++++++-- source/lib/worksheet/builder.js | 18 ++- source/lib/worksheet/worksheet.js | 24 ++++ 10 files changed, 379 insertions(+), 12 deletions(-) create mode 100644 sample2.js create mode 100644 sampleFiles/logo copy.png create mode 100644 sampleFiles/signatures2.png create mode 100644 source/lib/drawing/headerFooterPicture.js diff --git a/.gitignore b/.gitignore index a366b4fb..b8bebee8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,6 @@ tmp references coverage .nyc_output -package-lock.json \ No newline at end of file +package-lock.json +testzip +testzip/* \ No newline at end of file diff --git a/package.json b/package.json index 5a4d2cd7..be9c5021 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "source-map-support": "0.5.11", "tape": "4.10.1", "tape-promise": "2.0.1", + "unzipper": "0.10.11", "xmldom": "0.1.27", "xpath.js": "1.1.0" }, diff --git a/sample2.js b/sample2.js new file mode 100644 index 00000000..5da98bda --- /dev/null +++ b/sample2.js @@ -0,0 +1,68 @@ +const fs = require('fs'); +const path = require('path'); +const unzipper = require('unzipper') + +require('source-map-support').install(); +var xl = require('./distribution'); + +var wb = new xl.Workbook({ + defaultFont: { + name: 'Verdana', + size: 12 + }, + dateFormat: 'mm/dd/yyyy hh:mm:ss', + logLevel: 1, + workbookView: { + windowWidth: 28800, + windowHeight: 17620, + xWindow: 240, + yWindow: 480, + }, + author: 'Mohanad Ahmed' +}); + +var ws = wb.addWorksheet("Sheet1", { + pageSetup: { + fitToWidth: 1, + paperSize: 'A4_PAPER', + orientation: 'landscape' + }, + headerFooter: { + oddHeader: '&L&G &C&G &R&G', + oddFooter: '&L&G &C&G &R&G' + }, + printOptions: { centerHorizontal: true }, + sheetView: { rightToLeft: true } +}); + +ws.cell(1,1).string('Mohanad says hi'); + +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/logo copy.png')), + type: 'picture' +}, 'LF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/logo copy.png')), + type: 'picture' +}, 'CF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/signatures2.png')), + type: 'picture', + scale: 0.05 +}, 'RF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/signatures2.png')), + type: 'picture', + scale: 0.23 +}, 'CH') + +wb.write('Excel.xlsx', function (err, stats) { + if (err) { + console.log(err); + } else { + console.log('Excel.xlsx written and has the following stats'); + console.log(stats); + var dir = require('path').join(__dirname, '/testzip') + fs.createReadStream('Excel.xlsx').pipe(unzipper.Extract({ path: dir })); + } +}); diff --git a/sampleFiles/logo copy.png b/sampleFiles/logo copy.png new file mode 100644 index 0000000000000000000000000000000000000000..5f58bc450ec08b3bd10a4504e6dc6b4b04322df3 GIT binary patch literal 3988 zcmZWrcQo8vwEoQ~(TNr*WQfj~(V~RWYmm_mBiiVF5G91@U6e%B=tK}qgb>kdh9o4> zTXdpC@1Eq|ckg}cowZKcdw<{l&fb5Vb)t}3DwJf`$N&JKR8v*dx!9vGrUD7^@6|ku z>0%?amD7|1fU0=^W9{S%8)BuZqX_^JQ~(f53xGg+01(Uv009U9*mw;9lB)nfpGtCL zunPdl>g^R2kZKAF5G2;s#@@*q093omQ@!u!ES7KoAI&-B0oYjSjCUuc*ZOEvohZr9915-Dr@Asj5^DOKhk~({ zgCqlk!SrLPTZyC2wIfaw(xZ~nDTqy4w{iHZlQFlZ3x&UjoYz_x#4u*(hKcipZCnXQ z?>_N1c=7Bi#KPrA^fb{z<-*pYxYFE}cg-4)ZO6elru!gre)SknGjrm=U-#pmuv9gl z;NfZkE=SR_YNzb=p~-}kGvt~0U%4X~DrGL%rAxaQ)5Ezg%fB-KIgps}xMP?bbl z)&~*%-$@hS-=qQQ1d+Ib$k{;%Rl+m~GYN>&2Sh~!ux!PFp6t?ameci9&7}31d|Is3 z4Hfa8qv!atgf2=W?dxqFU9YRB0gds%7-S$ad984H1(pp^z+yo4_lFk|Kzw68yHAv<~DtO&y%5X4&Gb9t1QL9PQSp+_Vt+a#a$*>{OdgkmB> zIfrx!x3?!+;ORP2Ui|IZ2e-@@-SFjuJs_7UJ4wdB7nR z2Il6WXDEykQX0vZ(rzgc*At3P7>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 00000000..3824a244 --- /dev/null +++ b/source/lib/drawing/headerFooterPicture.js @@ -0,0 +1,143 @@ +const Drawing = require('./drawing.js'); +const path = require('path'); +const imgsz = require('image-size'); +const mime = require('mime'); +const uniqueId = require('lodash.uniqueid'); + +const EMU = require('../classes/emu.js'); +const xmlbuilder = require('xmlbuilder'); + +class headerFooterPicture extends Drawing { + /** + * Element representing an Excel Picture subclass of Drawing + * @property {String} kind Kind of picture (currently only image is supported) + * @property {String} type ooxml schema + * @property {String} imagePath Filesystem path to image + * @property {Buffer} image Buffer with image + * @property {String} contentType Mime type of image + * @property {String} description Description of image + * @property {String} title Title of image + * @property {String} id ID of image + * @property {String} noGrp pickLocks property + * @property {String} noSelect pickLocks property + * @property {String} noRot pickLocks property + * @property {String} noChangeAspect pickLocks property + * @property {String} noMove pickLocks property + * @property {String} noResize pickLocks property + * @property {String} noEditPoints pickLocks property + * @property {String} noAdjustHandles pickLocks property + * @property {String} noChangeArrowheads pickLocks property + * @property {String} noChangeShapeType pickLocks property + * @returns {Picture} Excel Picture pickLocks property + */ + constructor(opts) { + super(); + this.kind = 'image'; + this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'; + this.imagePath = opts.path; + this.image = opts.image; + + this._name = this.image ? + opts.name || uniqueId('image-') : + opts.name || path.basename(this.imagePath); + + const size = imgsz(this.imagePath || this.image); + + this._pxWidth = size.width; + this._pxHeight = size.height; + + this._extension = this.image ? + size.type : + path.extname(this.imagePath).substr(1); + + this.contentType = mime.getType(this._extension); + this.scale = opts.scale; + + this._descr = null; + this._title = null; + this._id; + // picLocks §20.1.2.2.31 picLocks (Picture Locks) + this.noGrp; + this.noSelect; + this.noRot; + this.noChangeAspect = true; + this.noMove; + this.noResize; + this.noEditPoints; + this.noAdjustHandles; + this.noChangeArrowheads; + this.noChangeShapeType; + } + + get name() { + return this._name; + } + set name(newName) { + this._name = newName; + } + get id() { + return this._id; + } + set id(id) { + this._id = id; + } + + get rId() { + return 'rId' + this._id; + } + + get description() { + return this._descr !== null ? this._descr : this._name; + } + set description(desc) { + this._descr = desc; + } + + get title() { + return this._title !== null ? this._title : this._name; + } + set title(title) { + this._title = title; + } + + get extension() { + return this._extension; + } + + get width() { + let inWidth = this._pxWidth / 96; + let emu = new EMU(inWidth + 'in'); + return emu.value; + } + + get height() { + let inHeight = this._pxHeight / 96; + let emu = new EMU(inHeight + 'in'); + return emu.value; + } + + /** + * @alias Picture.addToXMLele + * @desc When generating Workbook output, attaches pictures to the drawings xml file + * @func Picture.addToXMLele + * @param {xmlbuilder.Element} xmlele Element object of the xmlbuilder module + */ + addToXMLele(xmlele) { + const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH']; + var ind = headerFooterPositions.indexOf(this.position); + + //Size calculations see: https://stackoverflow.com/a/14369133/14456373, http://lcorneliussen.de/raw/dashboards/ooxml/ + let _scale = 1.0; if(this.scale) _scale = this.scale; + let x_width = Math.round((this.width * _scale) / 12700); + let x_height = Math.round((this.height * _scale) / 12700); + + + var sh = xmlele.ele('v:shape'); + sh.att('id', this.position).att('o:spid', '_x0000_s' + 1025 + ind).att('type', '#_x0000_t75') + .att('style', `position:absolute;margin-left:0;margin-top:0;width:${x_width};height:${x_height};z-index:${ind+1}`); + sh.ele('v:imagedata').att('o:relid', this.rId).att('o:title', 'image' + this.id) + sh.ele('o:lock').att('v:ext', 'edit').att('rotation', 't'); + } +} + +module.exports = headerFooterPicture; \ No newline at end of file diff --git a/source/lib/drawing/index.js b/source/lib/drawing/index.js index e1a0c882..0b6a21fd 100644 --- a/source/lib/drawing/index.js +++ b/source/lib/drawing/index.js @@ -1,5 +1,6 @@ let Drawing = require('./drawing.js'); let Picture = require('./picture.js'); +let headerFooterPicture = require('./headerFooterPicture.js') class DrawingCollection { constructor() { @@ -16,7 +17,10 @@ class DrawingCollection { let newPic = new Picture(opts); this.drawings.push(newPic); return newPic; - + case 'headerFooterPicture': + let xPic = new headerFooterPicture(opts); + this.drawings.push(xPic ); + return xPic; default: throw new TypeError('this option is not yet supported'); } @@ -31,4 +35,4 @@ class DrawingCollection { } } -module.exports = { DrawingCollection, Drawing, Picture }; +module.exports = { DrawingCollection, Drawing, Picture, headerFooterPicture }; diff --git a/source/lib/workbook/builder.js b/source/lib/workbook/builder.js index 44508eda..e7fb00a9 100644 --- a/source/lib/workbook/builder.js +++ b/source/lib/workbook/builder.js @@ -37,24 +37,36 @@ let addRootContentTypesXML = (promiseObj) => { extensionsAdded.push('vml'); } } + + if(s.legacyDrawingHeaderFooter.length > 0){ + if (extensionsAdded.indexOf('vml') < 0) { + xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing'); + extensionsAdded.push('vml'); + } + if (extensionsAdded.indexOf('png') < 0){ + xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png'); + extensionsAdded.push('png'); + } + } }); - xml.ele('Default').att('ContentType', 'application/xml').att('Extension', 'xml'); - xml.ele('Default').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml').att('Extension', 'rels'); + xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml'); + xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml'); promiseObj.wb.sheets.forEach((s, i) => { xml.ele('Override') - .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml') - .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`); + .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`) + .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml') + if (s.drawingCollection.length > 0) { xml.ele('Override') - .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml') - .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml'); + .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') + .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml') } if (Object.keys(s.comments).length > 0) { xml.ele('Override') - .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml') - .att('PartName', '/xl/comments' + s.sheetId + '.xml'); + .att('PartName', '/xl/comments' + s.sheetId + '.xml') + .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml') } }); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml'); @@ -565,6 +577,102 @@ let addDrawingsXML = (promiseObj) => { }); }; +let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { + return new Promise((resolve) => { + console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML') + if (!promiseObj.wb.mediaCollection.isEmpty) { + + promiseObj.wb.sheets.forEach((ws) => { + + if (!ws.legacyDrawingHeaderFooter.isEmpty) { + + let drawingRelXML = xmlbuilder.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }) + .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + let drawingsVML = xmlbuilder.begin().ele('xml'); + drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml') + drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); + + const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit'); + sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); + + const st = drawingsVML.ele('v:shapetype') + .att('id', '_x0000_t75') + .att('coordsize', '21600,21600') + .att('o:spt', '75') + .att('o:preferrelative', 't') + .att('path', 'm@4@5l@4@11@9@11@9@5xe') + .att('filled', 'f').att('stroked', 'f'); + + st.ele('v:stroke').att('joinstyle', 'miter'); + var vf = st.ele('v:formulas'); + vf.ele('v:f').att('eqn', "if lineDrawn pixelLineWidth 0") + vf.ele('v:f').att('eqn', "sum @0 1 0"); + vf.ele('v:f').att('eqn', "sum 0 0 @1"); + vf.ele('v:f').att('eqn', "prod @2 1 2"); + vf.ele('v:f').att('eqn', "prod @3 21600 pixelWidth"); + vf.ele('v:f').att('eqn', "prod @3 21600 pixelHeight"); + vf.ele('v:f').att('eqn', "sum @0 0 1"); + vf.ele('v:f').att('eqn', "prod @6 1 2"); + vf.ele('v:f').att('eqn', "prod @7 21600 pixelWidth"); + vf.ele('v:f').att('eqn', "sum @8 21600 0"); + vf.ele('v:f').att('eqn', "prod @7 21600 pixelHeight"); + vf.ele('v:f').att('eqn', "sum @10 21600 0"); + + st.ele('v:path') + .att('o:extrusionok','f') + .att('gradientshapeok','t') + .att('o:connecttype','rect') + + st.ele('o:lock').att('v:ext','edit').att('aspectratio','t'); + + // const sh = drawingsVML.ele('v:shape'); + // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75') + // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`); + // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1') + // sh.ele('o:lock').att('v:ext','edit').att('rotation','t'); + + // const textB = sh.ele('v:textbox').text('VML TextBox') + + ws.legacyDrawingHeaderFooter.drawings.forEach((d) => { + + if (d.kind === 'image') { + let target = 'image' + d.id + '.' + d.extension; + + let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image; + promiseObj.xlsx.folder('xl').folder('media').file(target, image); + + drawingRelXML.ele('Relationship') + .att('Id', d.rId) + .att('Target', '../media/' + target) + .att('Type', d.type); + + } + + d.addToXMLele(drawingsVML); + + }); + + let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars); + let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars); + console.log('Genenrating VML Drawing File for ', ws.sheetId); + promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr); + promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr); + } + }); + + } + resolve(promiseObj); + }); +}; + + /** * Use JSZip to generate file to a node buffer * @private @@ -593,6 +701,7 @@ let writeToBuffer = (wb) => { .then(addSharedStringsXML) .then(addStylesXML) .then(addDrawingsXML) + .then(addLegacyHeaderFooterDrawingsXML) .then(() => { wb.opts.jszip.type = 'nodebuffer'; promiseObj.xlsx.generateAsync(wb.opts.jszip) diff --git a/source/lib/worksheet/builder.js b/source/lib/worksheet/builder.js index b561800f..a23170d2 100644 --- a/source/lib/worksheet/builder.js +++ b/source/lib/worksheet/builder.js @@ -484,6 +484,16 @@ let _addHeaderFooter = (promiseObj) => { }); }; +let _addlegacyDrawingHeaderFooter = (promiseObj) => { + return new Promise((resolve, reject) => { + if (!promiseObj.ws.legacyDrawingHeaderFooter.isEmpty) { + let dId = promiseObj.ws.relationships.indexOf('legacyDrawingHeaderFooter') + 1; + promiseObj.xml.ele('legacyDrawingHF').att('r:id', 'rId' + dId).up(); + } + resolve(promiseObj); + }); +}; + let _addDrawing = (promiseObj) => { // §18.3.1.36 drawing (Drawing) return new Promise((resolve, reject) => { @@ -534,6 +544,7 @@ let sheetXML = (ws) => { .then(_addPageSetup) .then(_addPageBreaks) .then(_addHeaderFooter) + .then(_addlegacyDrawingHeaderFooter) .then(_addDrawing) .then((promiseObj) => { return new Promise((resolve, reject) => { @@ -594,7 +605,12 @@ let relsXML = (ws) => { relXML.ele('Relationship') .att('Id', rId) .att('Target', '../drawings/commentsVml' + ws.sheetId + '.vml') - .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'); + .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'); + } else if (r === 'legacyDrawingHeaderFooter') { + relXML.ele('Relationship') + .att('Id', rId) + .att('Target', '../drawings/vmlDrawing' + ws.sheetId + '.vml') + .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'); } }); let xmlString = relXML.doc().end(); diff --git a/source/lib/worksheet/worksheet.js b/source/lib/worksheet/worksheet.js index 69e4b848..1e38a8ce 100644 --- a/source/lib/worksheet/worksheet.js +++ b/source/lib/worksheet/worksheet.js @@ -130,6 +130,7 @@ class Worksheet { this.hyperlinkCollection = new HyperlinkCollection(); this.dataValidationCollection = new DataValidation.DataValidationCollection(); this.drawingCollection = new wsDrawing.DrawingCollection(); + this.legacyDrawingHeaderFooter = new wsDrawing.DrawingCollection(); this.comments = {}; // Comments for cells keyed by excel ref this.author = this.wb.author; @@ -137,6 +138,9 @@ class Worksheet { get relationships() { let rels = []; + if(!this.legacyDrawingHeaderFooter.isEmpty){ + rels.push('legacyDrawingHeaderFooter') + } this.hyperlinkCollection.links.forEach((l) => { rels.push(l); }); @@ -315,6 +319,26 @@ class Worksheet { return this; } + /** + * @func Worksheet.setHeaderFooterImage + * @param {Object} opts + * @param {String} opts.path File system path of image + * @param {Buffer} opts.image Buffer with image (against read file from opts.path) + * @param {String} opts.name Name of image + * @param {String} opts.type Type of image. Currently only 'picture' is supported + * @param {String} opts.position Position string for image: ['LF','CF', 'RF', 'LH', 'CH', 'RH'] + */ + addHeaderFooterImage(image, position){ + const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH']; + if(headerFooterPositions.indexOf(position) < 0){ + throw new Error('setHeaderFooterImage: Only allowed positions are LH, CH, RH, LF, CF, RF'); + } + if(image.type === 'picture') image.type = 'headerFooterPicture'; + var mediaId = this.wb.mediaCollection.add(image); + var ximg = this.legacyDrawingHeaderFooter.add(image) + ximg.position = position; + ximg.id = mediaId; + } } module.exports = Worksheet; \ No newline at end of file From 75658274fa5bacd99b91b01275b498dbe77681ef Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 28 Dec 2020 04:21:42 +0300 Subject: [PATCH 03/12] Remove the prepublish script --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index be9c5021..a2fb44df 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ "cover": "node nyc tape -r babel-register .\\tests/*.test.js", "build": "node ./node_modules/babel-cli/bin/babel.js source --presets babel-preset-env -s --out-dir distribution", "watch": "node ./node_modules/babel-cli/bin/babel.js source -w --presets babel-preset-env -s --out-dir distribution", - "document": "jsdoc ./source -r -d docs", - "prepublish": "npm run build; npm run test" + "document": "jsdoc ./source -r -d docs" }, "dependencies": { "deepmerge": "3.2.0", From b73a770d44382c556146b305b5761ae5c3c297f9 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 28 Dec 2020 13:06:49 +0300 Subject: [PATCH 04/12] Add Documentation and change back the prepublish script to bulid and test --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84c7aea8..9b8196a9 100644 --- a/README.md +++ b/README.md @@ -337,6 +337,46 @@ Full Worksheet options. All options are optional. **Note:** headerFooter strings accept [Dynamic Formatting Strings](https://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.html). i.e. '&L&A&C&BCompany, Inc. Confidential&B&RPage &P of &N' +### **Header and Footer Images** +To use header and footer images place the graphics dynamic string in the desired section of your header and footer &G. Then call the addHeaderFooterImage passing the image and type 'picture' and the position as one of 'LF', 'CF', 'RF', 'LH', 'CH', 'RH'. The followingg code adds four images to the worksheet in all the footers and at the center of the header. The scale factor specifies how much the images is scaled. + +``` +var ws = wb.addWorksheet("Sheet1", { + pageSetup: { + fitToWidth: 1, + paperSize: 'A4_PAPER', + orientation: 'landscape' + }, + headerFooter: { + oddHeader: '&L&G &C&G &R&G', + oddFooter: '&L&G &C&G &R&G' + }, + printOptions: { centerHorizontal: true }, + sheetView: { rightToLeft: true } +}); + +ws.cell(1,1).string('Mohanad says hi'); + +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/logo copy.png')), + type: 'picture' +}, 'LF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/logo copy.png')), + type: 'picture' +}, 'CF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/signatures2.png')), + type: 'picture', + scale: 0.05 +}, 'RF') +ws.addHeaderFooterImage({ + image: fs.readFileSync(path.resolve(__dirname, './sampleFiles/signatures2.png')), + type: 'picture', + scale: 0.23 +}, 'CH') +``` + #### Methods ##### Worksheet data validations diff --git a/package.json b/package.json index a2fb44df..d1eccd5f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "cover": "node nyc tape -r babel-register .\\tests/*.test.js", "build": "node ./node_modules/babel-cli/bin/babel.js source --presets babel-preset-env -s --out-dir distribution", "watch": "node ./node_modules/babel-cli/bin/babel.js source -w --presets babel-preset-env -s --out-dir distribution", - "document": "jsdoc ./source -r -d docs" + "document": "jsdoc ./source -r -d docs", + "prepublish": "npm run build && npm run test" }, "dependencies": { "deepmerge": "3.2.0", From 7f8f480543fc79b2a03f74336bc7aef6737ead6b Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 28 Dec 2020 13:13:35 +0300 Subject: [PATCH 05/12] Allow distribution to be commited to repo so that I can install from Github --- .gitignore | 1 - distribution/index.js | 40 ++ distribution/index.js.map | 1 + distribution/lib/cell/cell.js | 101 +++ distribution/lib/cell/cell.js.map | 1 + distribution/lib/cell/index.js | 461 +++++++++++++ distribution/lib/cell/index.js.map | 1 + distribution/lib/classes/comment.js | 31 + distribution/lib/classes/comment.js.map | 1 + distribution/lib/classes/ctMarker.js | 75 +++ distribution/lib/classes/ctMarker.js.map | 1 + .../lib/classes/definedNameCollection.js | 100 +++ .../lib/classes/definedNameCollection.js.map | 1 + distribution/lib/classes/emu.js | 114 ++++ distribution/lib/classes/emu.js.map | 1 + distribution/lib/classes/point.js | 21 + distribution/lib/classes/point.js.map | 1 + distribution/lib/column/column.js | 139 ++++ distribution/lib/column/column.js.map | 1 + distribution/lib/column/index.js | 25 + distribution/lib/column/index.js.map | 1 + distribution/lib/drawing/drawing.js | 131 ++++ distribution/lib/drawing/drawing.js.map | 1 + .../lib/drawing/headerFooterPicture.js | 170 +++++ .../lib/drawing/headerFooterPicture.js.map | 1 + distribution/lib/drawing/index.js | 54 ++ distribution/lib/drawing/index.js.map | 1 + distribution/lib/drawing/picture.js | 230 +++++++ distribution/lib/drawing/picture.js.map | 1 + distribution/lib/logger.js | 74 +++ distribution/lib/logger.js.map | 1 + distribution/lib/row/index.js | 28 + distribution/lib/row/index.js.map | 1 + distribution/lib/row/row.js | 239 +++++++ distribution/lib/row/row.js.map | 1 + distribution/lib/style/classes/alignment.js | 142 ++++ .../lib/style/classes/alignment.js.map | 1 + distribution/lib/style/classes/border.js | 177 +++++ distribution/lib/style/classes/border.js.map | 1 + distribution/lib/style/classes/ctColor.js | 75 +++ distribution/lib/style/classes/ctColor.js.map | 1 + distribution/lib/style/classes/fill.js | 209 ++++++ distribution/lib/style/classes/fill.js.map | 1 + distribution/lib/style/classes/font.js | 129 ++++ distribution/lib/style/classes/font.js.map | 1 + .../lib/style/classes/numberFormat.js | 49 ++ .../lib/style/classes/numberFormat.js.map | 1 + distribution/lib/style/index.js | 4 + distribution/lib/style/index.js.map | 1 + distribution/lib/style/style.js | 361 ++++++++++ distribution/lib/style/style.js.map | 1 + distribution/lib/types/alignment.js | 75 +++ distribution/lib/types/alignment.js.map | 1 + distribution/lib/types/borderStyle.js | 28 + distribution/lib/types/borderStyle.js.map | 1 + distribution/lib/types/cellComment.js | 29 + distribution/lib/types/cellComment.js.map | 1 + distribution/lib/types/colorScheme.js | 28 + distribution/lib/types/colorScheme.js.map | 1 + distribution/lib/types/excelColor.js | 92 +++ distribution/lib/types/excelColor.js.map | 1 + distribution/lib/types/fillPattern.js | 28 + distribution/lib/types/fillPattern.js.map | 1 + distribution/lib/types/fontFamily.js | 32 + distribution/lib/types/fontFamily.js.map | 1 + distribution/lib/types/index.js | 17 + distribution/lib/types/index.js.map | 1 + distribution/lib/types/orientation.js | 29 + distribution/lib/types/orientation.js.map | 1 + distribution/lib/types/pageOrder.js | 29 + distribution/lib/types/pageOrder.js.map | 1 + distribution/lib/types/pane.js | 29 + distribution/lib/types/pane.js.map | 1 + distribution/lib/types/paneState.js | 29 + distribution/lib/types/paneState.js.map | 1 + distribution/lib/types/paperSize.js | 97 +++ distribution/lib/types/paperSize.js.map | 1 + .../lib/types/positiveUniversalMeasure.js | 17 + .../lib/types/positiveUniversalMeasure.js.map | 1 + distribution/lib/types/printError.js | 28 + distribution/lib/types/printError.js.map | 1 + distribution/lib/utils.js | 249 +++++++ distribution/lib/utils.js.map | 1 + distribution/lib/workbook/builder.js | 620 +++++++++++++++++ distribution/lib/workbook/builder.js.map | 1 + distribution/lib/workbook/dxfCollection.js | 85 +++ .../lib/workbook/dxfCollection.js.map | 1 + distribution/lib/workbook/index.js | 4 + distribution/lib/workbook/index.js.map | 1 + distribution/lib/workbook/mediaCollection.js | 41 ++ .../lib/workbook/mediaCollection.js.map | 1 + distribution/lib/workbook/workbook.js | 317 +++++++++ distribution/lib/workbook/workbook.js.map | 1 + distribution/lib/worksheet/builder.js | 622 ++++++++++++++++++ distribution/lib/worksheet/builder.js.map | 1 + distribution/lib/worksheet/cf/cf_rule.js | 71 ++ distribution/lib/worksheet/cf/cf_rule.js.map | 1 + .../lib/worksheet/cf/cf_rule_types.js | 48 ++ .../lib/worksheet/cf/cf_rule_types.js.map | 1 + .../lib/worksheet/cf/cf_rules_collection.js | 53 ++ .../worksheet/cf/cf_rules_collection.js.map | 1 + .../lib/worksheet/classes/dataValidation.js | 217 ++++++ .../worksheet/classes/dataValidation.js.map | 1 + .../lib/worksheet/classes/hyperlink.js | 100 +++ .../lib/worksheet/classes/hyperlink.js.map | 1 + distribution/lib/worksheet/index.js | 4 + distribution/lib/worksheet/index.js.map | 1 + distribution/lib/worksheet/optsValidator.js | 216 ++++++ .../lib/worksheet/optsValidator.js.map | 1 + .../lib/worksheet/sheet_default_params.js | 113 ++++ .../lib/worksheet/sheet_default_params.js.map | 1 + distribution/lib/worksheet/worksheet.js | 383 +++++++++++ distribution/lib/worksheet/worksheet.js.map | 1 + 113 files changed, 6965 insertions(+), 1 deletion(-) create mode 100644 distribution/index.js create mode 100644 distribution/index.js.map create mode 100644 distribution/lib/cell/cell.js create mode 100644 distribution/lib/cell/cell.js.map create mode 100644 distribution/lib/cell/index.js create mode 100644 distribution/lib/cell/index.js.map create mode 100644 distribution/lib/classes/comment.js create mode 100644 distribution/lib/classes/comment.js.map create mode 100644 distribution/lib/classes/ctMarker.js create mode 100644 distribution/lib/classes/ctMarker.js.map create mode 100644 distribution/lib/classes/definedNameCollection.js create mode 100644 distribution/lib/classes/definedNameCollection.js.map create mode 100644 distribution/lib/classes/emu.js create mode 100644 distribution/lib/classes/emu.js.map create mode 100644 distribution/lib/classes/point.js create mode 100644 distribution/lib/classes/point.js.map create mode 100644 distribution/lib/column/column.js create mode 100644 distribution/lib/column/column.js.map create mode 100644 distribution/lib/column/index.js create mode 100644 distribution/lib/column/index.js.map create mode 100644 distribution/lib/drawing/drawing.js create mode 100644 distribution/lib/drawing/drawing.js.map create mode 100644 distribution/lib/drawing/headerFooterPicture.js create mode 100644 distribution/lib/drawing/headerFooterPicture.js.map create mode 100644 distribution/lib/drawing/index.js create mode 100644 distribution/lib/drawing/index.js.map create mode 100644 distribution/lib/drawing/picture.js create mode 100644 distribution/lib/drawing/picture.js.map create mode 100644 distribution/lib/logger.js create mode 100644 distribution/lib/logger.js.map create mode 100644 distribution/lib/row/index.js create mode 100644 distribution/lib/row/index.js.map create mode 100644 distribution/lib/row/row.js create mode 100644 distribution/lib/row/row.js.map create mode 100644 distribution/lib/style/classes/alignment.js create mode 100644 distribution/lib/style/classes/alignment.js.map create mode 100644 distribution/lib/style/classes/border.js create mode 100644 distribution/lib/style/classes/border.js.map create mode 100644 distribution/lib/style/classes/ctColor.js create mode 100644 distribution/lib/style/classes/ctColor.js.map create mode 100644 distribution/lib/style/classes/fill.js create mode 100644 distribution/lib/style/classes/fill.js.map create mode 100644 distribution/lib/style/classes/font.js create mode 100644 distribution/lib/style/classes/font.js.map create mode 100644 distribution/lib/style/classes/numberFormat.js create mode 100644 distribution/lib/style/classes/numberFormat.js.map create mode 100644 distribution/lib/style/index.js create mode 100644 distribution/lib/style/index.js.map create mode 100644 distribution/lib/style/style.js create mode 100644 distribution/lib/style/style.js.map create mode 100644 distribution/lib/types/alignment.js create mode 100644 distribution/lib/types/alignment.js.map create mode 100644 distribution/lib/types/borderStyle.js create mode 100644 distribution/lib/types/borderStyle.js.map create mode 100644 distribution/lib/types/cellComment.js create mode 100644 distribution/lib/types/cellComment.js.map create mode 100644 distribution/lib/types/colorScheme.js create mode 100644 distribution/lib/types/colorScheme.js.map create mode 100644 distribution/lib/types/excelColor.js create mode 100644 distribution/lib/types/excelColor.js.map create mode 100644 distribution/lib/types/fillPattern.js create mode 100644 distribution/lib/types/fillPattern.js.map create mode 100644 distribution/lib/types/fontFamily.js create mode 100644 distribution/lib/types/fontFamily.js.map create mode 100644 distribution/lib/types/index.js create mode 100644 distribution/lib/types/index.js.map create mode 100644 distribution/lib/types/orientation.js create mode 100644 distribution/lib/types/orientation.js.map create mode 100644 distribution/lib/types/pageOrder.js create mode 100644 distribution/lib/types/pageOrder.js.map create mode 100644 distribution/lib/types/pane.js create mode 100644 distribution/lib/types/pane.js.map create mode 100644 distribution/lib/types/paneState.js create mode 100644 distribution/lib/types/paneState.js.map create mode 100644 distribution/lib/types/paperSize.js create mode 100644 distribution/lib/types/paperSize.js.map create mode 100644 distribution/lib/types/positiveUniversalMeasure.js create mode 100644 distribution/lib/types/positiveUniversalMeasure.js.map create mode 100644 distribution/lib/types/printError.js create mode 100644 distribution/lib/types/printError.js.map create mode 100644 distribution/lib/utils.js create mode 100644 distribution/lib/utils.js.map create mode 100644 distribution/lib/workbook/builder.js create mode 100644 distribution/lib/workbook/builder.js.map create mode 100644 distribution/lib/workbook/dxfCollection.js create mode 100644 distribution/lib/workbook/dxfCollection.js.map create mode 100644 distribution/lib/workbook/index.js create mode 100644 distribution/lib/workbook/index.js.map create mode 100644 distribution/lib/workbook/mediaCollection.js create mode 100644 distribution/lib/workbook/mediaCollection.js.map create mode 100644 distribution/lib/workbook/workbook.js create mode 100644 distribution/lib/workbook/workbook.js.map create mode 100644 distribution/lib/worksheet/builder.js create mode 100644 distribution/lib/worksheet/builder.js.map create mode 100644 distribution/lib/worksheet/cf/cf_rule.js create mode 100644 distribution/lib/worksheet/cf/cf_rule.js.map create mode 100644 distribution/lib/worksheet/cf/cf_rule_types.js create mode 100644 distribution/lib/worksheet/cf/cf_rule_types.js.map create mode 100644 distribution/lib/worksheet/cf/cf_rules_collection.js create mode 100644 distribution/lib/worksheet/cf/cf_rules_collection.js.map create mode 100644 distribution/lib/worksheet/classes/dataValidation.js create mode 100644 distribution/lib/worksheet/classes/dataValidation.js.map create mode 100644 distribution/lib/worksheet/classes/hyperlink.js create mode 100644 distribution/lib/worksheet/classes/hyperlink.js.map create mode 100644 distribution/lib/worksheet/index.js create mode 100644 distribution/lib/worksheet/index.js.map create mode 100644 distribution/lib/worksheet/optsValidator.js create mode 100644 distribution/lib/worksheet/optsValidator.js.map create mode 100644 distribution/lib/worksheet/sheet_default_params.js create mode 100644 distribution/lib/worksheet/sheet_default_params.js.map create mode 100644 distribution/lib/worksheet/worksheet.js create mode 100644 distribution/lib/worksheet/worksheet.js.map diff --git a/.gitignore b/.gitignore index b8bebee8..a6e2bf47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .idea node_modules -distribution .DS_Store npm-debug.log Excel.xlsx diff --git a/distribution/index.js b/distribution/index.js new file mode 100644 index 00000000..bb901630 --- /dev/null +++ b/distribution/index.js @@ -0,0 +1,40 @@ +'use strict'; + +/* REFERENCES + http://www.ecma-international.org/news/TC45_current_work/OpenXML%20White%20Paper.pdf + http://www.ecma-international.org/publications/standards/Ecma-376.htm + http://www.openoffice.org/sc/excelfileformat.pdf + http://officeopenxml.com/anatomyofOOXML-xlsx.php +*/ + +/* + Code references specifications sections from ECMA-376 2nd edition doc + ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference.pdf + found in ECMA-376 2nd edition Part 1 download at http://www.ecma-international.org/publications/standards/Ecma-376.htm + Sections are referenced in code comments with § +*/ + +var utils = require('./lib/utils.js'); +var types = require('./lib/types/index.js'); + +module.exports = { + Workbook: require('./lib/workbook/index.js'), + getExcelRowCol: utils.getExcelRowCol, + getExcelAlpha: utils.getExcelAlpha, + getExcelTS: utils.getExcelTS, + getExcelCellRef: utils.getExcelCellRef, + PaperSize: types.paperSize, + CellComment: types.cellComments, + PrintError: types.printError, + PageOrder: types.pageOrder, + Orientation: types.orientation, + Pane: types.pane, + PaneState: types.paneState, + HorizontalAlignment: types.alignment.horizontal, + VerticalAlignment: types.alignment.vertical, + BorderStyle: types.borderStyle, + PresetColorVal: types.excelColor, + PatternType: types.fillPattern, + PositiveUniversalMeasure: types.positiveUniversalMeasure +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/index.js.map b/distribution/index.js.map new file mode 100644 index 00000000..54d8af81 --- /dev/null +++ b/distribution/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../source/index.js"],"names":["utils","require","types","module","exports","Workbook","getExcelRowCol","getExcelAlpha","getExcelTS","getExcelCellRef","PaperSize","paperSize","CellComment","cellComments","PrintError","printError","PageOrder","pageOrder","Orientation","orientation","Pane","pane","PaneState","paneState","HorizontalAlignment","alignment","horizontal","VerticalAlignment","vertical","BorderStyle","borderStyle","PresetColorVal","excelColor","PatternType","fillPattern","PositiveUniversalMeasure","positiveUniversalMeasure"],"mappings":";;AAAA;;;;;;;AAOA;;;;;;;AAOA,IAAMA,QAAQC,QAAQ,gBAAR,CAAd;AACA,IAAMC,QAAQD,QAAQ,sBAAR,CAAd;;AAEAE,OAAOC,OAAP,GAAiB;AACbC,cAAUJ,QAAQ,yBAAR,CADG;AAEbK,oBAAgBN,MAAMM,cAFT;AAGbC,mBAAeP,MAAMO,aAHR;AAIbC,gBAAYR,MAAMQ,UAJL;AAKbC,qBAAiBT,MAAMS,eALV;AAMbC,eAAWR,MAAMS,SANJ;AAObC,iBAAaV,MAAMW,YAPN;AAQbC,gBAAYZ,MAAMa,UARL;AASbC,eAAWd,MAAMe,SATJ;AAUbC,iBAAahB,MAAMiB,WAVN;AAWbC,UAAMlB,MAAMmB,IAXC;AAYbC,eAAWpB,MAAMqB,SAZJ;AAabC,yBAAqBtB,MAAMuB,SAAN,CAAgBC,UAbxB;AAcbC,uBAAmBzB,MAAMuB,SAAN,CAAgBG,QAdtB;AAebC,iBAAa3B,MAAM4B,WAfN;AAgBbC,oBAAgB7B,MAAM8B,UAhBT;AAiBbC,iBAAa/B,MAAMgC,WAjBN;AAkBbC,8BAA0BjC,MAAMkC;AAlBnB,CAAjB","file":"index.js","sourcesContent":["/* REFERENCES\r\n http://www.ecma-international.org/news/TC45_current_work/OpenXML%20White%20Paper.pdf\r\n http://www.ecma-international.org/publications/standards/Ecma-376.htm\r\n http://www.openoffice.org/sc/excelfileformat.pdf \r\n http://officeopenxml.com/anatomyofOOXML-xlsx.php\r\n*/\r\n\r\n/* \r\n Code references specifications sections from ECMA-376 2nd edition doc\r\n ECMA-376, Second Edition, Part 1 - Fundamentals And Markup Language Reference.pdf\r\n found in ECMA-376 2nd edition Part 1 download at http://www.ecma-international.org/publications/standards/Ecma-376.htm\r\n Sections are referenced in code comments with § \r\n*/\r\n\r\nconst utils = require('./lib/utils.js');\r\nconst types = require('./lib/types/index.js');\r\n\r\nmodule.exports = {\r\n Workbook: require('./lib/workbook/index.js'),\r\n getExcelRowCol: utils.getExcelRowCol,\r\n getExcelAlpha: utils.getExcelAlpha,\r\n getExcelTS: utils.getExcelTS,\r\n getExcelCellRef: utils.getExcelCellRef,\r\n PaperSize: types.paperSize,\r\n CellComment: types.cellComments,\r\n PrintError: types.printError,\r\n PageOrder: types.pageOrder,\r\n Orientation: types.orientation,\r\n Pane: types.pane,\r\n PaneState: types.paneState,\r\n HorizontalAlignment: types.alignment.horizontal,\r\n VerticalAlignment: types.alignment.vertical,\r\n BorderStyle: types.borderStyle,\r\n PresetColorVal: types.excelColor,\r\n PatternType: types.fillPattern,\r\n PositiveUniversalMeasure: types.positiveUniversalMeasure\r\n};\r\n"]} \ No newline at end of file diff --git a/distribution/lib/cell/cell.js b/distribution/lib/cell/cell.js new file mode 100644 index 00000000..7658c8c2 --- /dev/null +++ b/distribution/lib/cell/cell.js @@ -0,0 +1,101 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var utils = require('../utils.js'); +var Comment = require('../classes/comment'); + +// §18.3.1.4 c (Cell) + +var Cell = function () { + /** + * Create an Excel Cell + * @private + * @param {Number} row Row of cell. + * @param {Number} col Column of cell + */ + function Cell(row, col) { + _classCallCheck(this, Cell); + + this.r = '' + utils.getExcelAlpha(col) + row; // 'r' attribute + this.s = 0; // 's' attribute refering to style index + this.t = null; // 't' attribute stating Cell data type - §18.18.11 ST_CellType (Cell Type) + this.f = null; // 'f' child element used for formulas + this.v = null; // 'v' child element for values + this.row = row; // used internally throughout code. Does not go into XML + this.col = col; // used internally throughout code. Does not go into XML + } + + _createClass(Cell, [{ + key: 'string', + value: function string(index) { + this.t = 's'; + this.v = index; + this.f = null; + } + }, { + key: 'number', + value: function number(val) { + this.t = 'n'; + this.v = val; + this.f = null; + } + }, { + key: 'formula', + value: function formula(_formula) { + this.t = null; + this.v = null; + this.f = _formula; + } + }, { + key: 'bool', + value: function bool(val) { + this.t = 'b'; + this.v = val; + this.f = null; + } + }, { + key: 'date', + value: function date(dt) { + this.t = null; + this.v = utils.getExcelTS(dt); + this.f = null; + } + }, { + key: 'style', + value: function style(sId) { + this.s = sId; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + if (this.v === null && this.is === null) { + return; + } + + var cEle = ele.ele('c').att('r', this.r).att('s', this.s); + if (this.t !== null) { + cEle.att('t', this.t); + } + if (this.f !== null) { + cEle.ele('f').txt(this.f).up(); + } + if (this.v !== null) { + cEle.ele('v').txt(this.v).up(); + } + cEle.up(); + } + }, { + key: 'comment', + get: function get() { + return this.comments[this.r]; + } + }]); + + return Cell; +}(); + +module.exports = Cell; +//# sourceMappingURL=cell.js.map \ No newline at end of file diff --git a/distribution/lib/cell/cell.js.map b/distribution/lib/cell/cell.js.map new file mode 100644 index 00000000..5f377857 --- /dev/null +++ b/distribution/lib/cell/cell.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/cell/cell.js"],"names":["utils","require","Comment","Cell","row","col","r","getExcelAlpha","s","t","f","v","index","val","formula","dt","getExcelTS","sId","ele","is","cEle","att","txt","up","comments","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,aAAR,CAAd;AACA,IAAMC,UAAUD,QAAQ,oBAAR,CAAhB;;AAEA;;IACME,I;AACF;;;;;;AAMA,kBAAYC,GAAZ,EAAiBC,GAAjB,EAAsB;AAAA;;AAClB,aAAKC,CAAL,QAAYN,MAAMO,aAAN,CAAoBF,GAApB,CAAZ,GAAuCD,GAAvC,CADkB,CAC4B;AAC9C,aAAKI,CAAL,GAAS,CAAT,CAFkB,CAEN;AACZ,aAAKC,CAAL,GAAS,IAAT,CAHkB,CAGH;AACf,aAAKC,CAAL,GAAS,IAAT,CAJkB,CAIH;AACf,aAAKC,CAAL,GAAS,IAAT,CALkB,CAKH;AACf,aAAKP,GAAL,GAAWA,GAAX,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Ba,EAA1B;AACH;AACD,gBAAI,KAAKZ,CAAL,KAAW,IAAf,EAAqB;AACjBS,qBAAKF,GAAL,CAAS,GAAT,EAAcI,GAAd,CAAkB,KAAKX,CAAvB,EAA0BY,EAA1B;AACH;AACDH,iBAAKG,EAAL;AACH;;;4BAtDa;AACV,mBAAO,KAAKC,QAAL,CAAc,KAAKlB,CAAnB,CAAP;AACH;;;;;;AAuDLmB,OAAOC,OAAP,GAAiBvB,IAAjB","file":"cell.js","sourcesContent":["const utils = require('../utils.js');\r\nconst Comment = require('../classes/comment');\r\n\r\n// §18.3.1.4 c (Cell)\r\nclass Cell {\r\n /**\r\n * Create an Excel Cell\r\n * @private\r\n * @param {Number} row Row of cell. \r\n * @param {Number} col Column of cell\r\n */\r\n constructor(row, col) {\r\n this.r = `${utils.getExcelAlpha(col)}${row}`; // 'r' attribute\r\n this.s = 0; // 's' attribute refering to style index\r\n this.t = null; // 't' attribute stating Cell data type - §18.18.11 ST_CellType (Cell Type)\r\n this.f = null; // 'f' child element used for formulas\r\n this.v = null; // 'v' child element for values\r\n this.row = row; // used internally throughout code. Does not go into XML\r\n this.col = col; // used internally throughout code. Does not go into XML\r\n }\r\n\r\n get comment() {\r\n return this.comments[this.r];\r\n }\r\n\r\n string(index) {\r\n this.t = 's';\r\n this.v = index;\r\n this.f = null;\r\n }\r\n\r\n number(val) {\r\n this.t = 'n';\r\n this.v = val;\r\n this.f = null;\r\n }\r\n\r\n formula(formula) {\r\n this.t = null;\r\n this.v = null;\r\n this.f = formula;\r\n }\r\n\r\n bool(val) {\r\n this.t = 'b';\r\n this.v = val;\r\n this.f = null;\r\n }\r\n\r\n date(dt) {\r\n this.t = null;\r\n this.v = utils.getExcelTS(dt);\r\n this.f = null;\r\n }\r\n\r\n style(sId) {\r\n this.s = sId;\r\n }\r\n\r\n addToXMLele(ele) {\r\n if (this.v === null && this.is === null) {\r\n return;\r\n }\r\n\r\n let cEle = ele.ele('c').att('r', this.r).att('s', this.s);\r\n if (this.t !== null) {\r\n cEle.att('t', this.t);\r\n }\r\n if (this.f !== null) {\r\n cEle.ele('f').txt(this.f).up();\r\n }\r\n if (this.v !== null) {\r\n cEle.ele('v').txt(this.v).up();\r\n }\r\n cEle.up();\r\n }\r\n}\r\n\r\nmodule.exports = Cell;\r\n\r\n"]} \ No newline at end of file diff --git a/distribution/lib/cell/index.js b/distribution/lib/cell/index.js new file mode 100644 index 00000000..2f0a7d34 --- /dev/null +++ b/distribution/lib/cell/index.js @@ -0,0 +1,461 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var deepmerge = require('deepmerge'); +var Cell = require('./cell.js'); +var Row = require('../row/row.js'); +var Comment = require('../classes/comment'); +var Column = require('../column/column.js'); +var Style = require('../style/style.js'); +var utils = require('../utils.js'); +var util = require('util'); + +var validXmlRegex = /[\t\n\r -\uD7FF\uE000-\uFFFD]/; + +/** + * The list of valid characters is + * #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + * + * We need to test codepoints numerically, instead of regex characters above 65536 (0x10000), + */ +function removeInvalidXml(str) { + return Array.from(str).map(function (c) { + var cp = c.codePointAt(0); + if (cp >= 65536 && cp <= 1114111) { + return c; + } else if (c.match(validXmlRegex)) { + return c; + } else { + return ''; + } + }).join(''); +} + +function stringSetter(val) { + var _this = this; + + var logger = this.ws.wb.logger; + + if (typeof val !== 'string') { + logger.warn('Value sent to String function of cells %s was not a string, it has type of %s', JSON.stringify(this.excelRefs), typeof val === 'undefined' ? 'undefined' : _typeof(val)); + val = ''; + } + val = removeInvalidXml(val); + + if (!this.merged) { + this.cells.forEach(function (c) { + c.string(_this.ws.wb.getStringIndex(val)); + }); + } else { + var c = this.cells[0]; + c.string(this.ws.wb.getStringIndex(val)); + } + return this; +} + +function complexStringSetter(val) { + var _this2 = this; + + if (!this.merged) { + this.cells.forEach(function (c) { + c.string(_this2.ws.wb.getStringIndex(val)); + }); + } else { + var c = this.cells[0]; + c.string(this.ws.wb.getStringIndex(val)); + } + return this; +} + +function numberSetter(val) { + if (val === undefined || parseFloat(val) !== val) { + throw new TypeError(util.format('Value sent to Number function of cells %s was not a number, it has type of %s and value of %s', JSON.stringify(this.excelRefs), typeof val === 'undefined' ? 'undefined' : _typeof(val), val)); + } + val = parseFloat(val); + + if (!this.merged) { + this.cells.forEach(function (c, i) { + c.number(val); + }); + } else { + var c = this.cells[0]; + c.number(val); + } + return this; +} + +function booleanSetter(val) { + if (val === undefined || typeof (val.toString().toLowerCase() === 'true' || (val.toString().toLowerCase() === 'false' ? false : val)) !== 'boolean') { + throw new TypeError(util.format('Value sent to Bool function of cells %s was not a bool, it has type of %s and value of %s', JSON.stringify(this.excelRefs), typeof val === 'undefined' ? 'undefined' : _typeof(val), val)); + } + val = val.toString().toLowerCase() === 'true'; + + if (!this.merged) { + this.cells.forEach(function (c, i) { + c.bool(val.toString()); + }); + } else { + var c = this.cells[0]; + c.bool(val.toString()); + } + return this; +} + +function formulaSetter(val) { + if (typeof val !== 'string') { + throw new TypeError(util.format('Value sent to Formula function of cells %s was not a string, it has type of %s', JSON.stringify(this.excelRefs), typeof val === 'undefined' ? 'undefined' : _typeof(val))); + } + if (this.merged !== true) { + this.cells.forEach(function (c, i) { + c.formula(val); + }); + } else { + var c = this.cells[0]; + c.formula(val); + } + + return this; +} + +function dateSetter(val) { + var thisDate = new Date(val); + if (isNaN(thisDate.getTime())) { + throw new TypeError(util.format('Invalid date sent to date function of cells. %s could not be converted to a date.', val)); + } + if (this.merged !== true) { + this.cells.forEach(function (c, i) { + c.date(thisDate); + }); + } else { + var c = this.cells[0]; + c.date(thisDate); + } + var dtStyle = new Style(this.ws.wb, { + numberFormat: '[$-409]' + this.ws.wb.opts.dateFormat + }); + return styleSetter.bind(this)(dtStyle); +} + +function styleSetter(val) { + var _this3 = this; + + var thisStyle = void 0; + if (val instanceof Style) { + thisStyle = val.toObject(); + } else if (val instanceof Object) { + thisStyle = val; + } else { + throw new TypeError(util.format('Parameter sent to Style function must be an instance of a Style or a style configuration object')); + } + + var borderEdges = {}; + if (thisStyle.border && thisStyle.border.outline) { + borderEdges.left = this.firstCol; + borderEdges.right = this.lastCol; + borderEdges.top = this.firstRow; + borderEdges.bottom = this.lastRow; + } + + this.cells.forEach(function (c) { + if (thisStyle.border && thisStyle.border.outline) { + var thisCellsBorder = {}; + if (c.row === borderEdges.top && thisStyle.border.top) { + thisCellsBorder.top = thisStyle.border.top; + } + if (c.row === borderEdges.bottom && thisStyle.border.bottom) { + thisCellsBorder.bottom = thisStyle.border.bottom; + } + if (c.col === borderEdges.left && thisStyle.border.left) { + thisCellsBorder.left = thisStyle.border.left; + } + if (c.col === borderEdges.right && thisStyle.border.right) { + thisCellsBorder.right = thisStyle.border.right; + } + thisStyle.border = thisCellsBorder; + } + + if (c.s === 0) { + var thisCellStyle = _this3.ws.wb.createStyle(thisStyle); + c.style(thisCellStyle.ids.cellXfs); + } else { + var curStyle = _this3.ws.wb.styles[c.s]; + var newStyleOpts = deepmerge(curStyle.toObject(), thisStyle); + var mergedStyle = _this3.ws.wb.createStyle(newStyleOpts); + c.style(mergedStyle.ids.cellXfs); + } + }); + return this; +} + +function hyperlinkSetter(url, displayStr, tooltip) { + var _this4 = this; + + this.excelRefs.forEach(function (ref) { + displayStr = typeof displayStr === 'string' ? displayStr : url; + _this4.ws.hyperlinkCollection.add({ + location: url, + display: displayStr, + tooltip: tooltip, + ref: ref + }); + }); + stringSetter.bind(this)(displayStr); + return styleSetter.bind(this)({ + font: { + color: 'Blue', + underline: true + } + }); +} + +function commentSetter(comment, options) { + var _this5 = this; + + if (this.merged !== true) { + this.cells.forEach(function (c, i) { + _this5.ws.comments[c.r] = new Comment(c.r, comment, options); + }); + } else { + var c = this.cells[0]; + this.ws.comments[c.r] = new Comment(c.r, comment, options); + } + return this; +} + +function mergeCells(cellBlock) { + var excelRefs = cellBlock.excelRefs; + if (excelRefs instanceof Array && excelRefs.length > 0) { + excelRefs.sort(utils.sortCellRefs); + + var cellRange = excelRefs[0] + ':' + excelRefs[excelRefs.length - 1]; + var rangeCells = excelRefs; + + var okToMerge = true; + cellBlock.ws.mergedCells.forEach(function (cr) { + // Check to see if currently merged cells contain cells in new merge request + var curCells = utils.getAllCellsInExcelRange(cr); + var intersection = utils.arrayIntersectSafe(rangeCells, curCells); + if (intersection.length > 0) { + okToMerge = false; + cellBlock.ws.wb.logger.error('Invalid Range for: ' + cellRange + '. Some cells in this range are already included in another merged cell range: ' + cr + '.'); + } + }); + if (okToMerge) { + cellBlock.ws.mergedCells.push(cellRange); + } + } else { + throw new TypeError(util.format('excelRefs variable sent to mergeCells function must be an array with length > 0')); + } +} + +/** + * @class cellBlock + */ + +var cellBlock = function () { + function cellBlock() { + _classCallCheck(this, cellBlock); + + this.ws; + this.cells = []; + this.excelRefs = []; + this.merged = false; + } + + _createClass(cellBlock, [{ + key: 'matrix', + get: function get() { + var matrix = []; + var tmpObj = {}; + this.cells.forEach(function (c) { + if (!tmpObj[c.row]) { + tmpObj[c.row] = []; + } + tmpObj[c.row].push(c); + }); + var rows = Object.keys(tmpObj); + rows.forEach(function (r) { + tmpObj[r].sort(function (a, b) { + return a.col - b.col; + }); + matrix.push(tmpObj[r]); + }); + return matrix; + } + }, { + key: 'firstRow', + get: function get() { + var firstRow = void 0; + this.cells.forEach(function (c) { + if (c.row < firstRow || firstRow === undefined) { + firstRow = c.row; + } + }); + return firstRow; + } + }, { + key: 'lastRow', + get: function get() { + var lastRow = void 0; + this.cells.forEach(function (c) { + if (c.row > lastRow || lastRow === undefined) { + lastRow = c.row; + } + }); + return lastRow; + } + }, { + key: 'firstCol', + get: function get() { + var firstCol = void 0; + this.cells.forEach(function (c) { + if (c.col < firstCol || firstCol === undefined) { + firstCol = c.col; + } + }); + return firstCol; + } + }, { + key: 'lastCol', + get: function get() { + var lastCol = void 0; + this.cells.forEach(function (c) { + if (c.col > lastCol || lastCol === undefined) { + lastCol = c.col; + } + }); + return lastCol; + } + }]); + + return cellBlock; +}(); + +/** + * Module repesenting a Cell Accessor + * @alias Worksheet.cell + * @namespace + * @func Worksheet.cell + * @desc Access a range of cells in order to manipulate values + * @param {Number} row1 Row of top left cell + * @param {Number} col1 Column of top left cell + * @param {Number} row2 Row of bottom right cell (optional) + * @param {Number} col2 Column of bottom right cell (optional) + * @param {Boolean} isMerged Merged the cell range into a single cell + * @returns {cellBlock} + */ + + +function cellAccessor(row1, col1, row2, col2, isMerged) { + var theseCells = new cellBlock(); + theseCells.ws = this; + + row2 = row2 ? row2 : row1; + col2 = col2 ? col2 : col1; + + if (row2 > this.lastUsedRow) { + this.lastUsedRow = row2; + } + + if (col2 > this.lastUsedCol) { + this.lastUsedCol = col2; + } + + for (var r = row1; r <= row2; r++) { + for (var c = col1; c <= col2; c++) { + var ref = '' + utils.getExcelAlpha(c) + r; + if (!this.cells[ref]) { + this.cells[ref] = new Cell(r, c); + } + if (!this.rows[r]) { + this.rows[r] = new Row(r, this); + } + if (this.rows[r].cellRefs.indexOf(ref) < 0) { + this.rows[r].cellRefs.push(ref); + } + + theseCells.cells.push(this.cells[ref]); + theseCells.excelRefs.push(ref); + } + } + if (isMerged) { + theseCells.merged = true; + mergeCells(theseCells); + } + + return theseCells; +} + +/** + * @alias cellBlock.string + * @func cellBlock.string + * @param {String} val Value of String + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.string = function (val) { + if (val instanceof Array) { + return complexStringSetter.bind(this)(val); + } else { + return stringSetter.bind(this)(val); + } +}; + +/** + * @alias cellBlock.style + * @func cellBlock.style + * @param {Object} style One of a Style instance or an object with Style parameters + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.style = styleSetter; + +/** + * @alias cellBlock.number + * @func cellBlock.number + * @param {Number} val Value of Number + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.number = numberSetter; + +/** + * @alias cellBlock.bool + * @func cellBlock.bool + * @param {Boolean} val Value of Boolean + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.bool = booleanSetter; + +/** + * @alias cellBlock.formula + * @func cellBlock.formula + * @param {String} val Excel style formula as string + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.formula = formulaSetter; + +/** + * @alias cellBlock.date + * @func cellBlock.date + * @param {Date} val Value of Date + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.date = dateSetter; + +/** + * @alias cellBlock.link + * @func cellBlock.link + * @param {String} url Value of Hyperlink URL + * @param {String} displayStr Value of String representation of URL + * @param {String} tooltip Value of text to display as hover + * @returns {cellBlock} Block of cells with attached methods + */ +cellBlock.prototype.link = hyperlinkSetter; + +cellBlock.prototype.comment = commentSetter; + +module.exports = cellAccessor; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/cell/index.js.map b/distribution/lib/cell/index.js.map new file mode 100644 index 00000000..f4883e47 --- /dev/null +++ b/distribution/lib/cell/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/cell/index.js"],"names":["deepmerge","require","Cell","Row","Comment","Column","Style","utils","util","validXmlRegex","removeInvalidXml","str","Array","from","map","cp","c","codePointAt","match","join","stringSetter","val","logger","ws","wb","warn","JSON","stringify","excelRefs","merged","cells","forEach","string","getStringIndex","complexStringSetter","numberSetter","undefined","parseFloat","TypeError","format","i","number","booleanSetter","toString","toLowerCase","bool","formulaSetter","formula","dateSetter","thisDate","Date","isNaN","getTime","date","dtStyle","numberFormat","opts","dateFormat","styleSetter","bind","thisStyle","toObject","Object","borderEdges","border","outline","left","firstCol","right","lastCol","top","firstRow","bottom","lastRow","thisCellsBorder","row","col","s","thisCellStyle","createStyle","style","ids","cellXfs","curStyle","styles","newStyleOpts","mergedStyle","hyperlinkSetter","url","displayStr","tooltip","ref","hyperlinkCollection","add","location","display","font","color","underline","commentSetter","comment","options","comments","r","mergeCells","cellBlock","length","sort","sortCellRefs","cellRange","rangeCells","okToMerge","mergedCells","cr","curCells","getAllCellsInExcelRange","intersection","arrayIntersectSafe","error","push","matrix","tmpObj","rows","keys","a","b","cellAccessor","row1","col1","row2","col2","isMerged","theseCells","lastUsedRow","lastUsedCol","getExcelAlpha","cellRefs","indexOf","prototype","link","module","exports"],"mappings":";;;;;;;;AAAA,IAAMA,YAAYC,QAAQ,WAAR,CAAlB;AACA,IAAMC,OAAOD,QAAQ,WAAR,CAAb;AACA,IAAME,MAAMF,QAAQ,eAAR,CAAZ;AACA,IAAMG,UAAUH,QAAQ,oBAAR,CAAhB;AACA,IAAMI,SAASJ,QAAQ,qBAAR,CAAf;AACA,IAAMK,QAAQL,QAAQ,mBAAR,CAAd;AACA,IAAMM,QAAQN,QAAQ,aAAR,CAAd;AACA,IAAMO,OAAOP,QAAQ,MAAR,CAAb;;AAEA,IAAMQ,gBAAgB,+BAAtB;;AAEA;;;;;;AAMA,SAASC,gBAAT,CAA0BC,GAA1B,EAA+B;AAC3B,WAAOC,MAAMC,IAAN,CAAWF,GAAX,EAAgBG,GAAhB,CAAoB,aAAK;AAC5B,YAAMC,KAAKC,EAAEC,WAAF,CAAc,CAAd,CAAX;AACA,YAAIF,MAAM,KAAN,IAAeA,MAAM,OAAzB,EAAkC;AAC9B,mBAAOC,CAAP;AACH,SAFD,MAEO,IAAIA,EAAEE,KAAF,CAAQT,aAAR,CAAJ,EAA4B;AAC/B,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KAAL,CAAW6D,GAAX,CAAtB;AACAyC,uBAAWxG,SAAX,CAAqB2F,IAArB,CAA0B5B,GAA1B;AACH;AACJ;AACD,QAAIwC,QAAJ,EAAc;AACVC,mBAAWvG,MAAX,GAAoB,IAApB;AACA2E,mBAAW4B,UAAX;AACH;;AAED,WAAOA,UAAP;AACH;;AAED;;;;;;AAMA3B,UAAUiC,SAAV,CAAoB1G,MAApB,GAA6B,UAAUX,GAAV,EAAe;AACxC,QAAIA,eAAeT,KAAnB,EAA0B;AACtB,eAAOsB,oBAAoByB,IAApB,CAAyB,IAAzB,EAA+BtC,GAA/B,CAAP;AACH,KAFD,MAEO;AACH,eAAOD,aAAauC,IAAb,CAAkB,IAAlB,EAAwBtC,GAAxB,CAAP;AACH;AACJ,CAND;;AAQA;;;;;;AAMAoF,UAAUiC,SAAV,CAAoB1D,KAApB,GAA4BtB,WAA5B;;AAEA;;;;;;AAMA+C,UAAUiC,SAAV,CAAoBjG,MAApB,GAA6BN,YAA7B;;AAEA;;;;;;AAMAsE,UAAUiC,SAAV,CAAoB7F,IAApB,GAA2BH,aAA3B;;AAEA;;;;;;AAMA+D,UAAUiC,SAAV,CAAoB3F,OAApB,GAA8BD,aAA9B;;AAEA;;;;;;AAMA2D,UAAUiC,SAAV,CAAoBrF,IAApB,GAA2BL,UAA3B;;AAEA;;;;;;;;AAQAyD,UAAUiC,SAAV,CAAoBC,IAApB,GAA2BpD,eAA3B;;AAEAkB,UAAUiC,SAAV,CAAoBtC,OAApB,GAA8BD,aAA9B;;AAEAyC,OAAOC,OAAP,GAAiBf,YAAjB","file":"index.js","sourcesContent":["const deepmerge = require('deepmerge');\r\nconst Cell = require('./cell.js');\r\nconst Row = require('../row/row.js');\r\nconst Comment = require('../classes/comment');\r\nconst Column = require('../column/column.js');\r\nconst Style = require('../style/style.js');\r\nconst utils = require('../utils.js');\r\nconst util = require('util');\r\n\r\nconst validXmlRegex = /[\\u0009\\u000a\\u000d\\u0020-\\uD7FF\\uE000-\\uFFFD]/u;\r\n\r\n/**\r\n * The list of valid characters is\r\n * #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]\r\n *\r\n * We need to test codepoints numerically, instead of regex characters above 65536 (0x10000),\r\n */\r\nfunction removeInvalidXml(str) {\r\n return Array.from(str).map(c => {\r\n const cp = c.codePointAt(0);\r\n if (cp >= 65536 && cp <= 1114111) {\r\n return c\r\n } else if (c.match(validXmlRegex)) {\r\n return c;\r\n } else {\r\n return '';\r\n }\r\n }).join('');\r\n}\r\n\r\nfunction stringSetter(val) {\r\n let logger = this.ws.wb.logger;\r\n\r\n if (typeof (val) !== 'string') {\r\n logger.warn('Value sent to String function of cells %s was not a string, it has type of %s',\r\n JSON.stringify(this.excelRefs),\r\n typeof (val));\r\n val = '';\r\n }\r\n val = removeInvalidXml(val);\r\n\r\n if (!this.merged) {\r\n this.cells.forEach((c) => {\r\n c.string(this.ws.wb.getStringIndex(val));\r\n });\r\n } else {\r\n let c = this.cells[0];\r\n c.string(this.ws.wb.getStringIndex(val));\r\n }\r\n return this;\r\n}\r\n\r\nfunction complexStringSetter(val) {\r\n if (!this.merged) {\r\n this.cells.forEach((c) => {\r\n c.string(this.ws.wb.getStringIndex(val));\r\n });\r\n } else {\r\n let c = this.cells[0];\r\n c.string(this.ws.wb.getStringIndex(val));\r\n }\r\n return this;\r\n}\r\n\r\nfunction numberSetter(val) {\r\n if (val === undefined || parseFloat(val) !== val) {\r\n throw new TypeError(util.format('Value sent to Number function of cells %s was not a number, it has type of %s and value of %s',\r\n JSON.stringify(this.excelRefs),\r\n typeof (val),\r\n val\r\n ));\r\n }\r\n val = parseFloat(val);\r\n\r\n if (!this.merged) {\r\n this.cells.forEach((c, i) => {\r\n c.number(val);\r\n });\r\n } else {\r\n var c = this.cells[0];\r\n c.number(val);\r\n }\r\n return this;\r\n}\r\n\r\nfunction booleanSetter(val) {\r\n if (val === undefined || typeof (val.toString().toLowerCase() === 'true' || ((val.toString().toLowerCase() === 'false') ? false : val)) !== 'boolean') {\r\n throw new TypeError(util.format('Value sent to Bool function of cells %s was not a bool, it has type of %s and value of %s',\r\n JSON.stringify(this.excelRefs),\r\n typeof (val),\r\n val\r\n ));\r\n }\r\n val = val.toString().toLowerCase() === 'true';\r\n\r\n if (!this.merged) {\r\n this.cells.forEach((c, i) => {\r\n c.bool(val.toString());\r\n });\r\n } else {\r\n var c = this.cells[0];\r\n c.bool(val.toString());\r\n }\r\n return this;\r\n}\r\n\r\nfunction formulaSetter(val) {\r\n if (typeof (val) !== 'string') {\r\n throw new TypeError(util.format('Value sent to Formula function of cells %s was not a string, it has type of %s', JSON.stringify(this.excelRefs), typeof (val)));\r\n }\r\n if (this.merged !== true) {\r\n this.cells.forEach((c, i) => {\r\n c.formula(val);\r\n });\r\n } else {\r\n var c = this.cells[0];\r\n c.formula(val);\r\n }\r\n\r\n return this;\r\n}\r\n\r\nfunction dateSetter(val) {\r\n let thisDate = new Date(val);\r\n if (isNaN(thisDate.getTime())) {\r\n throw new TypeError(util.format('Invalid date sent to date function of cells. %s could not be converted to a date.', val));\r\n }\r\n if (this.merged !== true) {\r\n this.cells.forEach((c, i) => {\r\n c.date(thisDate);\r\n });\r\n } else {\r\n var c = this.cells[0];\r\n c.date(thisDate);\r\n }\r\n const dtStyle = new Style(this.ws.wb, {\r\n numberFormat: '[$-409]' + this.ws.wb.opts.dateFormat\r\n });\r\n return styleSetter.bind(this)(dtStyle);\r\n}\r\n\r\nfunction styleSetter(val) {\r\n let thisStyle;\r\n if (val instanceof Style) {\r\n thisStyle = val.toObject();\r\n } else if (val instanceof Object) {\r\n thisStyle = val;\r\n } else {\r\n throw new TypeError(util.format('Parameter sent to Style function must be an instance of a Style or a style configuration object'));\r\n }\r\n\r\n let borderEdges = {};\r\n if (thisStyle.border && thisStyle.border.outline) {\r\n borderEdges.left = this.firstCol;\r\n borderEdges.right = this.lastCol;\r\n borderEdges.top = this.firstRow;\r\n borderEdges.bottom = this.lastRow;\r\n }\r\n\r\n this.cells.forEach((c) => {\r\n if (thisStyle.border && thisStyle.border.outline) {\r\n let thisCellsBorder = {};\r\n if (c.row === borderEdges.top && thisStyle.border.top) {\r\n thisCellsBorder.top = thisStyle.border.top;\r\n }\r\n if (c.row === borderEdges.bottom && thisStyle.border.bottom) {\r\n thisCellsBorder.bottom = thisStyle.border.bottom;\r\n }\r\n if (c.col === borderEdges.left && thisStyle.border.left) {\r\n thisCellsBorder.left = thisStyle.border.left;\r\n }\r\n if (c.col === borderEdges.right && thisStyle.border.right) {\r\n thisCellsBorder.right = thisStyle.border.right;\r\n }\r\n thisStyle.border = thisCellsBorder;\r\n }\r\n\r\n if (c.s === 0) {\r\n let thisCellStyle = this.ws.wb.createStyle(thisStyle);\r\n c.style(thisCellStyle.ids.cellXfs);\r\n } else {\r\n let curStyle = this.ws.wb.styles[c.s];\r\n let newStyleOpts = deepmerge(curStyle.toObject(), thisStyle);\r\n let mergedStyle = this.ws.wb.createStyle(newStyleOpts);\r\n c.style(mergedStyle.ids.cellXfs);\r\n }\r\n });\r\n return this;\r\n}\r\n\r\nfunction hyperlinkSetter(url, displayStr, tooltip) {\r\n this.excelRefs.forEach((ref) => {\r\n displayStr = typeof displayStr === 'string' ? displayStr : url;\r\n this.ws.hyperlinkCollection.add({\r\n location: url,\r\n display: displayStr,\r\n tooltip: tooltip,\r\n ref: ref\r\n });\r\n });\r\n stringSetter.bind(this)(displayStr);\r\n return styleSetter.bind(this)({\r\n font: {\r\n color: 'Blue',\r\n underline: true\r\n }\r\n });\r\n}\r\n\r\nfunction commentSetter(comment, options) {\r\n if (this.merged !== true) {\r\n this.cells.forEach((c, i) => {\r\n this.ws.comments[c.r] = new Comment(c.r, comment, options)\r\n });\r\n } else {\r\n var c = this.cells[0];\r\n this.ws.comments[c.r] = new Comment(c.r, comment, options)\r\n }\r\n return this;\r\n}\r\n\r\nfunction mergeCells(cellBlock) {\r\n let excelRefs = cellBlock.excelRefs;\r\n if (excelRefs instanceof Array && excelRefs.length > 0) {\r\n excelRefs.sort(utils.sortCellRefs);\r\n\r\n let cellRange = excelRefs[0] + ':' + excelRefs[excelRefs.length - 1];\r\n let rangeCells = excelRefs;\r\n\r\n let okToMerge = true;\r\n cellBlock.ws.mergedCells.forEach((cr) => {\r\n // Check to see if currently merged cells contain cells in new merge request\r\n let curCells = utils.getAllCellsInExcelRange(cr);\r\n let intersection = utils.arrayIntersectSafe(rangeCells, curCells);\r\n if (intersection.length > 0) {\r\n okToMerge = false;\r\n cellBlock.ws.wb.logger.error(`Invalid Range for: ${cellRange}. Some cells in this range are already included in another merged cell range: ${cr}.`);\r\n }\r\n });\r\n if (okToMerge) {\r\n cellBlock.ws.mergedCells.push(cellRange);\r\n }\r\n } else {\r\n throw new TypeError(util.format('excelRefs variable sent to mergeCells function must be an array with length > 0'));\r\n }\r\n}\r\n\r\n/**\r\n * @class cellBlock\r\n */\r\nclass cellBlock {\r\n\r\n constructor() {\r\n this.ws;\r\n this.cells = [];\r\n this.excelRefs = [];\r\n this.merged = false;\r\n }\r\n\r\n get matrix() {\r\n let matrix = [];\r\n let tmpObj = {};\r\n this.cells.forEach((c) => {\r\n if (!tmpObj[c.row]) {\r\n tmpObj[c.row] = [];\r\n }\r\n tmpObj[c.row].push(c);\r\n });\r\n let rows = Object.keys(tmpObj);\r\n rows.forEach((r) => {\r\n tmpObj[r].sort((a, b) => {\r\n return a.col - b.col;\r\n });\r\n matrix.push(tmpObj[r]);\r\n });\r\n return matrix;\r\n }\r\n\r\n get firstRow() {\r\n let firstRow;\r\n this.cells.forEach((c) => {\r\n if (c.row < firstRow || firstRow === undefined) {\r\n firstRow = c.row;\r\n }\r\n });\r\n return firstRow;\r\n }\r\n\r\n get lastRow() {\r\n let lastRow;\r\n this.cells.forEach((c) => {\r\n if (c.row > lastRow || lastRow === undefined) {\r\n lastRow = c.row;\r\n }\r\n });\r\n return lastRow;\r\n }\r\n\r\n get firstCol() {\r\n let firstCol;\r\n this.cells.forEach((c) => {\r\n if (c.col < firstCol || firstCol === undefined) {\r\n firstCol = c.col;\r\n }\r\n });\r\n return firstCol;\r\n }\r\n\r\n get lastCol() {\r\n let lastCol;\r\n this.cells.forEach((c) => {\r\n if (c.col > lastCol || lastCol === undefined) {\r\n lastCol = c.col;\r\n }\r\n });\r\n return lastCol;\r\n }\r\n}\r\n\r\n/**\r\n * Module repesenting a Cell Accessor\r\n * @alias Worksheet.cell\r\n * @namespace\r\n * @func Worksheet.cell\r\n * @desc Access a range of cells in order to manipulate values\r\n * @param {Number} row1 Row of top left cell\r\n * @param {Number} col1 Column of top left cell\r\n * @param {Number} row2 Row of bottom right cell (optional)\r\n * @param {Number} col2 Column of bottom right cell (optional)\r\n * @param {Boolean} isMerged Merged the cell range into a single cell\r\n * @returns {cellBlock}\r\n */\r\nfunction cellAccessor(row1, col1, row2, col2, isMerged) {\r\n let theseCells = new cellBlock();\r\n theseCells.ws = this;\r\n\r\n row2 = row2 ? row2 : row1;\r\n col2 = col2 ? col2 : col1;\r\n\r\n if (row2 > this.lastUsedRow) {\r\n this.lastUsedRow = row2;\r\n }\r\n\r\n if (col2 > this.lastUsedCol) {\r\n this.lastUsedCol = col2;\r\n }\r\n\r\n for (let r = row1; r <= row2; r++) {\r\n for (let c = col1; c <= col2; c++) {\r\n let ref = `${utils.getExcelAlpha(c)}${r}`;\r\n if (!this.cells[ref]) {\r\n this.cells[ref] = new Cell(r, c);\r\n }\r\n if (!this.rows[r]) {\r\n this.rows[r] = new Row(r, this);\r\n }\r\n if (this.rows[r].cellRefs.indexOf(ref) < 0) {\r\n this.rows[r].cellRefs.push(ref);\r\n }\r\n\r\n theseCells.cells.push(this.cells[ref]);\r\n theseCells.excelRefs.push(ref);\r\n }\r\n }\r\n if (isMerged) {\r\n theseCells.merged = true;\r\n mergeCells(theseCells);\r\n }\r\n\r\n return theseCells;\r\n}\r\n\r\n/**\r\n * @alias cellBlock.string\r\n * @func cellBlock.string\r\n * @param {String} val Value of String\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.string = function (val) {\r\n if (val instanceof Array) {\r\n return complexStringSetter.bind(this)(val);\r\n } else {\r\n return stringSetter.bind(this)(val);\r\n }\r\n};\r\n\r\n/**\r\n * @alias cellBlock.style\r\n * @func cellBlock.style\r\n * @param {Object} style One of a Style instance or an object with Style parameters\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.style = styleSetter;\r\n\r\n/**\r\n * @alias cellBlock.number\r\n * @func cellBlock.number\r\n * @param {Number} val Value of Number\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.number = numberSetter;\r\n\r\n/**\r\n * @alias cellBlock.bool\r\n * @func cellBlock.bool\r\n * @param {Boolean} val Value of Boolean\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.bool = booleanSetter;\r\n\r\n/**\r\n * @alias cellBlock.formula\r\n * @func cellBlock.formula\r\n * @param {String} val Excel style formula as string\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.formula = formulaSetter;\r\n\r\n/**\r\n * @alias cellBlock.date\r\n * @func cellBlock.date\r\n * @param {Date} val Value of Date\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.date = dateSetter;\r\n\r\n/**\r\n * @alias cellBlock.link\r\n * @func cellBlock.link\r\n * @param {String} url Value of Hyperlink URL\r\n * @param {String} displayStr Value of String representation of URL\r\n * @param {String} tooltip Value of text to display as hover\r\n * @returns {cellBlock} Block of cells with attached methods\r\n */\r\ncellBlock.prototype.link = hyperlinkSetter;\r\n\r\ncellBlock.prototype.comment = commentSetter;\r\n\r\nmodule.exports = cellAccessor;"]} \ No newline at end of file diff --git a/distribution/lib/classes/comment.js b/distribution/lib/classes/comment.js new file mode 100644 index 00000000..6f677b4b --- /dev/null +++ b/distribution/lib/classes/comment.js @@ -0,0 +1,31 @@ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var uuid = require('uuid/v4'); +var utils = require('../utils'); + +// §18.7.3 Comment + +var Comment = function Comment(ref, comment) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + _classCallCheck(this, Comment); + + this.ref = ref; + this.comment = comment; + this.uuid = '{' + uuid().toUpperCase() + '}'; + this.row = utils.getExcelRowCol(ref).row; + this.col = utils.getExcelRowCol(ref).col; + this.marginLeft = options.marginLeft || this.col * 88 + 8 + 'pt'; + this.marginTop = options.marginTop || (this.row - 1) * 16 + 8 + 'pt'; + this.width = options.width || '104pt'; + this.height = options.height || '69pt'; + this.position = options.position || 'absolute'; + this.zIndex = options.zIndex || '1'; + this.fillColor = options.fillColor || '#ffffe1'; + this.visibility = options.visibility || 'hidden'; +}; + +module.exports = Comment; +//# sourceMappingURL=comment.js.map \ No newline at end of file diff --git a/distribution/lib/classes/comment.js.map b/distribution/lib/classes/comment.js.map new file mode 100644 index 00000000..433a14eb --- /dev/null +++ b/distribution/lib/classes/comment.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/classes/comment.js"],"names":["uuid","require","utils","Comment","ref","comment","options","toUpperCase","row","getExcelRowCol","col","marginLeft","marginTop","width","height","position","zIndex","fillColor","visibility","module","exports"],"mappings":";;;;AAAA,IAAMA,OAAOC,QAAQ,SAAR,CAAb;AACA,IAAMC,QAAQD,QAAQ,UAAR,CAAd;;AAEA;;IACME,O,GACF,iBAAYC,GAAZ,EAAiBC,OAAjB,EAAwC;AAAA,QAAdC,OAAc,uEAAJ,EAAI;;AAAA;;AACpC,SAAKF,GAAL,GAAWA,GAAX;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKL,IAAL,GAAY,MAAMA,OAAOO,WAAP,EAAN,GAA6B,GAAzC;AACA,SAAKC,GAAL,GAAWN,MAAMO,cAAN,CAAqBL,GAArB,EAA0BI,GAArC;AACA,SAAKE,GAAL,GAAWR,MAAMO,cAAN,CAAqBL,GAArB,EAA0BM,GAArC;AACA,SAAKC,UAAL,GAAkBL,QAAQK,UAAR,IAAwB,KAAKD,GAAN,GAAa,EAAb,GAAkB,CAAnB,GAAwB,IAAhE;AACA,SAAKE,SAAL,GAAiBN,QAAQM,SAAR,IAAsB,CAAC,KAAKJ,GAAL,GAAW,CAAZ,IAAiB,EAAjB,GAAsB,CAAvB,GAA4B,IAAlE;AACA,SAAKK,KAAL,GAAaP,QAAQO,KAAR,IAAiB,OAA9B;AACA,SAAKC,MAAL,GAAcR,QAAQQ,MAAR,IAAkB,MAAhC;AACA,SAAKC,QAAL,GAAgBT,QAAQS,QAAR,IAAoB,UAApC;AACA,SAAKC,MAAL,GAAcV,QAAQU,MAAR,IAAkB,GAAhC;AACA,SAAKC,SAAL,GAAiBX,QAAQW,SAAR,IAAqB,SAAtC;AACA,SAAKC,UAAL,GAAkBZ,QAAQY,UAAR,IAAsB,QAAxC;AACH,C;;AAILC,OAAOC,OAAP,GAAiBjB,OAAjB","file":"comment.js","sourcesContent":["const uuid = require('uuid/v4');\r\nconst utils = require('../utils');\r\n\r\n// §18.7.3 Comment\r\nclass Comment {\r\n constructor(ref, comment, options = {}) {\r\n this.ref = ref;\r\n this.comment = comment;\r\n this.uuid = '{' + uuid().toUpperCase() + '}';\r\n this.row = utils.getExcelRowCol(ref).row;\r\n this.col = utils.getExcelRowCol(ref).col;\r\n this.marginLeft = options.marginLeft || ((this.col) * 88 + 8) + 'pt';\r\n this.marginTop = options.marginTop || ((this.row - 1) * 16 + 8) + 'pt';\r\n this.width = options.width || '104pt';\r\n this.height = options.height || '69pt';\r\n this.position = options.position || 'absolute';\r\n this.zIndex = options.zIndex || '1';\r\n this.fillColor = options.fillColor || '#ffffe1';\r\n this.visibility = options.visibility || 'hidden';\r\n }\r\n\r\n}\r\n\r\nmodule.exports = Comment;\r\n"]} \ No newline at end of file diff --git a/distribution/lib/classes/ctMarker.js b/distribution/lib/classes/ctMarker.js new file mode 100644 index 00000000..338b3b1d --- /dev/null +++ b/distribution/lib/classes/ctMarker.js @@ -0,0 +1,75 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var EMU = require('./emu.js'); + +var CTMarker = function () { + /** + * Element representing an Excel position marker + * @param {Number} colId Column Number + * @param {String} colOffset Offset stating how far right to shift the start edge + * @param {Number} rowId Row Number + * @param {String} rowOffset Offset stating how far down to shift the start edge + * @property {Number} col Column number + * @property {EMU} colOff EMUs of right shift + * @property {Number} row Row number + * @property {EMU} rowOff EMUs of top shift + * @returns {CTMarker} Excel CTMarker + */ + function CTMarker(colId, colOffset, rowId, rowOffset) { + _classCallCheck(this, CTMarker); + + this._col = colId; + this._colOff = new EMU(colOffset); + this._row = rowId; + this._rowOff = new EMU(rowOffset); + } + + _createClass(CTMarker, [{ + key: 'col', + get: function get() { + return this._col; + }, + set: function set(val) { + if (parseInt(val, 10) !== val || val < 0) { + throw new TypeError('CTMarker column must be a positive integer'); + } + this._col = val; + } + }, { + key: 'row', + get: function get() { + return this._row; + }, + set: function set(val) { + if (parseInt(val, 10) !== val || val < 0) { + throw new TypeError('CTMarker row must be a positive integer'); + } + this._row = val; + } + }, { + key: 'colOff', + get: function get() { + return this._colOff.value; + }, + set: function set(val) { + this._colOff = new EMU(val); + } + }, { + key: 'rowOff', + get: function get() { + return this._rowOff.value; + }, + set: function set(val) { + this._rowOff = new EMU(val); + } + }]); + + return CTMarker; +}(); + +module.exports = CTMarker; +//# sourceMappingURL=ctMarker.js.map \ No newline at end of file diff --git a/distribution/lib/classes/ctMarker.js.map b/distribution/lib/classes/ctMarker.js.map new file mode 100644 index 00000000..17ddabb3 --- /dev/null +++ b/distribution/lib/classes/ctMarker.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/classes/ctMarker.js"],"names":["EMU","require","CTMarker","colId","colOffset","rowId","rowOffset","_col","_colOff","_row","_rowOff","val","parseInt","TypeError","value","module","exports"],"mappings":";;;;;;AAAA,IAAIA,MAAMC,QAAQ,UAAR,CAAV;;IAEMC,Q;AACF;;;;;;;;;;;;AAYA,sBAAYC,KAAZ,EAAmBC,SAAnB,EAA8BC,KAA9B,EAAqCC,SAArC,EAAgD;AAAA;;AAC5C,aAAKC,IAAL,GAAYJ,KAAZ;AACA,aAAKK,OAAL,GAAe,IAAIR,GAAJ,CAAQI,SAAR,CAAf;AACA,aAAKK,IAAL,GAAYJ,KAAZ;AACA,aAAKK,OAAL,GAAe,IAAIV,GAAJ,CAAQM,SAAR,CAAf;AACH;;;;4BAES;AACN,mBAAO,KAAKC,IAAZ;AACH,S;0BACOI,G,EAAK;AACT,gBAAIC,SAASD,GAAT,EAAc,EAAd,MAAsBA,GAAtB,IAA6BA,MAAM,CAAvC,EAA0C;AACtC,sBAAM,IAAIE,SAAJ,CAAc,4CAAd,CAAN;AACH;AACD,iBAAKN,IAAL,GAAYI,GAAZ;AACH;;;4BAES;AACN,mBAAO,KAAKF,IAAZ;AACH,S;0BACOE,G,EAAK;AACT,gBAAIC,SAASD,GAAT,EAAc,EAAd,MAAsBA,GAAtB,IAA6BA,MAAM,CAAvC,EAA0C;AACtC,sBAAM,IAAIE,SAAJ,CAAc,yCAAd,CAAN;AACH;AACD,iBAAKJ,IAAL,GAAYE,GAAZ;AACH;;;4BAEY;AACT,mBAAO,KAAKH,OAAL,CAAaM,KAApB;AACH,S;0BACUH,G,EAAK;AACZ,iBAAKH,OAAL,GAAe,IAAIR,GAAJ,CAAQW,GAAR,CAAf;AACH;;;4BAEY;AACT,mBAAO,KAAKD,OAAL,CAAaI,KAApB;AACH,S;0BACUH,G,EAAK;AACZ,iBAAKD,OAAL,GAAe,IAAIV,GAAJ,CAAQW,GAAR,CAAf;AACH;;;;;;AAGLI,OAAOC,OAAP,GAAiBd,QAAjB","file":"ctMarker.js","sourcesContent":["let EMU = require('./emu.js');\r\n\r\nclass CTMarker {\r\n /**\r\n * Element representing an Excel position marker\r\n * @param {Number} colId Column Number\r\n * @param {String} colOffset Offset stating how far right to shift the start edge\r\n * @param {Number} rowId Row Number\r\n * @param {String} rowOffset Offset stating how far down to shift the start edge\r\n * @property {Number} col Column number\r\n * @property {EMU} colOff EMUs of right shift\r\n * @property {Number} row Row number\r\n * @property {EMU} rowOff EMUs of top shift\r\n * @returns {CTMarker} Excel CTMarker \r\n */\r\n constructor(colId, colOffset, rowId, rowOffset) {\r\n this._col = colId;\r\n this._colOff = new EMU(colOffset);\r\n this._row = rowId;\r\n this._rowOff = new EMU(rowOffset);\r\n }\r\n\r\n get col() {\r\n return this._col;\r\n }\r\n set col(val) {\r\n if (parseInt(val, 10) !== val || val < 0) {\r\n throw new TypeError('CTMarker column must be a positive integer');\r\n }\r\n this._col = val;\r\n }\r\n\r\n get row() {\r\n return this._row;\r\n }\r\n set row(val) {\r\n if (parseInt(val, 10) !== val || val < 0) {\r\n throw new TypeError('CTMarker row must be a positive integer');\r\n }\r\n this._row = val;\r\n }\r\n\r\n get colOff() {\r\n return this._colOff.value;\r\n }\r\n set colOff(val) {\r\n this._colOff = new EMU(val);\r\n }\r\n\r\n get rowOff() {\r\n return this._rowOff.value;\r\n }\r\n set rowOff(val) {\r\n this._rowOff = new EMU(val);\r\n }\r\n}\r\n\r\nmodule.exports = CTMarker;"]} \ No newline at end of file diff --git a/distribution/lib/classes/definedNameCollection.js b/distribution/lib/classes/definedNameCollection.js new file mode 100644 index 00000000..73c4b388 --- /dev/null +++ b/distribution/lib/classes/definedNameCollection.js @@ -0,0 +1,100 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var DefinedName = function () { + //§18.2.5 definedName (Defined Name) + function DefinedName(opts) { + _classCallCheck(this, DefinedName); + + opts.refFormula !== undefined ? this.refFormula = opts.refFormula : null; + opts.name !== undefined ? this.name = opts.name : null; + opts.comment !== undefined ? this.comment = opts.comment : null; + opts.customMenu !== undefined ? this.customMenu = opts.customMenu : null; + opts.description !== undefined ? this.description = opts.description : null; + opts.help !== undefined ? this.help = opts.help : null; + opts.statusBar !== undefined ? this.statusBar = opts.statusBar : null; + opts.localSheetId !== undefined ? this.localSheetId = opts.localSheetId : null; + opts.hidden !== undefined ? this.hidden = opts.hidden : null; + opts['function'] !== undefined ? this['function'] = opts['function'] : null; + opts.vbProcedure !== undefined ? this.vbProcedure = opts.vbProcedure : null; + opts.xlm !== undefined ? this.xlm = opts.xlm : null; + opts.functionGroupId !== undefined ? this.functionGroupId = opts.functionGroupId : null; + opts.shortcutKey !== undefined ? this.shortcutKey = opts.shortcutKey : null; + opts.publishToServer !== undefined ? this.publishToServer = opts.publishToServer : null; + opts.workbookParameter !== undefined ? this.workbookParameter = opts.workbookParameter : null; + } + + _createClass(DefinedName, [{ + key: 'addToXMLele', + value: function addToXMLele(ele) { + var dEle = ele.ele('definedName'); + this.comment !== undefined ? dEle.att('comment', this.comment) : null; + this.customMenu !== undefined ? dEle.att('customMenu', this.customMenu) : null; + this.description !== undefined ? dEle.att('description', this.description) : null; + this.help !== undefined ? dEle.att('help', this.help) : null; + this.statusBar !== undefined ? dEle.att('statusBar', this.statusBar) : null; + this.hidden !== undefined ? dEle.att('hidden', this.hidden) : null; + this.localSheetId !== undefined ? dEle.att('localSheetId', this.localSheetId) : null; + this.name !== undefined ? dEle.att('name', this.name) : null; + this['function'] !== undefined ? dEle.att('function', this['function']) : null; + this.vbProcedure !== undefined ? dEle.att('vbProcedure', this.vbProcedure) : null; + this.xlm !== undefined ? dEle.att('xlm', this.xlm) : null; + this.functionGroupId !== undefined ? dEle.att('functionGroupId', this.functionGroupId) : null; + this.shortcutKey !== undefined ? dEle.att('shortcutKey', this.shortcutKey) : null; + this.publishToServer !== undefined ? dEle.att('publishToServer', this.publishToServer) : null; + this.workbookParameter !== undefined ? dEle.att('workbookParameter', this.workbookParameter) : null; + + this.refFormula !== undefined ? dEle.text(this.refFormula) : null; + } + }]); + + return DefinedName; +}(); + +var DefinedNameCollection = function () { + // §18.2.6 definedNames (Defined Names) + function DefinedNameCollection() { + _classCallCheck(this, DefinedNameCollection); + + this.items = []; + } + + _createClass(DefinedNameCollection, [{ + key: 'addDefinedName', + value: function addDefinedName(opts) { + var item = new DefinedName(opts); + var newLength = this.items.push(item); + return this.items[newLength - 1]; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var dnEle = ele.ele('definedNames'); + this.items.forEach(function (dn) { + dn.addToXMLele(dnEle); + }); + } + }, { + key: 'length', + get: function get() { + return this.items.length; + } + }, { + key: 'isEmpty', + get: function get() { + if (this.items.length === 0) { + return true; + } else { + return false; + } + } + }]); + + return DefinedNameCollection; +}(); + +module.exports = DefinedNameCollection; +//# sourceMappingURL=definedNameCollection.js.map \ No newline at end of file diff --git a/distribution/lib/classes/definedNameCollection.js.map b/distribution/lib/classes/definedNameCollection.js.map new file mode 100644 index 00000000..842bdaf0 --- /dev/null +++ b/distribution/lib/classes/definedNameCollection.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/classes/definedNameCollection.js"],"names":["DefinedName","opts","refFormula","undefined","name","comment","customMenu","description","help","statusBar","localSheetId","hidden","vbProcedure","xlm","functionGroupId","shortcutKey","publishToServer","workbookParameter","ele","dEle","att","text","DefinedNameCollection","items","item","newLength","push","dnEle","forEach","dn","addToXMLele","length","module","exports"],"mappings":";;;;;;IAAMA,W;AAAc;AAChB,yBAAYC,IAAZ,EAAkB;AAAA;;AACdA,aAAKC,UAAL,KAAoBC,SAApB,GAAgC,KAAKD,UAAL,GAAkBD,KAAKC,UAAvD,GAAoE,IAApE;AACAD,aAAKG,IAAL,KAAcD,SAAd,GAA0B,KAAKC,IAAL,GAAYH,KAAKG,IAA3C,GAAkD,IAAlD;AACAH,aAAKI,OAAL,KAAiBF,SAAjB,GAA6B,KAAKE,OAAL,GAAeJ,KAAKI,OAAjD,GAA2D,IAA3D;AACAJ,aAAKK,UAAL,KAAoBH,SAApB,GAAgC,KAAKG,UAAL,GAAkBL,KAAKK,UAAvD,GAAoE,IAApE;AACAL,aAAKM,WAAL,KAAqBJ,SAArB,GAAiC,KAAKI,WAAL,GAAmBN,KAAKM,WAAzD,GAAuE,IAAvE;AACAN,aAAKO,IAAL,KAAcL,SAAd,GAA0B,KAAKK,IAAL,GAAYP,KAAKO,IAA3C,GAAkD,IAAlD;AACAP,aAAKQ,SAAL,KAAmBN,SAAnB,GAA+B,KAAKM,SAAL,GAAiBR,KAAKQ,SAArD,GAAiE,IAAjE;AACAR,aAAKS,YAAL,KAAsBP,SAAtB,GAAkC,KAAKO,YAAL,GAAoBT,KAAKS,YAA3D,GAA0E,IAA1E;AACAT,aAAKU,MAAL,KAAgBR,SAAhB,GAA4B,KAAKQ,MAAL,GAAcV,KAAKU,MAA/C,GAAwD,IAAxD;AACAV,aAAK,UAAL,MAAqBE,SAArB,GAAiC,KAAK,UAAL,IAAmBF,KAAK,UAAL,CAApD,GAAuE,IAAvE;AACAA,aAAKW,WAAL,KAAqBT,SAArB,GAAiC,KAAKS,WAAL,GAAmBX,KAAKW,WAAzD,GAAuE,IAAvE;AACAX,aAAKY,GAAL,KAAaV,SAAb,GAAyB,KAAKU,GAAL,GAAWZ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AAY,KAAKF,KAAL,CAAWG,IAAX,CAAgBF,IAAhB,CAAhB;AACA,mBAAO,KAAKD,KAAL,CAAWE,YAAY,CAAvB,CAAP;AACH;;;oCAEWP,G,EAAK;AACb,gBAAIS,QAAQT,IAAIA,GAAJ,CAAQ,cAAR,CAAZ;AACA,iBAAKK,KAAL,CAAWK,OAAX,CAAmB,UAACC,EAAD,EAAQ;AACvBA,mBAAGC,WAAH,CAAeH,KAAf;AACH,aAFD;AAGH;;;4BAvBY;AACT,mBAAO,KAAKJ,KAAL,CAAWQ,MAAlB;AACH;;;4BAEa;AACV,gBAAI,KAAKR,KAAL,CAAWQ,MAAX,KAAsB,CAA1B,EAA6B;AACzB,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAeLC,OAAOC,OAAP,GAAiBX,qBAAjB","file":"definedNameCollection.js","sourcesContent":["class DefinedName { //§18.2.5 definedName (Defined Name)\r\n constructor(opts) {\r\n opts.refFormula !== undefined ? this.refFormula = opts.refFormula : null; \r\n opts.name !== undefined ? this.name = opts.name : null;\r\n opts.comment !== undefined ? this.comment = opts.comment : null; \r\n opts.customMenu !== undefined ? this.customMenu = opts.customMenu : null; \r\n opts.description !== undefined ? this.description = opts.description : null; \r\n opts.help !== undefined ? this.help = opts.help : null; \r\n opts.statusBar !== undefined ? this.statusBar = opts.statusBar : null; \r\n opts.localSheetId !== undefined ? this.localSheetId = opts.localSheetId : null; \r\n opts.hidden !== undefined ? this.hidden = opts.hidden : null; \r\n opts['function'] !== undefined ? this['function'] = opts['function'] : null; \r\n opts.vbProcedure !== undefined ? this.vbProcedure = opts.vbProcedure : null; \r\n opts.xlm !== undefined ? this.xlm = opts.xlm : null; \r\n opts.functionGroupId !== undefined ? this.functionGroupId = opts.functionGroupId : null; \r\n opts.shortcutKey !== undefined ? this.shortcutKey = opts.shortcutKey : null; \r\n opts.publishToServer !== undefined ? this.publishToServer = opts.publishToServer : null; \r\n opts.workbookParameter !== undefined ? this.workbookParameter = opts.workbookParameter : null; \r\n }\r\n\r\n addToXMLele(ele) {\r\n let dEle = ele.ele('definedName');\r\n this.comment !== undefined ? dEle.att('comment', this.comment) : null; \r\n this.customMenu !== undefined ? dEle.att('customMenu', this.customMenu) : null; \r\n this.description !== undefined ? dEle.att('description', this.description) : null; \r\n this.help !== undefined ? dEle.att('help', this.help) : null; \r\n this.statusBar !== undefined ? dEle.att('statusBar', this.statusBar) : null; \r\n this.hidden !== undefined ? dEle.att('hidden', this.hidden) : null; \r\n this.localSheetId !== undefined ? dEle.att('localSheetId', this.localSheetId) : null; \r\n this.name !== undefined ? dEle.att('name', this.name) : null;\r\n this['function'] !== undefined ? dEle.att('function', this['function']) : null; \r\n this.vbProcedure !== undefined ? dEle.att('vbProcedure', this.vbProcedure) : null; \r\n this.xlm !== undefined ? dEle.att('xlm', this.xlm) : null; \r\n this.functionGroupId !== undefined ? dEle.att('functionGroupId', this.functionGroupId) : null; \r\n this.shortcutKey !== undefined ? dEle.att('shortcutKey', this.shortcutKey) : null; \r\n this.publishToServer !== undefined ? dEle.att('publishToServer', this.publishToServer) : null; \r\n this.workbookParameter !== undefined ? dEle.att('workbookParameter', this.workbookParameter) : null; \r\n\r\n this.refFormula !== undefined ? dEle.text(this.refFormula) : null;\r\n }\r\n}\r\n\r\n\r\nclass DefinedNameCollection { // §18.2.6 definedNames (Defined Names)\r\n constructor() {\r\n this.items = [];\r\n }\r\n\r\n get length() {\r\n return this.items.length;\r\n }\r\n\r\n get isEmpty() {\r\n if (this.items.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n addDefinedName(opts) {\r\n let item = new DefinedName(opts);\r\n let newLength = this.items.push(item);\r\n return this.items[newLength - 1];\r\n }\r\n\r\n addToXMLele(ele) {\r\n let dnEle = ele.ele('definedNames');\r\n this.items.forEach((dn) => {\r\n dn.addToXMLele(dnEle);\r\n });\r\n }\r\n}\r\nmodule.exports = DefinedNameCollection;"]} \ No newline at end of file diff --git a/distribution/lib/classes/emu.js b/distribution/lib/classes/emu.js new file mode 100644 index 00000000..ccad8ecc --- /dev/null +++ b/distribution/lib/classes/emu.js @@ -0,0 +1,114 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var EMU = function () { + + /** + * The EMU was created in order to be able to evenly divide in both English and Metric units + * @class EMU + * @param {String} Number of EMUs or string representation of length in mm, cm or in. i.e. '10.5mm' + * @property {Number} value Number of EMUs + * @returns {EMU} Number of EMUs + */ + function EMU(val) { + _classCallCheck(this, EMU); + + this._value; + this.value = val; + } + + _createClass(EMU, [{ + key: 'toInt', + + + /** + * @alias EMU.toInt + * @desc Returns the number of EMUs as integer + * @func EMU.toInt + * @returns {Number} Number of EMUs + */ + value: function toInt() { + return this._value; + } + + /** + * @alias EMU.toInch + * @desc Returns the number of Inches for the EMUs + * @func EMU.toInch + * @returns {Number} Number of Inches for the EMUs + */ + + }, { + key: 'toInch', + value: function toInch() { + return this._value / 914400; + } + + /** + * @alias EMU.toCM + * @desc Returns the number of Centimeters for the EMUs + * @func EMU.toCM + * @returns {Number} Number of Centimeters for the EMUs + */ + + }, { + key: 'toCM', + value: function toCM() { + return this._value / 360000; + } + }, { + key: 'value', + get: function get() { + return this._value; + }, + set: function set(val) { + if (val === undefined) { + this._value = 0; + } else if (typeof val === 'number') { + this._value = val ? parseInt(val) : 0; + } else if (typeof val === 'string') { + var re = new RegExp('[0-9]+(\.[0-9]+)?(mm|cm|in)'); + if (re.test(val) === true) { + var measure = parseFloat(/[0-9]+(\.[0-9]+)?/.exec(val)[0]); + var unit = /(mm|cm|in)/.exec(val)[0]; + + switch (unit) { + case 'mm': + this._value = parseInt(measure * 36000); + break; + + case 'cm': + this._value = parseInt(measure * 360000); + break; + + case 'in': + this._value = parseInt(measure * 914400); + break; + } + } else { + throw new TypeError('EMUs must be specified as whole integer EMUs or Floats immediately followed by unit of measure in cm, mm, or in. i.e. "1.5in"'); + } + } + } + }]); + + return EMU; +}(); + +module.exports = EMU; + +/* +M.4.1.1 EMU Unit of Measurement + +1 emu = 1/914400 in = 1/360000 cm + +Throughout ECMA-376, the EMU is used as a unit of measurement for length. An EMU is defined as follows: +The EMU was created in order to be able to evenly divide in both English and Metric units, in order to +avoid rounding errors during the calculation. The usage of EMUs also facilitates a more seamless system +switch and interoperability between different locales utilizing different units of measurement. +EMUs define an integer based, high precision coordinate system. +*/ +//# sourceMappingURL=emu.js.map \ No newline at end of file diff --git a/distribution/lib/classes/emu.js.map b/distribution/lib/classes/emu.js.map new file mode 100644 index 00000000..561b9dc4 --- /dev/null +++ b/distribution/lib/classes/emu.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/classes/emu.js"],"names":["EMU","val","_value","value","undefined","parseInt","re","RegExp","test","measure","parseFloat","exec","unit","TypeError","module","exports"],"mappings":";;;;;;IAAMA,G;;AAEF;;;;;;;AAOA,iBAAYC,GAAZ,EAAiB;AAAA;;AACb,aAAKC,MAAL;AACA,aAAKC,KAAL,GAAaF,GAAb;AACH;;;;;;AAoCD;;;;;;gCAMQ;AACJ,mBAAO,KAAKC,MAAZ;AACH;;AAED;;;;;;;;;iCAMS;AACL,mBAAO,KAAKA,MAAL,GAAc,MAArB;AACH;;AAED;;;;;;;;;+BAMO;AACH,mBAAO,KAAKA,MAAL,GAAc,MAArB;AACH;;;4BA9DW;AACR,mBAAO,KAAKA,MAAZ;AACH,S;0BAESD,G,EAAK;AACX,gBAAIA,QAAQG,SAAZ,EAAuB;AACnB,qBAAKF,MAAL,GAAc,CAAd;AACH,aAFD,MAEO,IAAI,OAAOD,GAAP,KAAe,QAAnB,EAA6B;AAChC,qBAAKC,MAAL,GAAcD,MAAMI,SAASJ,GAAT,CAAN,GAAsB,CAApC;AACH,aAFM,MAEA,IAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AAChC,oBAAIK,KAAK,IAAIC,MAAJ,CAAW,6BAAX,CAAT;AACA,oBAAID,GAAGE,IAAH,CAAQP,GAAR,MAAiB,IAArB,EAA2B;AACvB,wBAAIQ,UAAUC,WAAW,oBAAoBC,IAApB,CAAyBV,GAAzB,EAA8B,CAA9B,CAAX,CAAd;AACA,wBAAIW,OAAO,aAAaD,IAAb,CAAkBV,GAAlB,EAAuB,CAAvB,CAAX;;AAEA,4BAAQW,IAAR;AACA,6BAAK,IAAL;AACI,iCAAKV,MAAL,GAAcG,SAASI,UAAU,KAAnB,CAAd;AACA;;AAEJ,6BAAK,IAAL;AACI,iCAAKP,MAAL,GAAcG,SAASI,UAAU,MAAnB,CAAd;AACA;;AAEJ,6BAAK,IAAL;AACI,iCAAKP,MAAL,GAAcG,SAASI,UAAU,MAAnB,CAAd;AACA;AAXJ;AAaH,iBAjBD,MAiBO;AACH,0BAAM,IAAII,SAAJ,CAAc,+HAAd,CAAN;AACH;AACJ;AACJ;;;;;;AAiCLC,OAAOC,OAAP,GAAiBf,GAAjB;;AAEA","file":"emu.js","sourcesContent":["class EMU {\r\n \r\n /** \r\n * The EMU was created in order to be able to evenly divide in both English and Metric units\r\n * @class EMU\r\n * @param {String} Number of EMUs or string representation of length in mm, cm or in. i.e. '10.5mm'\r\n * @property {Number} value Number of EMUs\r\n * @returns {EMU} Number of EMUs \r\n */\r\n constructor(val) {\r\n this._value;\r\n this.value = val;\r\n }\r\n\r\n get value() {\r\n return this._value;\r\n }\r\n\r\n set value(val) {\r\n if (val === undefined) {\r\n this._value = 0;\r\n } else if (typeof val === 'number') {\r\n this._value = val ? parseInt(val) : 0; \r\n } else if (typeof val === 'string') {\r\n let re = new RegExp('[0-9]+(\\.[0-9]+)?(mm|cm|in)');\r\n if (re.test(val) === true) {\r\n let measure = parseFloat(/[0-9]+(\\.[0-9]+)?/.exec(val)[0]);\r\n let unit = /(mm|cm|in)/.exec(val)[0];\r\n\r\n switch (unit) {\r\n case 'mm':\r\n this._value = parseInt(measure * 36000);\r\n break;\r\n\r\n case 'cm':\r\n this._value = parseInt(measure * 360000);\r\n break;\r\n\r\n case 'in':\r\n this._value = parseInt(measure * 914400);\r\n break;\r\n }\r\n } else {\r\n throw new TypeError('EMUs must be specified as whole integer EMUs or Floats immediately followed by unit of measure in cm, mm, or in. i.e. \"1.5in\"');\r\n }\r\n } \r\n }\r\n\r\n /**\r\n * @alias EMU.toInt\r\n * @desc Returns the number of EMUs as integer\r\n * @func EMU.toInt\r\n * @returns {Number} Number of EMUs\r\n */\r\n toInt() {\r\n return this._value;\r\n }\r\n\r\n /**\r\n * @alias EMU.toInch\r\n * @desc Returns the number of Inches for the EMUs\r\n * @func EMU.toInch\r\n * @returns {Number} Number of Inches for the EMUs\r\n */\r\n toInch() {\r\n return this._value / 914400;\r\n }\r\n\r\n /**\r\n * @alias EMU.toCM\r\n * @desc Returns the number of Centimeters for the EMUs\r\n * @func EMU.toCM\r\n * @returns {Number} Number of Centimeters for the EMUs\r\n */\r\n toCM() {\r\n return this._value / 360000;\r\n }\r\n}\r\n\r\nmodule.exports = EMU;\r\n\r\n/*\r\nM.4.1.1 EMU Unit of Measurement\r\n\r\n1 emu = 1/914400 in = 1/360000 cm\r\n\r\nThroughout ECMA-376, the EMU is used as a unit of measurement for length. An EMU is defined as follows:\r\nThe EMU was created in order to be able to evenly divide in both English and Metric units, in order to \r\navoid rounding errors during the calculation. The usage of EMUs also facilitates a more seamless system \r\nswitch and interoperability between different locales utilizing different units of measurement. \r\nEMUs define an integer based, high precision coordinate system.\r\n*/"]} \ No newline at end of file diff --git a/distribution/lib/classes/point.js b/distribution/lib/classes/point.js new file mode 100644 index 00000000..e9dae603 --- /dev/null +++ b/distribution/lib/classes/point.js @@ -0,0 +1,21 @@ +"use strict"; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Point = +/** + * An XY coordinate point on the Worksheet with 0.0 being top left corner + * @class Point + * @property {Number} x X coordinate of Point + * @property {Number} y Y coordinate of Point + * @returns {Point} Excel Point + */ +function Point(x, y) { + _classCallCheck(this, Point); + + this.x = x; + this.y = y; +}; + +module.exports = Point; +//# sourceMappingURL=point.js.map \ No newline at end of file diff --git a/distribution/lib/classes/point.js.map b/distribution/lib/classes/point.js.map new file mode 100644 index 00000000..cd33cc17 --- /dev/null +++ b/distribution/lib/classes/point.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/classes/point.js"],"names":["Point","x","y","module","exports"],"mappings":";;;;IAAMA,K;AACF;;;;;;;AAOA,eAAYC,CAAZ,EAAeC,CAAf,EAAkB;AAAA;;AACd,SAAKD,CAAL,GAASA,CAAT;AACA,SAAKC,CAAL,GAASA,CAAT;AACH,C;;AAGLC,OAAOC,OAAP,GAAiBJ,KAAjB","file":"point.js","sourcesContent":["class Point { \r\n /** \r\n * An XY coordinate point on the Worksheet with 0.0 being top left corner\r\n * @class Point\r\n * @property {Number} x X coordinate of Point\r\n * @property {Number} y Y coordinate of Point\r\n * @returns {Point} Excel Point\r\n */\r\n constructor(x, y) { \r\n this.x = x;\r\n this.y = y;\r\n }\r\n}\r\n\r\nmodule.exports = Point;"]} \ No newline at end of file diff --git a/distribution/lib/column/column.js b/distribution/lib/column/column.js new file mode 100644 index 00000000..0da53de6 --- /dev/null +++ b/distribution/lib/column/column.js @@ -0,0 +1,139 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var utils = require('../utils.js'); + +var Column = function () { + /** + * Element representing an Excel Column + * @param {Number} col Column of cell + * @param {Worksheet} Worksheet that contains column + * @property {Worksheet} ws Worksheet that contains the specified Column + * @property {Boolean} collapsed States whether the column is collapsed if part of a group + * @property {Boolean} customWidth States whether or not the column as a width that is not default + * @property {Boolean} hidden States whether or not the specified column is hiddent + * @property {Number} max The greatest column if part of a range + * @property {Number} min The least column if part of a range + * @property {Number} outlineLevel The grouping leve of the Column + * @property {Number} style ID of style + * @property {Number} width Width of the Column + */ + function Column(col, ws) { + _classCallCheck(this, Column); + + this.ws = ws; + this.collapsed = null; + this.customWidth = null; + this.hidden = null; + this.max = col; + this.min = col; + this.outlineLevel = null; + this.style = null; + this.colWidth = null; + } + + _createClass(Column, [{ + key: 'setWidth', + + + /** + * @alias Column.setWidth + * @desc Sets teh width of a column + * @func Column.setWidth + * @param {Number} val New Width of column + * @returns {Column} Excel Column with attached methods + */ + value: function setWidth(w) { + this.width = w; + return this; + } + + /** + * @alias Column.hide + * @desc Sets a Column to be hidden + * @func Column.hide + * @returns {Column} Excel Column with attached methods + */ + + }, { + key: 'hide', + value: function hide() { + this.hidden = true; + return this; + } + + /** + * @alias Column.group + * @desc Adds column to the specified group + * @func Column.group + * @param {Number} level Level of excel grouping + * @param {Boolean} collapsed States wheter column grouping level should be collapsed by default + * @returns {Column} Excel Column with attached methods + */ + + }, { + key: 'group', + value: function group(level, collapsed) { + if (parseInt(level) === level) { + this.outlineLevel = level; + } else { + throw new TypeError('Column group level must be a positive integer'); + } + + if (collapsed === undefined) { + return this; + } + + if (typeof collapsed === 'boolean') { + this.collapsed = collapsed; + this.hidden = collapsed; + } else { + throw new TypeError('Column group collapse flag must be a boolean'); + } + + return this; + } + + /** + * @alias Column.freeze + * @desc Creates an Excel pane at the specificed column and Freezes that column from scolling + * @func Column.freeze + * @param {Number} jumptTo Specifies the column that the active pane will be scrolled to by default + * @returns {Column} Excel Column with attached methods + */ + + }, { + key: 'freeze', + value: function freeze(jumpTo) { + var o = this.ws.opts.sheetView.pane; + jumpTo = typeof jumpTo === 'number' && jumpTo > this.min ? jumpTo : this.min + 1; + o.state = 'frozen'; + o.xSplit = this.min; + o.activePane = 'bottomRight'; + o.ySplit === null ? o.topLeftCell = utils.getExcelCellRef(1, jumpTo) : o.topLeftCell = utils.getExcelCellRef(utils.getExcelRowCol(o.topLeftCell).row, jumpTo); + return this; + } + }, { + key: 'width', + get: function get() { + return this.colWidth; + }, + set: function set(w) { + if (typeof w === 'number') { + this.colWidth = w; + this.customWidth = true; + } else { + throw new TypeError('Column width must be a number'); + } + return this.colWidth; + } + }]); + + return Column; +}(); + +module.exports = Column; +//# sourceMappingURL=column.js.map \ No newline at end of file diff --git a/distribution/lib/column/column.js.map b/distribution/lib/column/column.js.map new file mode 100644 index 00000000..b3d3db08 --- /dev/null +++ b/distribution/lib/column/column.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/column/column.js"],"names":["utils","require","Column","col","ws","collapsed","customWidth","hidden","max","min","outlineLevel","style","colWidth","w","width","level","parseInt","TypeError","undefined","jumpTo","o","opts","sheetView","pane","state","xSplit","activePane","ySplit","topLeftCell","getExcelCellRef","getExcelRowCol","row","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,aAAR,CAAd;;IAEMC,M;AACF;;;;;;;;;;;;;;AAcA,oBAAYC,GAAZ,EAAiBC,EAAjB,EAAqB;AAAA;;AACjB,aAAKA,EAAL,GAAUA,EAAV;AACA,aAAKC,SAAL,GAAiB,IAAjB;AACA,aAAKC,WAAL,GAAmB,IAAnB;AACA,aAAKC,MAAL,GAAc,IAAd;AACA,aAAKC,GAAL,GAAWL,GAAX;AACA,aAAKM,GAAL,GAAWN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AAN,CAAsB7B,MAAM8B,cAAN,CAAqBV,EAAEQ,WAAvB,EAAoCG,GAA1D,EAA+DZ,MAA/D,CAFpB;AAGA,mBAAO,IAAP;AACH;;;4BAnFW;AACR,mBAAO,KAAKP,QAAZ;AACH,S;0BAESC,C,EAAG;AACT,gBAAI,OAAOA,CAAP,KAAa,QAAjB,EAA2B;AACvB,qBAAKD,QAAL,GAAgBC,CAAhB;AACA,qBAAKP,WAAL,GAAmB,IAAnB;AACH,aAHD,MAGO;AACH,sBAAM,IAAIW,SAAJ,CAAc,+BAAd,CAAN;AACH;AACD,mBAAO,KAAKL,QAAZ;AACH;;;;;;AA0ELoB,OAAOC,OAAP,GAAiB/B,MAAjB","file":"column.js","sourcesContent":["const utils = require('../utils.js');\r\n\r\nclass Column {\r\n /**\r\n * Element representing an Excel Column\r\n * @param {Number} col Column of cell\r\n * @param {Worksheet} Worksheet that contains column\r\n * @property {Worksheet} ws Worksheet that contains the specified Column\r\n * @property {Boolean} collapsed States whether the column is collapsed if part of a group\r\n * @property {Boolean} customWidth States whether or not the column as a width that is not default\r\n * @property {Boolean} hidden States whether or not the specified column is hiddent\r\n * @property {Number} max The greatest column if part of a range\r\n * @property {Number} min The least column if part of a range\r\n * @property {Number} outlineLevel The grouping leve of the Column\r\n * @property {Number} style ID of style\r\n * @property {Number} width Width of the Column\r\n */\r\n constructor(col, ws) {\r\n this.ws = ws;\r\n this.collapsed = null;\r\n this.customWidth = null;\r\n this.hidden = null;\r\n this.max = col;\r\n this.min = col;\r\n this.outlineLevel = null;\r\n this.style = null;\r\n this.colWidth = null;\r\n }\r\n\r\n get width() {\r\n return this.colWidth;\r\n }\r\n\r\n set width(w) {\r\n if (typeof w === 'number') {\r\n this.colWidth = w;\r\n this.customWidth = true;\r\n } else {\r\n throw new TypeError('Column width must be a number');\r\n }\r\n return this.colWidth;\r\n }\r\n\r\n /**\r\n * @alias Column.setWidth\r\n * @desc Sets teh width of a column\r\n * @func Column.setWidth\r\n * @param {Number} val New Width of column\r\n * @returns {Column} Excel Column with attached methods\r\n */\r\n setWidth(w) {\r\n this.width = w;\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Column.hide\r\n * @desc Sets a Column to be hidden\r\n * @func Column.hide\r\n * @returns {Column} Excel Column with attached methods\r\n */\r\n hide() {\r\n this.hidden = true;\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Column.group\r\n * @desc Adds column to the specified group\r\n * @func Column.group\r\n * @param {Number} level Level of excel grouping\r\n * @param {Boolean} collapsed States wheter column grouping level should be collapsed by default\r\n * @returns {Column} Excel Column with attached methods\r\n */\r\n group(level, collapsed) {\r\n if (parseInt(level) === level) {\r\n this.outlineLevel = level;\r\n } else {\r\n throw new TypeError('Column group level must be a positive integer');\r\n }\r\n\r\n if (collapsed === undefined) {\r\n return this;\r\n }\r\n\r\n if (typeof collapsed === 'boolean') {\r\n this.collapsed = collapsed;\r\n this.hidden = collapsed;\r\n } else {\r\n throw new TypeError('Column group collapse flag must be a boolean');\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Column.freeze\r\n * @desc Creates an Excel pane at the specificed column and Freezes that column from scolling\r\n * @func Column.freeze\r\n * @param {Number} jumptTo Specifies the column that the active pane will be scrolled to by default\r\n * @returns {Column} Excel Column with attached methods\r\n */\r\n freeze(jumpTo) {\r\n let o = this.ws.opts.sheetView.pane;\r\n jumpTo = typeof jumpTo === 'number' && jumpTo > this.min ? jumpTo : this.min + 1;\r\n o.state = 'frozen';\r\n o.xSplit = this.min;\r\n o.activePane = 'bottomRight';\r\n o.ySplit === null ?\r\n o.topLeftCell = utils.getExcelCellRef(1, jumpTo) :\r\n o.topLeftCell = utils.getExcelCellRef(utils.getExcelRowCol(o.topLeftCell).row, jumpTo);\r\n return this;\r\n }\r\n}\r\n\r\nmodule.exports = Column;"]} \ No newline at end of file diff --git a/distribution/lib/column/index.js b/distribution/lib/column/index.js new file mode 100644 index 00000000..b59cb10e --- /dev/null +++ b/distribution/lib/column/index.js @@ -0,0 +1,25 @@ +'use strict'; + +var Cell = require('../cell/cell.js'); +var Row = require('../row/row.js'); +var Column = require('../column/column.js'); +var utils = require('../utils.js'); + +/** + * Module repesenting a Column Accessor + * @alias Worksheet.column + * @namespace + * @func Worksheet.column + * @desc Access a column in order to manipulate values + * @param {Number} col Column of top left cell + * @returns {Column} + */ +var colAccessor = function colAccessor(ws, col) { + if (!(ws.cols[col] instanceof Column)) { + ws.cols[col] = new Column(col, ws); + } + return ws.cols[col]; +}; + +module.exports = colAccessor; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/column/index.js.map b/distribution/lib/column/index.js.map new file mode 100644 index 00000000..8a53459c --- /dev/null +++ b/distribution/lib/column/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/column/index.js"],"names":["Cell","require","Row","Column","utils","colAccessor","ws","col","cols","module","exports"],"mappings":";;AAAA,IAAMA,OAAOC,QAAQ,iBAAR,CAAb;AACA,IAAMC,MAAMD,QAAQ,eAAR,CAAZ;AACA,IAAME,SAASF,QAAQ,qBAAR,CAAf;AACA,IAAMG,QAAQH,QAAQ,aAAR,CAAd;;AAEA;;;;;;;;;AASA,IAAII,cAAc,SAAdA,WAAc,CAACC,EAAD,EAAKC,GAAL,EAAa;AAC3B,QAAI,EAAED,GAAGE,IAAH,CAAQD,GAAR,aAAwBJ,MAA1B,CAAJ,EAAuC;AACnCG,WAAGE,IAAH,CAAQD,GAAR,IAAe,IAAIJ,MAAJ,CAAWI,GAAX,EAAgBD,EAAhB,CAAf;AACH;AACD,WAAOA,GAAGE,IAAH,CAAQD,GAAR,CAAP;AACH,CALD;;AAOAE,OAAOC,OAAP,GAAiBL,WAAjB","file":"index.js","sourcesContent":["const Cell = require('../cell/cell.js');\r\nconst Row = require('../row/row.js');\r\nconst Column = require('../column/column.js');\r\nconst utils = require('../utils.js');\r\n\r\n/**\r\n * Module repesenting a Column Accessor\r\n * @alias Worksheet.column\r\n * @namespace\r\n * @func Worksheet.column\r\n * @desc Access a column in order to manipulate values\r\n * @param {Number} col Column of top left cell\r\n * @returns {Column}\r\n */\r\nlet colAccessor = (ws, col) => {\r\n if (!(ws.cols[col] instanceof Column)) {\r\n ws.cols[col] = new Column(col, ws);\r\n }\r\n return ws.cols[col];\r\n};\r\n\r\nmodule.exports = colAccessor;"]} \ No newline at end of file diff --git a/distribution/lib/drawing/drawing.js b/distribution/lib/drawing/drawing.js new file mode 100644 index 00000000..522173a9 --- /dev/null +++ b/distribution/lib/drawing/drawing.js @@ -0,0 +1,131 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var CTMarker = require('../classes/ctMarker.js'); +var Point = require('../classes/point.js'); +var EMU = require('../classes/emu.js'); + +var Drawing = function () { + /** + * Element representing an Excel Drawing superclass + * @property {String} anchorType Proprty for type of anchor. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor' + * @property {CTMarker} anchorFrom Property for the top left corner position of drawing + * @property {CTMarker} anchorTo Property for the bottom left corner position of drawing + * @property {String} editAs Property that states how to interact with the Drawing in Excel. One of 'absolute', 'oneCell', 'twoCell' + * @property {Point} _position Internal property for position on Excel Worksheet when drawing type is absoluteAnchor + * @returns {Drawing} Excel Drawing + */ + function Drawing() { + _classCallCheck(this, Drawing); + + this._anchorType = null; + this._anchorFrom = null; + this._anchorTo = null; + this._editAs = null; + this._position = null; + } + + _createClass(Drawing, [{ + key: 'anchor', + + + /** + * @alias Drawing.achor + * @desc Sets the postion and anchor properties of the Drawing + * @func Drawing.achor + * @param {String} type Anchor type of drawing + * @param {Object} from Properties for achorFrom property + * @param {Number} from.col Left edge of drawing will align with left edge of this column + * @param {String} from.colOff Offset. Drawing will be shifted to the right the specified amount. Float followed by measure [0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm' + * @param {Number} from.row Top edge of drawing will align with top edge of this row + * @param {String} from.rowOff Offset. Drawing will be shifted down the specified amount. Float followed by measure [0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm' + * @param {Object} to Properties for anchorTo property + * @param {Number} to.col Left edge of drawing will align with left edge of this column + * @param {String} to.colOff Offset. Drawing will be shifted to the right the specified amount. Float followed by measure [0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm' + * @param {Number} to.row Top edge of drawing will align with top edge of this row + * @param {String} to.rowOff Offset. Drawing will be shifted down the specified amount. Float followed by measure [0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm' + * @returns {Drawing} Excel Drawing with attached methods + */ + value: function anchor(type, from, to) { + if (type === 'twoCellAnchor') { + if (from === undefined || to === undefined) { + throw new TypeError('twoCellAnchor requires both from and two markers'); + } + this.editAs = 'oneCell'; + } + this.anchorType = type; + this.anchorFrom = from; + this.anchorTo = to; + return this; + } + + /** + * @alias Drawing.position + * @desc The position of the top left corner of the image on the Worksheet + * @func Drawing.position + * @param {ST_PositiveUniversalMeasure} cx Postion from left of Worksheet edge + * @param {ST_PositiveUniversalMeasure} cy Postion from top of Worksheet edge + */ + + }, { + key: 'position', + value: function position(cx, cy) { + this.anchorType = 'absoluteAnchor'; + var thisCx = new EMU(cx); + var thisCy = new EMU(cy); + this._position = new Point(thisCx.value, thisCy.value); + } + }, { + key: 'anchorType', + get: function get() { + return this._anchorType; + }, + set: function set(type) { + var types = ['absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor']; + if (types.indexOf(type) < 0) { + throw new TypeError('Invalid option for anchor type. anchorType must be one of ' + types.join(', ')); + } + this._anchorType = type; + } + }, { + key: 'editAs', + get: function get() { + return this._editAs; + }, + set: function set(val) { + var types = ['absolute', 'oneCell', 'twoCell']; + if (types.indexOf(val) < 0) { + throw new TypeError('Invalid option for editAs. editAs must be one of ' + types.join(', ')); + } + this._editAs = val; + } + }, { + key: 'anchorFrom', + get: function get() { + return this._anchorFrom; + }, + set: function set(obj) { + if (obj !== undefined && obj instanceof Object) { + this._anchorFrom = new CTMarker(obj.col - 1, obj.colOff, obj.row - 1, obj.rowOff); + } + } + }, { + key: 'anchorTo', + get: function get() { + return this._anchorTo; + }, + set: function set(obj) { + if (obj !== undefined && obj instanceof Object) { + this._anchorTo = new CTMarker(obj.col - 1, obj.colOff, obj.row - 1, obj.rowOff); + } + } + }]); + + return Drawing; +}(); + +module.exports = Drawing; +//# sourceMappingURL=drawing.js.map \ No newline at end of file diff --git a/distribution/lib/drawing/drawing.js.map b/distribution/lib/drawing/drawing.js.map new file mode 100644 index 00000000..9695a756 --- /dev/null +++ b/distribution/lib/drawing/drawing.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/drawing/drawing.js"],"names":["CTMarker","require","Point","EMU","Drawing","_anchorType","_anchorFrom","_anchorTo","_editAs","_position","type","from","to","undefined","TypeError","editAs","anchorType","anchorFrom","anchorTo","cx","cy","thisCx","thisCy","value","types","indexOf","join","val","obj","Object","col","colOff","row","rowOff","module","exports"],"mappings":";;;;;;AAAA,IAAMA,WAAWC,QAAQ,wBAAR,CAAjB;AACA,IAAMC,QAAQD,QAAQ,qBAAR,CAAd;AACA,IAAME,MAAMF,QAAQ,mBAAR,CAAZ;;IAEMG,O;AACF;;;;;;;;;AASA,uBAAc;AAAA;;AACV,aAAKC,WAAL,GAAmB,IAAnB;AACA,aAAKC,WAAL,GAAmB,IAAnB;AACA,aAAKC,SAAL,GAAiB,IAAjB;AACA,aAAKC,OAAL,GAAe,IAAf;AACA,aAAKC,SAAL,GAAiB,IAAjB;AACH;;;;;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X,CAApE,CAAN;AACH;AACD,iBAAKlB,OAAL,GAAemB,GAAf;AACH;;;4BAEgB;AACb,mBAAO,KAAKrB,WAAZ;AACH,S;0BACcsB,G,EAAK;AAChB,gBAAIA,QAAQf,SAAR,IAAqBe,eAAeC,MAAxC,EAAgD;AAC5C,qBAAKvB,WAAL,GAAmB,IAAIN,QAAJ,CAAa4B,IAAIE,GAAJ,GAAU,CAAvB,EAA0BF,IAAIG,MAA9B,EAAsCH,IAAII,GAAJ,GAAU,CAAhD,EAAmDJ,IAAIK,MAAvD,CAAnB;AACH;AACJ;;;4BAEc;AACX,mBAAO,KAAK1B,SAAZ;AACH,S;0BACYqB,G,EAAK;AACd,gBAAIA,QAAQf,SAAR,IAAqBe,eAAeC,MAAxC,EAAgD;AAC5C,qBAAKtB,SAAL,GAAiB,IAAIP,QAAJ,CAAa4B,IAAIE,GAAJ,GAAU,CAAvB,EAA0BF,IAAIG,MAA9B,EAAsCH,IAAII,GAAJ,GAAU,CAAhD,EAAmDJ,IAAIK,MAAvD,CAAjB;AACH;AACJ;;;;;;AA+CLC,OAAOC,OAAP,GAAiB/B,OAAjB","file":"drawing.js","sourcesContent":["const CTMarker = require('../classes/ctMarker.js');\r\nconst Point = require('../classes/point.js');\r\nconst EMU = require('../classes/emu.js');\r\n\r\nclass Drawing {\r\n /**\r\n * Element representing an Excel Drawing superclass\r\n * @property {String} anchorType Proprty for type of anchor. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor'\r\n * @property {CTMarker} anchorFrom Property for the top left corner position of drawing\r\n * @property {CTMarker} anchorTo Property for the bottom left corner position of drawing\r\n * @property {String} editAs Property that states how to interact with the Drawing in Excel. One of 'absolute', 'oneCell', 'twoCell'\r\n * @property {Point} _position Internal property for position on Excel Worksheet when drawing type is absoluteAnchor\r\n * @returns {Drawing} Excel Drawing \r\n */\r\n constructor() {\r\n this._anchorType = null;\r\n this._anchorFrom = null;\r\n this._anchorTo = null;\r\n this._editAs = null;\r\n this._position = null;\r\n }\r\n\r\n get anchorType() {\r\n return this._anchorType;\r\n }\r\n set anchorType(type) {\r\n let types = ['absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor'];\r\n if (types.indexOf(type) < 0) {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of ' + types.join(', '));\r\n }\r\n this._anchorType = type;\r\n }\r\n\r\n get editAs() {\r\n return this._editAs;\r\n }\r\n set editAs(val) {\r\n let types = ['absolute', 'oneCell', 'twoCell'];\r\n if (types.indexOf(val) < 0) {\r\n throw new TypeError('Invalid option for editAs. editAs must be one of ' + types.join(', '));\r\n }\r\n this._editAs = val;\r\n }\r\n\r\n get anchorFrom() {\r\n return this._anchorFrom;\r\n }\r\n set anchorFrom(obj) {\r\n if (obj !== undefined && obj instanceof Object) {\r\n this._anchorFrom = new CTMarker(obj.col - 1, obj.colOff, obj.row - 1, obj.rowOff);\r\n }\r\n }\r\n\r\n get anchorTo() {\r\n return this._anchorTo;\r\n }\r\n set anchorTo(obj) {\r\n if (obj !== undefined && obj instanceof Object) {\r\n this._anchorTo = new CTMarker(obj.col - 1, obj.colOff, obj.row - 1, obj.rowOff);\r\n }\r\n }\r\n\r\n /**\r\n * @alias Drawing.achor\r\n * @desc Sets the postion and anchor properties of the Drawing\r\n * @func Drawing.achor\r\n * @param {String} type Anchor type of drawing\r\n * @param {Object} from Properties for achorFrom property\r\n * @param {Number} from.col Left edge of drawing will align with left edge of this column\r\n * @param {String} from.colOff Offset. Drawing will be shifted to the right the specified amount. Float followed by measure [0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm'\r\n * @param {Number} from.row Top edge of drawing will align with top edge of this row\r\n * @param {String} from.rowOff Offset. Drawing will be shifted down the specified amount. Float followed by measure [0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm'\r\n * @param {Object} to Properties for anchorTo property\r\n * @param {Number} to.col Left edge of drawing will align with left edge of this column\r\n * @param {String} to.colOff Offset. Drawing will be shifted to the right the specified amount. Float followed by measure [0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm'\r\n * @param {Number} to.row Top edge of drawing will align with top edge of this row\r\n * @param {String} to.rowOff Offset. Drawing will be shifted down the specified amount. Float followed by measure [0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi). i.e '10.5mm'\r\n * @returns {Drawing} Excel Drawing with attached methods\r\n */\r\n anchor(type, from, to) {\r\n if (type === 'twoCellAnchor') {\r\n if (from === undefined || to === undefined) {\r\n throw new TypeError('twoCellAnchor requires both from and two markers');\r\n }\r\n this.editAs = 'oneCell';\r\n }\r\n this.anchorType = type;\r\n this.anchorFrom = from;\r\n this.anchorTo = to;\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Drawing.position\r\n * @desc The position of the top left corner of the image on the Worksheet\r\n * @func Drawing.position\r\n * @param {ST_PositiveUniversalMeasure} cx Postion from left of Worksheet edge\r\n * @param {ST_PositiveUniversalMeasure} cy Postion from top of Worksheet edge\r\n */\r\n position(cx, cy) {\r\n this.anchorType = 'absoluteAnchor';\r\n let thisCx = new EMU(cx);\r\n let thisCy = new EMU(cy);\r\n this._position = new Point(thisCx.value, thisCy.value);\r\n }\r\n}\r\n\r\nmodule.exports = Drawing;"]} \ No newline at end of file diff --git a/distribution/lib/drawing/headerFooterPicture.js b/distribution/lib/drawing/headerFooterPicture.js new file mode 100644 index 00000000..b8a80f4e --- /dev/null +++ b/distribution/lib/drawing/headerFooterPicture.js @@ -0,0 +1,170 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Drawing = require('./drawing.js'); +var path = require('path'); +var imgsz = require('image-size'); +var mime = require('mime'); +var uniqueId = require('lodash.uniqueid'); + +var EMU = require('../classes/emu.js'); +var xmlbuilder = require('xmlbuilder'); + +var headerFooterPicture = function (_Drawing) { + _inherits(headerFooterPicture, _Drawing); + + /** + * Element representing an Excel Picture subclass of Drawing + * @property {String} kind Kind of picture (currently only image is supported) + * @property {String} type ooxml schema + * @property {String} imagePath Filesystem path to image + * @property {Buffer} image Buffer with image + * @property {String} contentType Mime type of image + * @property {String} description Description of image + * @property {String} title Title of image + * @property {String} id ID of image + * @property {String} noGrp pickLocks property + * @property {String} noSelect pickLocks property + * @property {String} noRot pickLocks property + * @property {String} noChangeAspect pickLocks property + * @property {String} noMove pickLocks property + * @property {String} noResize pickLocks property + * @property {String} noEditPoints pickLocks property + * @property {String} noAdjustHandles pickLocks property + * @property {String} noChangeArrowheads pickLocks property + * @property {String} noChangeShapeType pickLocks property + * @returns {Picture} Excel Picture pickLocks property + */ + function headerFooterPicture(opts) { + _classCallCheck(this, headerFooterPicture); + + var _this = _possibleConstructorReturn(this, (headerFooterPicture.__proto__ || Object.getPrototypeOf(headerFooterPicture)).call(this)); + + _this.kind = 'image'; + _this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'; + _this.imagePath = opts.path; + _this.image = opts.image; + + _this._name = _this.image ? opts.name || uniqueId('image-') : opts.name || path.basename(_this.imagePath); + + var size = imgsz(_this.imagePath || _this.image); + + _this._pxWidth = size.width; + _this._pxHeight = size.height; + + _this._extension = _this.image ? size.type : path.extname(_this.imagePath).substr(1); + + _this.contentType = mime.getType(_this._extension); + _this.scale = opts.scale; + + _this._descr = null; + _this._title = null; + _this._id; + // picLocks §20.1.2.2.31 picLocks (Picture Locks) + _this.noGrp; + _this.noSelect; + _this.noRot; + _this.noChangeAspect = true; + _this.noMove; + _this.noResize; + _this.noEditPoints; + _this.noAdjustHandles; + _this.noChangeArrowheads; + _this.noChangeShapeType; + return _this; + } + + _createClass(headerFooterPicture, [{ + key: 'addToXMLele', + + + /** + * @alias Picture.addToXMLele + * @desc When generating Workbook output, attaches pictures to the drawings xml file + * @func Picture.addToXMLele + * @param {xmlbuilder.Element} xmlele Element object of the xmlbuilder module + */ + value: function addToXMLele(xmlele) { + var headerFooterPositions = ['LF', 'CF', 'RF', 'LH', 'CH', 'RH']; + var ind = headerFooterPositions.indexOf(this.position); + + //Size calculations see: https://stackoverflow.com/a/14369133/14456373, http://lcorneliussen.de/raw/dashboards/ooxml/ + var _scale = 1.0;if (this.scale) _scale = this.scale; + var x_width = Math.round(this.width * _scale / 12700); + var x_height = Math.round(this.height * _scale / 12700); + + var sh = xmlele.ele('v:shape'); + sh.att('id', this.position).att('o:spid', '_x0000_s' + 1025 + ind).att('type', '#_x0000_t75').att('style', 'position:absolute;margin-left:0;margin-top:0;width:' + x_width + ';height:' + x_height + ';z-index:' + (ind + 1)); + sh.ele('v:imagedata').att('o:relid', this.rId).att('o:title', 'image' + this.id); + sh.ele('o:lock').att('v:ext', 'edit').att('rotation', 't'); + } + }, { + key: 'name', + get: function get() { + return this._name; + }, + set: function set(newName) { + this._name = newName; + } + }, { + key: 'id', + get: function get() { + return this._id; + }, + set: function set(id) { + this._id = id; + } + }, { + key: 'rId', + get: function get() { + return 'rId' + this._id; + } + }, { + key: 'description', + get: function get() { + return this._descr !== null ? this._descr : this._name; + }, + set: function set(desc) { + this._descr = desc; + } + }, { + key: 'title', + get: function get() { + return this._title !== null ? this._title : this._name; + }, + set: function set(title) { + this._title = title; + } + }, { + key: 'extension', + get: function get() { + return this._extension; + } + }, { + key: 'width', + get: function get() { + var inWidth = this._pxWidth / 96; + var emu = new EMU(inWidth + 'in'); + return emu.value; + } + }, { + key: 'height', + get: function get() { + var inHeight = this._pxHeight / 96; + var emu = new EMU(inHeight + 'in'); + return emu.value; + } + }]); + + return headerFooterPicture; +}(Drawing); + +module.exports = headerFooterPicture; +//# sourceMappingURL=headerFooterPicture.js.map \ No newline at end of file diff --git a/distribution/lib/drawing/headerFooterPicture.js.map b/distribution/lib/drawing/headerFooterPicture.js.map new file mode 100644 index 00000000..7fdd93ee --- /dev/null +++ b/distribution/lib/drawing/headerFooterPicture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/drawing/headerFooterPicture.js"],"names":["Drawing","require","path","imgsz","mime","uniqueId","EMU","xmlbuilder","headerFooterPicture","opts","kind","type","imagePath","image","_name","name","basename","size","_pxWidth","width","_pxHeight","height","_extension","extname","substr","contentType","getType","scale","_descr","_title","_id","noGrp","noSelect","noRot","noChangeAspect","noMove","noResize","noEditPoints","noAdjustHandles","noChangeArrowheads","noChangeShapeType","xmlele","headerFooterPositions","ind","indexOf","position","_scale","x_width","Math","round","x_height","sh","ele","att","rId","id","newName","desc","title","inWidth","emu","value","inHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,OAAOD,QAAQ,MAAR,CAAb;AACA,IAAME,QAAQF,QAAQ,YAAR,CAAd;AACA,IAAMG,OAAOH,QAAQ,MAAR,CAAb;AACA,IAAMI,WAAWJ,QAAQ,iBAAR,CAAjB;;AAEA,IAAMK,MAAML,QAAQ,mBAAR,CAAZ;AACA,IAAMM,aAAaN,QAAQ,YAAR,CAAnB;;IAEMO,mB;;;AACF;;;;;;;;;;;;;;;;;;;;;;AAsBA,i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AAc6B,IAAd;AACH;;;4BAEW;AACR,mBAAO,KAAK5B,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAKf,KAAjD;AACH,S;0BACS4C,K,EAAO;AACb,iBAAK7B,MAAL,GAAc6B,KAAd;AACH;;;4BAEe;AACZ,mBAAO,KAAKpC,UAAZ;AACH;;;4BAEW;AACR,gBAAIqC,UAAU,KAAKzC,QAAL,GAAgB,EAA9B;AACA,gBAAI0C,MAAM,IAAItD,GAAJ,CAAQqD,UAAU,IAAlB,CAAV;AACA,mBAAOC,IAAIC,KAAX;AACH;;;4BAEY;AACT,gBAAIC,WAAW,KAAK1C,SAAL,GAAiB,EAAhC;AACA,gBAAIwC,MAAM,IAAItD,GAAJ,CAAQwD,WAAW,IAAnB,CAAV;AACA,mBAAOF,IAAIC,KAAX;AACH;;;;EA3G6B7D,O;;AAqIlC+D,OAAOC,OAAP,GAAiBxD,mBAAjB","file":"headerFooterPicture.js","sourcesContent":["const Drawing = require('./drawing.js');\nconst path = require('path');\nconst imgsz = require('image-size');\nconst mime = require('mime');\nconst uniqueId = require('lodash.uniqueid');\n\nconst EMU = require('../classes/emu.js');\nconst xmlbuilder = require('xmlbuilder');\n\nclass headerFooterPicture extends Drawing {\n /**\n * Element representing an Excel Picture subclass of Drawing\n * @property {String} kind Kind of picture (currently only image is supported)\n * @property {String} type ooxml schema\n * @property {String} imagePath Filesystem path to image\n * @property {Buffer} image Buffer with image\n * @property {String} contentType Mime type of image\n * @property {String} description Description of image\n * @property {String} title Title of image\n * @property {String} id ID of image\n * @property {String} noGrp pickLocks property\n * @property {String} noSelect pickLocks property\n * @property {String} noRot pickLocks property\n * @property {String} noChangeAspect pickLocks property\n * @property {String} noMove pickLocks property\n * @property {String} noResize pickLocks property\n * @property {String} noEditPoints pickLocks property\n * @property {String} noAdjustHandles pickLocks property\n * @property {String} noChangeArrowheads pickLocks property\n * @property {String} noChangeShapeType pickLocks property\n * @returns {Picture} Excel Picture pickLocks property\n */\n constructor(opts) {\n super();\n this.kind = 'image';\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image';\n this.imagePath = opts.path;\n this.image = opts.image;\n\n this._name = this.image ?\n opts.name || uniqueId('image-') :\n opts.name || path.basename(this.imagePath);\n\n const size = imgsz(this.imagePath || this.image);\n\n this._pxWidth = size.width;\n this._pxHeight = size.height;\n\n this._extension = this.image ?\n size.type :\n path.extname(this.imagePath).substr(1);\n\n this.contentType = mime.getType(this._extension);\n this.scale = opts.scale;\n\n this._descr = null;\n this._title = null;\n this._id;\n // picLocks §20.1.2.2.31 picLocks (Picture Locks)\n this.noGrp;\n this.noSelect;\n this.noRot;\n this.noChangeAspect = true;\n this.noMove;\n this.noResize;\n this.noEditPoints;\n this.noAdjustHandles;\n this.noChangeArrowheads;\n this.noChangeShapeType;\n }\n\n get name() {\n return this._name;\n }\n set name(newName) {\n this._name = newName;\n }\n get id() {\n return this._id;\n }\n set id(id) {\n this._id = id;\n }\n\n get rId() {\n return 'rId' + this._id;\n }\n\n get description() {\n return this._descr !== null ? this._descr : this._name;\n }\n set description(desc) {\n this._descr = desc;\n }\n\n get title() {\n return this._title !== null ? this._title : this._name;\n }\n set title(title) {\n this._title = title;\n }\n\n get extension() {\n return this._extension;\n }\n\n get width() {\n let inWidth = this._pxWidth / 96;\n let emu = new EMU(inWidth + 'in');\n return emu.value;\n }\n\n get height() {\n let inHeight = this._pxHeight / 96;\n let emu = new EMU(inHeight + 'in');\n return emu.value;\n }\n\n /**\n * @alias Picture.addToXMLele\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\n * @func Picture.addToXMLele\n * @param {xmlbuilder.Element} xmlele Element object of the xmlbuilder module\n */\n addToXMLele(xmlele) {\n const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH'];\n var ind = headerFooterPositions.indexOf(this.position);\n \n //Size calculations see: https://stackoverflow.com/a/14369133/14456373, http://lcorneliussen.de/raw/dashboards/ooxml/\n let _scale = 1.0; if(this.scale) _scale = this.scale; \n let x_width = Math.round((this.width * _scale) / 12700); \n let x_height = Math.round((this.height * _scale) / 12700);\n \n\n var sh = xmlele.ele('v:shape');\n sh.att('id', this.position).att('o:spid', '_x0000_s' + 1025 + ind).att('type', '#_x0000_t75')\n .att('style', `position:absolute;margin-left:0;margin-top:0;width:${x_width};height:${x_height};z-index:${ind+1}`);\n sh.ele('v:imagedata').att('o:relid', this.rId).att('o:title', 'image' + this.id)\n sh.ele('o:lock').att('v:ext', 'edit').att('rotation', 't');\n }\n}\n\nmodule.exports = headerFooterPicture;"]} \ No newline at end of file diff --git a/distribution/lib/drawing/index.js b/distribution/lib/drawing/index.js new file mode 100644 index 00000000..2340effd --- /dev/null +++ b/distribution/lib/drawing/index.js @@ -0,0 +1,54 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Drawing = require('./drawing.js'); +var Picture = require('./picture.js'); +var headerFooterPicture = require('./headerFooterPicture.js'); + +var DrawingCollection = function () { + function DrawingCollection() { + _classCallCheck(this, DrawingCollection); + + this.drawings = []; + } + + _createClass(DrawingCollection, [{ + key: 'add', + value: function add(opts) { + switch (opts.type) { + case 'picture': + var newPic = new Picture(opts); + this.drawings.push(newPic); + return newPic; + case 'headerFooterPicture': + var xPic = new headerFooterPicture(opts); + this.drawings.push(xPic); + return xPic; + default: + throw new TypeError('this option is not yet supported'); + } + } + }, { + key: 'length', + get: function get() { + return this.drawings.length; + } + }, { + key: 'isEmpty', + get: function get() { + if (this.drawings.length === 0) { + return true; + } else { + return false; + } + } + }]); + + return DrawingCollection; +}(); + +module.exports = { DrawingCollection: DrawingCollection, Drawing: Drawing, Picture: Picture, headerFooterPicture: headerFooterPicture }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/drawing/index.js.map b/distribution/lib/drawing/index.js.map new file mode 100644 index 00000000..52bfa6b3 --- /dev/null +++ b/distribution/lib/drawing/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/drawing/index.js"],"names":["Drawing","require","Picture","headerFooterPicture","DrawingCollection","drawings","opts","type","newPic","push","xPic","TypeError","length","module","exports"],"mappings":";;;;;;AAAA,IAAIA,UAAUC,QAAQ,cAAR,CAAd;AACA,IAAIC,UAAUD,QAAQ,cAAR,CAAd;AACA,IAAIE,sBAAsBF,QAAQ,0BAAR,CAA1B;;IAEMG,iB;AACF,iCAAc;AAAA;;AACV,aAAKC,QAAL,GAAgB,EAAhB;AACH;;;;4BAMGC,I,EAAM;AACN,oBAAQA,KAAKC,IAAb;AACA,qBAAK,SAAL;AACI,wBAAIC,SAAS,IAAIN,OAAJ,CAAYI,IAAZ,CAAb;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBD,MAAnB;AACA,2BAAOA,MAAP;AACJ,qBAAK,qBAAL;AACI,wBAAIE,OAAO,IAAIP,mBAAJ,CAAwBG,IAAxB,CAAX;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBC,IAAnB;AACA,2BAAOA,IAAP;AACJ;AACI,0BAAM,IAAIC,SAAJ,CAAc,kCAAd,CAAN;AAVJ;AAYH;;;4BAjBY;AACT,mBAAO,KAAKN,QAAL,CAAcO,MAArB;AACH;;;4BAiBa;AACV,gBAAI,KAAKP,QAAL,CAAcO,MAAd,KAAyB,CAA7B,EAAgC;AAC5B,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAGLC,OAAOC,OAAP,GAAiB,EAAEV,oCAAF,EAAqBJ,gBAArB,EAA8BE,gBAA9B,EAAuCC,wCAAvC,EAAjB","file":"index.js","sourcesContent":["let Drawing = require('./drawing.js');\r\nlet Picture = require('./picture.js');\r\nlet headerFooterPicture = require('./headerFooterPicture.js')\r\n\r\nclass DrawingCollection {\r\n constructor() {\r\n this.drawings = [];\r\n }\r\n\r\n get length() {\r\n return this.drawings.length;\r\n }\r\n\r\n add(opts) {\r\n switch (opts.type) {\r\n case 'picture':\r\n let newPic = new Picture(opts);\r\n this.drawings.push(newPic);\r\n return newPic;\r\n case 'headerFooterPicture':\r\n let xPic = new headerFooterPicture(opts);\r\n this.drawings.push(xPic );\r\n return xPic;\r\n default:\r\n throw new TypeError('this option is not yet supported');\r\n }\r\n }\r\n\r\n get isEmpty() {\r\n if (this.drawings.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = { DrawingCollection, Drawing, Picture, headerFooterPicture };\r\n"]} \ No newline at end of file diff --git a/distribution/lib/drawing/picture.js b/distribution/lib/drawing/picture.js new file mode 100644 index 00000000..72004913 --- /dev/null +++ b/distribution/lib/drawing/picture.js @@ -0,0 +1,230 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Drawing = require('./drawing.js'); +var path = require('path'); +var imgsz = require('image-size'); +var mime = require('mime'); +var uniqueId = require('lodash.uniqueid'); + +var EMU = require('../classes/emu.js'); +var xmlbuilder = require('xmlbuilder'); + +var Picture = function (_Drawing) { + _inherits(Picture, _Drawing); + + /** + * Element representing an Excel Picture subclass of Drawing + * @property {String} kind Kind of picture (currently only image is supported) + * @property {String} type ooxml schema + * @property {String} imagePath Filesystem path to image + * @property {Buffer} image Buffer with image + * @property {String} contentType Mime type of image + * @property {String} description Description of image + * @property {String} title Title of image + * @property {String} id ID of image + * @property {String} noGrp pickLocks property + * @property {String} noSelect pickLocks property + * @property {String} noRot pickLocks property + * @property {String} noChangeAspect pickLocks property + * @property {String} noMove pickLocks property + * @property {String} noResize pickLocks property + * @property {String} noEditPoints pickLocks property + * @property {String} noAdjustHandles pickLocks property + * @property {String} noChangeArrowheads pickLocks property + * @property {String} noChangeShapeType pickLocks property + * @returns {Picture} Excel Picture pickLocks property + */ + function Picture(opts) { + _classCallCheck(this, Picture); + + var _this = _possibleConstructorReturn(this, (Picture.__proto__ || Object.getPrototypeOf(Picture)).call(this)); + + _this.kind = 'image'; + _this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'; + _this.imagePath = opts.path; + _this.image = opts.image; + + _this._name = _this.image ? opts.name || uniqueId('image-') : opts.name || path.basename(_this.imagePath); + + var size = imgsz(_this.imagePath || _this.image); + + _this._pxWidth = size.width; + _this._pxHeight = size.height; + + _this._extension = _this.image ? size.type : path.extname(_this.imagePath).substr(1); + + _this.contentType = mime.getType(_this._extension); + + _this._descr = null; + _this._title = null; + _this._id; + // picLocks §20.1.2.2.31 picLocks (Picture Locks) + _this.noGrp; + _this.noSelect; + _this.noRot; + _this.noChangeAspect = true; + _this.noMove; + _this.noResize; + _this.noEditPoints; + _this.noAdjustHandles; + _this.noChangeArrowheads; + _this.noChangeShapeType; + if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) { + _this.anchor(opts.position.type, opts.position.from, opts.position.to); + } else if (opts.position.type === 'absoluteAnchor') { + _this.position(opts.position.x, opts.position.y); + } else { + throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor'); + } + return _this; + } + + _createClass(Picture, [{ + key: 'addToXMLele', + + + /** + * @alias Picture.addToXMLele + * @desc When generating Workbook output, attaches pictures to the drawings xml file + * @func Picture.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + value: function addToXMLele(ele) { + + var anchorEle = ele.ele('xdr:' + this.anchorType); + + if (this.editAs !== null) { + anchorEle.att('editAs', this.editAs); + } + + if (this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y); + } + + if (this.anchorType !== 'absoluteAnchor') { + var af = this.anchorFrom; + var afEle = anchorEle.ele('xdr:from'); + afEle.ele('xdr:col').text(af.col); + afEle.ele('xdr:colOff').text(af.colOff); + afEle.ele('xdr:row').text(af.row); + afEle.ele('xdr:rowOff').text(af.rowOff); + } + + if (this.anchorTo && this.anchorType === 'twoCellAnchor') { + var at = this.anchorTo; + var atEle = anchorEle.ele('xdr:to'); + atEle.ele('xdr:col').text(at.col); + atEle.ele('xdr:colOff').text(at.colOff); + atEle.ele('xdr:row').text(at.row); + atEle.ele('xdr:rowOff').text(at.rowOff); + } + + if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height); + } + + var picEle = anchorEle.ele('xdr:pic'); + var nvPicPrEle = picEle.ele('xdr:nvPicPr'); + var cNvPrEle = nvPicPrEle.ele('xdr:cNvPr'); + cNvPrEle.att('descr', this.description); + cNvPrEle.att('id', this.id + 1); + cNvPrEle.att('name', this.name); + cNvPrEle.att('title', this.title); + var cNvPicPrEle = nvPicPrEle.ele('xdr:cNvPicPr'); + + this.noGrp === true ? cNvPicPrEle.ele('a:picLocks').att('noGrp', 1) : null; + this.noSelect === true ? cNvPicPrEle.ele('a:picLocks').att('noSelect', 1) : null; + this.noRot === true ? cNvPicPrEle.ele('a:picLocks').att('noRot', 1) : null; + this.noChangeAspect === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeAspect', 1) : null; + this.noMove === true ? cNvPicPrEle.ele('a:picLocks').att('noMove', 1) : null; + this.noResize === true ? cNvPicPrEle.ele('a:picLocks').att('noResize', 1) : null; + this.noEditPoints === true ? cNvPicPrEle.ele('a:picLocks').att('noEditPoints', 1) : null; + this.noAdjustHandles === true ? cNvPicPrEle.ele('a:picLocks').att('noAdjustHandles', 1) : null; + this.noChangeArrowheads === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeArrowheads', 1) : null; + this.noChangeShapeType === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeShapeType', 1) : null; + + var blipFillEle = picEle.ele('xdr:blipFill'); + blipFillEle.ele('a:blip').att('r:embed', this.rId).att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + blipFillEle.ele('a:stretch').ele('a:fillRect'); + + var spPrEle = picEle.ele('xdr:spPr'); + var xfrmEle = spPrEle.ele('a:xfrm'); + xfrmEle.ele('a:off').att('x', 0).att('y', 0); + xfrmEle.ele('a:ext').att('cx', this.width).att('cy', this.height); + + var prstGeom = spPrEle.ele('a:prstGeom').att('prst', 'rect'); + prstGeom.ele('a:avLst'); + + anchorEle.ele('xdr:clientData'); + } + }, { + key: 'name', + get: function get() { + return this._name; + }, + set: function set(newName) { + this._name = newName; + } + }, { + key: 'id', + get: function get() { + return this._id; + }, + set: function set(id) { + this._id = id; + } + }, { + key: 'rId', + get: function get() { + return 'rId' + this._id; + } + }, { + key: 'description', + get: function get() { + return this._descr !== null ? this._descr : this._name; + }, + set: function set(desc) { + this._descr = desc; + } + }, { + key: 'title', + get: function get() { + return this._title !== null ? this._title : this._name; + }, + set: function set(title) { + this._title = title; + } + }, { + key: 'extension', + get: function get() { + return this._extension; + } + }, { + key: 'width', + get: function get() { + var inWidth = this._pxWidth / 96; + var emu = new EMU(inWidth + 'in'); + return emu.value; + } + }, { + key: 'height', + get: function get() { + var inHeight = this._pxHeight / 96; + var emu = new EMU(inHeight + 'in'); + return emu.value; + } + }]); + + return Picture; +}(Drawing); + +module.exports = Picture; +//# sourceMappingURL=picture.js.map \ No newline at end of file diff --git a/distribution/lib/drawing/picture.js.map b/distribution/lib/drawing/picture.js.map new file mode 100644 index 00000000..34825b81 --- /dev/null +++ b/distribution/lib/drawing/picture.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/drawing/picture.js"],"names":["Drawing","require","path","imgsz","mime","uniqueId","EMU","xmlbuilder","Picture","opts","kind","type","imagePath","image","_name","name","basename","size","_pxWidth","width","_pxHeight","height","_extension","extname","substr","contentType","getType","_descr","_title","_id","noGrp","noSelect","noRot","noChangeAspect","noMove","noResize","noEditPoints","noAdjustHandles","noChangeArrowheads","noChangeShapeType","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","editAs","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","picEle","nvPicPrEle","cNvPrEle","description","id","title","cNvPicPrEle","blipFillEle","rId","spPrEle","xfrmEle","prstGeom","newName","desc","inWidth","emu","value","inHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,OAAOD,QAAQ,MAAR,CAAb;AACA,IAAME,QAAQF,QAAQ,YAAR,CAAd;AACA,IAAMG,OAAOH,QAAQ,MAAR,CAAb;AACA,IAAMI,WAAWJ,QAAQ,iBAAR,CAAjB;;AAEA,IAAMK,MAAML,QAAQ,mBAAR,CAAZ;AACA,IAAMM,aAAaN,QAAQ,YAA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Ad;AACH;;;4BAEW;AACR,mBAAO,KAAKlD,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAKd,KAAjD;AACH,S;0BACSwD,K,EAAO;AACb,iBAAK1C,MAAL,GAAc0C,KAAd;AACH;;;4BAEe;AACZ,mBAAO,KAAKhD,UAAZ;AACH;;;4BAEW;AACR,gBAAIyD,UAAU,KAAK7D,QAAL,GAAgB,EAA9B;AACA,gBAAI8D,MAAM,IAAI1E,GAAJ,CAAQyE,UAAU,IAAlB,CAAV;AACA,mBAAOC,IAAIC,KAAX;AACH;;;4BAEY;AACT,gBAAIC,WAAW,KAAK9D,SAAL,GAAiB,EAAhC;AACA,gBAAI4D,MAAM,IAAI1E,GAAJ,CAAQ4E,WAAW,IAAnB,CAAV;AACA,mBAAOF,IAAIC,KAAX;AACH;;;;EAjHiBjF,O;;AA+LtBmF,OAAOC,OAAP,GAAiB5E,OAAjB","file":"picture.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst path = require('path');\r\nconst imgsz = require('image-size');\r\nconst mime = require('mime');\r\nconst uniqueId = require('lodash.uniqueid');\r\n\r\nconst EMU = require('../classes/emu.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\n\r\nclass Picture extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture (currently only image is supported)\r\n * @property {String} type ooxml schema\r\n * @property {String} imagePath Filesystem path to image\r\n * @property {Buffer} image Buffer with image\r\n * @property {String} contentType Mime type of image\r\n * @property {String} description Description of image\r\n * @property {String} title Title of image\r\n * @property {String} id ID of image\r\n * @property {String} noGrp pickLocks property\r\n * @property {String} noSelect pickLocks property\r\n * @property {String} noRot pickLocks property\r\n * @property {String} noChangeAspect pickLocks property\r\n * @property {String} noMove pickLocks property\r\n * @property {String} noResize pickLocks property\r\n * @property {String} noEditPoints pickLocks property\r\n * @property {String} noAdjustHandles pickLocks property\r\n * @property {String} noChangeArrowheads pickLocks property\r\n * @property {String} noChangeShapeType pickLocks property\r\n * @returns {Picture} Excel Picture pickLocks property\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'image';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image';\r\n this.imagePath = opts.path;\r\n this.image = opts.image;\r\n\r\n this._name = this.image ?\r\n opts.name || uniqueId('image-') :\r\n opts.name || path.basename(this.imagePath);\r\n\r\n const size = imgsz(this.imagePath || this.image);\r\n\r\n this._pxWidth = size.width;\r\n this._pxHeight = size.height;\r\n\r\n this._extension = this.image ?\r\n size.type :\r\n path.extname(this.imagePath).substr(1);\r\n\r\n this.contentType = mime.getType(this._extension);\r\n\r\n this._descr = null;\r\n this._title = null;\r\n this._id;\r\n // picLocks §20.1.2.2.31 picLocks (Picture Locks)\r\n this.noGrp;\r\n this.noSelect;\r\n this.noRot;\r\n this.noChangeAspect = true;\r\n this.noMove;\r\n this.noResize;\r\n this.noEditPoints;\r\n this.noAdjustHandles;\r\n this.noChangeArrowheads;\r\n this.noChangeShapeType;\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n if (this.editAs !== null) {\r\n anchorEle.att('editAs', this.editAs);\r\n }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let picEle = anchorEle.ele('xdr:pic');\r\n let nvPicPrEle = picEle.ele('xdr:nvPicPr');\r\n let cNvPrEle = nvPicPrEle.ele('xdr:cNvPr');\r\n cNvPrEle.att('descr', this.description);\r\n cNvPrEle.att('id', this.id + 1);\r\n cNvPrEle.att('name', this.name);\r\n cNvPrEle.att('title', this.title);\r\n let cNvPicPrEle = nvPicPrEle.ele('xdr:cNvPicPr');\r\n\r\n this.noGrp === true ? cNvPicPrEle.ele('a:picLocks').att('noGrp', 1) : null;\r\n this.noSelect === true ? cNvPicPrEle.ele('a:picLocks').att('noSelect', 1) : null;\r\n this.noRot === true ? cNvPicPrEle.ele('a:picLocks').att('noRot', 1) : null;\r\n this.noChangeAspect === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeAspect', 1) : null;\r\n this.noMove === true ? cNvPicPrEle.ele('a:picLocks').att('noMove', 1) : null;\r\n this.noResize === true ? cNvPicPrEle.ele('a:picLocks').att('noResize', 1) : null;\r\n this.noEditPoints === true ? cNvPicPrEle.ele('a:picLocks').att('noEditPoints', 1) : null;\r\n this.noAdjustHandles === true ? cNvPicPrEle.ele('a:picLocks').att('noAdjustHandles', 1) : null;\r\n this.noChangeArrowheads === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeArrowheads', 1) : null;\r\n this.noChangeShapeType === true ? cNvPicPrEle.ele('a:picLocks').att('noChangeShapeType', 1) : null;\r\n\r\n let blipFillEle = picEle.ele('xdr:blipFill');\r\n blipFillEle.ele('a:blip').att('r:embed', this.rId).att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n blipFillEle.ele('a:stretch').ele('a:fillRect');\r\n\r\n let spPrEle = picEle.ele('xdr:spPr');\r\n let xfrmEle = spPrEle.ele('a:xfrm');\r\n xfrmEle.ele('a:off').att('x', 0).att('y', 0);\r\n xfrmEle.ele('a:ext').att('cx', this.width).att('cy', this.height);\r\n\r\n let prstGeom = spPrEle.ele('a:prstGeom').att('prst', 'rect');\r\n prstGeom.ele('a:avLst');\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n}\r\n\r\nmodule.exports = Picture;"]} \ No newline at end of file diff --git a/distribution/lib/logger.js b/distribution/lib/logger.js new file mode 100644 index 00000000..71709d94 --- /dev/null +++ b/distribution/lib/logger.js @@ -0,0 +1,74 @@ +"use strict"; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var SimpleLogger = function () { + function SimpleLogger(opts) { + _classCallCheck(this, SimpleLogger); + + this.logLevel = opts.logLevel || 5; + } + + _createClass(SimpleLogger, [{ + key: "debug", + value: function debug() { + if (this.logLevel >= 5) { + var _console; + + (_console = console).debug.apply(_console, arguments); + } + } + }, { + key: "log", + value: function log() { + if (this.logLevel >= 4) { + var _console2; + + (_console2 = console).log.apply(_console2, arguments); + } + } + }, { + key: "inspect", + value: function inspect() { + if (this.logLevel >= 4) { + var _console3; + + (_console3 = console).log.apply(_console3, arguments); + } + } + }, { + key: "info", + value: function info() { + if (this.logLevel >= 3) { + var _console4; + + (_console4 = console).info.apply(_console4, arguments); + } + } + }, { + key: "warn", + value: function warn() { + if (this.logLevel >= 2) { + var _console5; + + (_console5 = console).warn.apply(_console5, arguments); + } + } + }, { + key: "error", + value: function error() { + if (this.logLevel >= 1) { + var _console6; + + (_console6 = console).error.apply(_console6, arguments); + } + } + }]); + + return SimpleLogger; +}(); + +module.exports = SimpleLogger; +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/distribution/lib/logger.js.map b/distribution/lib/logger.js.map new file mode 100644 index 00000000..1763408c --- /dev/null +++ b/distribution/lib/logger.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../source/lib/logger.js"],"names":["SimpleLogger","opts","logLevel","debug","arguments","log","info","warn","error","module","exports"],"mappings":";;;;;;IAAMA,Y;AACJ,wBAAYC,IAAZ,EAAkB;AAAA;;AAChB,SAAKC,QAAL,GAAgBD,KAAKC,QAAL,IAAiB,CAAjC;AACD;;;;4BAEO;AACN,UAAI,KAAKA,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,6BAAQC,KAAR,iBAAiBC,SAAjB;AACD;AACF;;;0BAEK;AACJ,UAAI,KAAKF,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,8BAAQG,GAAR,kBAAeD,SAAf;AACD;AACF;;;8BAES;AACR,UAAI,KAAKF,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,8BAAQG,GAAR,kBAAeD,SAAf;AACD;AACF;;;2BAEM;AACL,UAAI,KAAKF,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,8BAAQI,IAAR,kBAAgBF,SAAhB;AACD;AACF;;;2BAEM;AACL,UAAI,KAAKF,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,8BAAQK,IAAR,kBAAgBH,SAAhB;AACD;AACF;;;4BAEO;AACN,UAAI,KAAKF,QAAL,IAAiB,CAArB,EAAwB;AAAA;;AACtB,8BAAQM,KAAR,kBAAiBJ,SAAjB;AACD;AACF;;;;;;AAIHK,OAAOC,OAAP,GAAiBV,YAAjB","file":"logger.js","sourcesContent":["class SimpleLogger {\r\n constructor(opts) {\r\n this.logLevel = opts.logLevel || 5;\r\n }\r\n\r\n debug() {\r\n if (this.logLevel >= 5) {\r\n console.debug(...arguments);\r\n }\r\n }\r\n\r\n log() {\r\n if (this.logLevel >= 4) {\r\n console.log(...arguments);\r\n }\r\n }\r\n\r\n inspect() {\r\n if (this.logLevel >= 4) {\r\n console.log(...arguments);\r\n }\r\n }\r\n\r\n info() {\r\n if (this.logLevel >= 3) {\r\n console.info(...arguments);\r\n }\r\n }\r\n\r\n warn() {\r\n if (this.logLevel >= 2) {\r\n console.warn(...arguments);\r\n }\r\n }\r\n\r\n error() {\r\n if (this.logLevel >= 1) {\r\n console.error(...arguments);\r\n }\r\n }\r\n\r\n}\r\n\r\nmodule.exports = SimpleLogger;"]} \ No newline at end of file diff --git a/distribution/lib/row/index.js b/distribution/lib/row/index.js new file mode 100644 index 00000000..ebaddba4 --- /dev/null +++ b/distribution/lib/row/index.js @@ -0,0 +1,28 @@ +'use strict'; + +var Row = require('../row/row.js'); + +/** + * Module repesenting a Row Accessor + * @alias Worksheet.row + * @namespace + * @func Worksheet.row + * @desc Access a row in order to manipulate values + * @param {Number} row Row of top left cell + * @returns {Row} + */ +var rowAccessor = function rowAccessor(ws, row) { + + if (typeof row !== 'number') { + throw new TypeError('Row sent to row accessor was not a number.'); + } + + if (!(ws.rows[row] instanceof Row)) { + ws.rows[row] = new Row(row, ws); + } + + return ws.rows[row]; +}; + +module.exports = rowAccessor; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/row/index.js.map b/distribution/lib/row/index.js.map new file mode 100644 index 00000000..c475f9df --- /dev/null +++ b/distribution/lib/row/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/row/index.js"],"names":["Row","require","rowAccessor","ws","row","TypeError","rows","module","exports"],"mappings":";;AAAA,IAAMA,MAAMC,QAAQ,eAAR,CAAZ;;AAEA;;;;;;;;;AASA,IAAIC,cAAc,SAAdA,WAAc,CAAUC,EAAV,EAAcC,GAAd,EAAmB;;AAEjC,QAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AACzB,cAAM,IAAIC,SAAJ,CAAc,4CAAd,CAAN;AACH;;AAED,QAAI,EAAEF,GAAGG,IAAH,CAAQF,GAAR,aAAwBJ,GAA1B,CAAJ,EAAoC;AAChCG,WAAGG,IAAH,CAAQF,GAAR,IAAe,IAAIJ,GAAJ,CAAQI,GAAR,EAAaD,EAAb,CAAf;AACH;;AAED,WAAOA,GAAGG,IAAH,CAAQF,GAAR,CAAP;AACH,CAXD;;AAeAG,OAAOC,OAAP,GAAiBN,WAAjB","file":"index.js","sourcesContent":["const Row = require('../row/row.js');\r\n\r\n/**\r\n * Module repesenting a Row Accessor\r\n * @alias Worksheet.row\r\n * @namespace\r\n * @func Worksheet.row\r\n * @desc Access a row in order to manipulate values\r\n * @param {Number} row Row of top left cell\r\n * @returns {Row}\r\n */\r\nlet rowAccessor = function (ws, row) {\r\n\r\n if (typeof row !== 'number') {\r\n throw new TypeError('Row sent to row accessor was not a number.');\r\n }\r\n\r\n if (!(ws.rows[row] instanceof Row)) {\r\n ws.rows[row] = new Row(row, ws);\r\n }\r\n\r\n return ws.rows[row];\r\n};\r\n\r\n\r\n\r\nmodule.exports = rowAccessor;"]} \ No newline at end of file diff --git a/distribution/lib/row/row.js b/distribution/lib/row/row.js new file mode 100644 index 00000000..9953b97d --- /dev/null +++ b/distribution/lib/row/row.js @@ -0,0 +1,239 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var utils = require('../utils.js'); + +var Row = function () { + /** + * Element representing an Excel Row + * @param {Number} row Row of cell + * @param {Worksheet} Worksheet that contains row + * @property {Worksheet} ws Worksheet that contains the specified Row + * @property {Array.String} cellRefs Array of excel cell references + * @property {Boolean} collapsed States whether row is collapsed when grouped + * @property {Boolean} customFormat States whether the row has a custom format + * @property {Boolean} customHeight States whether the row's height is different than default + * @property {Boolean} hidden States whether the row is hidden + * @property {Number} ht Height of the row (internal property) + * @property {Number} outlineLevel Grouping level of row + * @property {Number} r Row index + * @property {Number} s Style index + * @property {Boolean} thickBot States whether row has a thick bottom border + * @property {Boolean} thickTop States whether row has a thick top border + * @property {Number} height Height of row + * @property {String} spans String representation of excel cell range i.e. A1:A10 + * @property {Number} firstColumn Index of the first column of the row containg data + * @property {String} firstColumnAlpha Alpha representation of the first column of the row containing data + * @property {Number} lastColumn Index of the last column of the row cotaining data + * @property {String} lastColumnAlpha Alpha representation of the last column of the row containing data + */ + function Row(row, ws) { + _classCallCheck(this, Row); + + this.ws = ws; + this.cellRefs = []; + this.collapsed = null; + this.customFormat = null; + this.customHeight = null; + this.hidden = null; + this.ht = null; + this.outlineLevel = null; + this.r = row; + this.s = null; + this.thickBot = null; + this.thickTop = null; + } + + _createClass(Row, [{ + key: 'setHeight', + + + /** + * @alias Row.setHeight + * @desc Sets the height of a row + * @func Row.setHeight + * @param {Number} val New Height of row + * @returns {Row} Excel Row with attached methods + */ + value: function setHeight(h) { + if (typeof h === 'number') { + this.ht = h; + this.customHeight = true; + } else { + throw new TypeError('Row height must be a number'); + } + return this; + } + }, { + key: 'filter', + + + /** + * @alias Row.filter + * @desc Add autofilter dropdowns to the items of the row + * @func Row.filter + * @param {Object} opts Object containing options for the fitler. + * @param {Number} opts.lastRow Last row in which the filter show effect filtered results (optional) + * @param {Number} opts.startCol First column that a filter dropdown should be added (optional) + * @param {Number} opts.lastCol Last column that a filter dropdown should be added (optional) + * @param {Array.DefinedName} opts.filters Array of filter paramaters + * @returns {Row} Excel Row with attached methods + */ + value: function filter() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + + var theseFilters = opts.filters instanceof Array ? opts.filters : []; + + var o = this.ws.opts.autoFilter; + o.startRow = this.r; + if (typeof opts.lastRow === 'number') { + o.endRow = opts.lastRow; + } + + if (typeof opts.firstColumn === 'number' && typeof opts.lastColumn === 'number') { + o.startCol = opts.firstColumn; + o.endCol = opts.lastColumn; + } + + // Programmer Note: DefinedName class is added to workbook during workbook write process for filters + + this.ws.opts.autoFilter.filters = theseFilters; + } + + /** + * @alias Row.hide + * @desc Hides the row + * @func Row.hide + * @returns {Row} Excel Row with attached methods + */ + + }, { + key: 'hide', + value: function hide() { + this.hidden = true; + return this; + } + + /** + * @alias Row.group + * @desc Hides the row + * @func Row.group + * @param {Number} level Group level of row + * @param {Boolean} collapsed States whether group should be collapsed or expanded by default + * @returns {Row} Excel Row with attached methods + */ + + }, { + key: 'group', + value: function group(level, collapsed) { + if (parseInt(level) === level) { + this.outlineLevel = level; + } else { + throw new TypeError('Row group level must be a positive integer'); + } + + if (collapsed === undefined) { + return this; + } + + if (typeof collapsed === 'boolean') { + this.collapsed = collapsed; + this.hidden = collapsed; + } else { + throw new TypeError('Row group collapse flag must be a boolean'); + } + + return this; + } + + /** + * @alias Row.freeze + * @desc Creates Worksheet panes and freezes the top pane + * @func Row.freeze + * @param {Number} jumpTo Row that the bottom pane should be scrolled to by default + * @returns {Row} Excel Row with attached methods + */ + + }, { + key: 'freeze', + value: function freeze(jumpTo) { + var o = this.ws.opts.sheetView.pane; + jumpTo = typeof jumpTo === 'number' && jumpTo > this.r ? jumpTo : this.r + 1; + o.state = 'frozen'; + o.ySplit = this.r; + o.activePane = 'bottomRight'; + o.xSplit === null ? o.topLeftCell = utils.getExcelCellRef(jumpTo, 1) : o.topLeftCell = utils.getExcelCellRef(jumpTo, utils.getExcelRowCol(o.topLeftCell).col); + return this; + } + }, { + key: 'height', + set: function set(h) { + if (typeof h === 'number') { + this.ht = h; + this.customHeight = true; + } else { + throw new TypeError('Row height must be a number'); + } + return this.ht; + }, + get: function get() { + return this.ht; + } + }, { + key: 'spans', + get: function get() { + if (this.cellRefs.length > 0) { + var startCol = utils.getExcelRowCol(this.cellRefs[0]).col; + var endCol = utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col; + return startCol + ':' + endCol; + } else { + return null; + } + } + }, { + key: 'firstColumn', + get: function get() { + if (this.cellRefs instanceof Array && this.cellRefs.length > 0) { + return utils.getExcelRowCol(this.cellRefs[0]).col; + } else { + return 1; + } + } + }, { + key: 'firstColumnAlpha', + get: function get() { + if (this.cellRefs instanceof Array && this.cellRefs.length > 0) { + return utils.getExcelAlpha(utils.getExcelRowCol(this.cellRefs[0]).col); + } else { + return 'A'; + } + } + }, { + key: 'lastColumn', + get: function get() { + if (this.cellRefs instanceof Array && this.cellRefs.length > 0) { + return utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col; + } else { + return 1; + } + } + }, { + key: 'lastColumnAlpha', + get: function get() { + if (this.cellRefs instanceof Array && this.cellRefs.length > 0) { + return utils.getExcelAlpha(utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col); + } else { + return 'A'; + } + } + }]); + + return Row; +}(); + +module.exports = Row; +//# sourceMappingURL=row.js.map \ No newline at end of file diff --git a/distribution/lib/row/row.js.map b/distribution/lib/row/row.js.map new file mode 100644 index 00000000..ef1aa646 --- /dev/null +++ b/distribution/lib/row/row.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/row/row.js"],"names":["utils","require","Row","row","ws","cellRefs","collapsed","customFormat","customHeight","hidden","ht","outlineLevel","r","s","thickBot","thickTop","h","TypeError","opts","theseFilters","filters","Array","o","autoFilter","startRow","lastRow","endRow","firstColumn","lastColumn","startCol","endCol","level","parseInt","undefined","jumpTo","sheetView","pane","state","ySplit","activePane","xSplit","topLeftCell","getExcelCellRef","getExcelRowCol","col","length","getExcelAlpha","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,aAAR,CAAd;;IAEMC,G;AACF;;;;;;;;;;;;;;;;;;;;;;;AAuBA,iBAAYC,GAAZ,EAAiBC,EAAjB,EAAqB;AAAA;;AACjB,aAAKA,EAAL,GAAUA,EAAV;AACA,aAAKC,QAAL,GAAgB,EAAhB;AACA,aAAKC,SAAL,GAAiB,IAAjB;AACA,aAAKC,YAAL,GAAoB,IAApB;AACA,aAAKC,YAAL,GAAoB,IAApB;AACA,aAAKC,MAAL,GAAc,IAAd;AACA,aAAKC,EAAL,GAAU,IAAV;AACA,aAAKC,YAAL,GAAoB,IAApB;AACA,aAAKC,CAAL,GAA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AAd,GAAuB,CAA7D,EAAgE;AAC5D,uBAAO7C,MAAM8C,aAAN,CAAoB9C,MAAM2C,cAAN,CAAqB,KAAKtC,QAAL,CAAc,KAAKA,QAAL,CAAcwC,MAAd,GAAuB,CAArC,CAArB,EAA8DD,GAAlF,CAAP;AACH,aAFD,MAEO;AACH,uBAAO,GAAP;AACH;AACJ;;;;;;AA6FLG,OAAOC,OAAP,GAAiB9C,GAAjB","file":"row.js","sourcesContent":["const utils = require('../utils.js');\r\n\r\nclass Row {\r\n /**\r\n * Element representing an Excel Row\r\n * @param {Number} row Row of cell\r\n * @param {Worksheet} Worksheet that contains row\r\n * @property {Worksheet} ws Worksheet that contains the specified Row\r\n * @property {Array.String} cellRefs Array of excel cell references\r\n * @property {Boolean} collapsed States whether row is collapsed when grouped\r\n * @property {Boolean} customFormat States whether the row has a custom format\r\n * @property {Boolean} customHeight States whether the row's height is different than default\r\n * @property {Boolean} hidden States whether the row is hidden\r\n * @property {Number} ht Height of the row (internal property)\r\n * @property {Number} outlineLevel Grouping level of row\r\n * @property {Number} r Row index\r\n * @property {Number} s Style index\r\n * @property {Boolean} thickBot States whether row has a thick bottom border\r\n * @property {Boolean} thickTop States whether row has a thick top border\r\n * @property {Number} height Height of row\r\n * @property {String} spans String representation of excel cell range i.e. A1:A10\r\n * @property {Number} firstColumn Index of the first column of the row containg data\r\n * @property {String} firstColumnAlpha Alpha representation of the first column of the row containing data\r\n * @property {Number} lastColumn Index of the last column of the row cotaining data\r\n * @property {String} lastColumnAlpha Alpha representation of the last column of the row containing data\r\n */\r\n constructor(row, ws) {\r\n this.ws = ws;\r\n this.cellRefs = [];\r\n this.collapsed = null;\r\n this.customFormat = null;\r\n this.customHeight = null;\r\n this.hidden = null;\r\n this.ht = null;\r\n this.outlineLevel = null;\r\n this.r = row;\r\n this.s = null;\r\n this.thickBot = null;\r\n this.thickTop = null;\r\n }\r\n\r\n set height(h) {\r\n if (typeof h === 'number') {\r\n this.ht = h;\r\n this.customHeight = true;\r\n } else {\r\n throw new TypeError('Row height must be a number');\r\n }\r\n return this.ht;\r\n }\r\n get height() {\r\n return this.ht;\r\n }\r\n\r\n /**\r\n * @alias Row.setHeight\r\n * @desc Sets the height of a row\r\n * @func Row.setHeight\r\n * @param {Number} val New Height of row\r\n * @returns {Row} Excel Row with attached methods\r\n */\r\n setHeight(h) {\r\n if (typeof h === 'number') {\r\n this.ht = h;\r\n this.customHeight = true;\r\n } else {\r\n throw new TypeError('Row height must be a number');\r\n }\r\n return this;\r\n }\r\n\r\n get spans() {\r\n if (this.cellRefs.length > 0) {\r\n const startCol = utils.getExcelRowCol(this.cellRefs[0]).col;\r\n const endCol = utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col;\r\n return `${startCol}:${endCol}`;\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n get firstColumn() {\r\n if (this.cellRefs instanceof Array && this.cellRefs.length > 0) {\r\n return utils.getExcelRowCol(this.cellRefs[0]).col;\r\n } else {\r\n return 1;\r\n }\r\n }\r\n\r\n get firstColumnAlpha() {\r\n if (this.cellRefs instanceof Array && this.cellRefs.length > 0) {\r\n return utils.getExcelAlpha(utils.getExcelRowCol(this.cellRefs[0]).col);\r\n } else {\r\n return 'A';\r\n }\r\n }\r\n\r\n get lastColumn() {\r\n if (this.cellRefs instanceof Array && this.cellRefs.length > 0) {\r\n return utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col;\r\n } else {\r\n return 1;\r\n }\r\n }\r\n\r\n get lastColumnAlpha() {\r\n if (this.cellRefs instanceof Array && this.cellRefs.length > 0) {\r\n return utils.getExcelAlpha(utils.getExcelRowCol(this.cellRefs[this.cellRefs.length - 1]).col);\r\n } else {\r\n return 'A';\r\n }\r\n }\r\n\r\n /**\r\n * @alias Row.filter\r\n * @desc Add autofilter dropdowns to the items of the row\r\n * @func Row.filter\r\n * @param {Object} opts Object containing options for the fitler. \r\n * @param {Number} opts.lastRow Last row in which the filter show effect filtered results (optional)\r\n * @param {Number} opts.startCol First column that a filter dropdown should be added (optional)\r\n * @param {Number} opts.lastCol Last column that a filter dropdown should be added (optional)\r\n * @param {Array.DefinedName} opts.filters Array of filter paramaters\r\n * @returns {Row} Excel Row with attached methods\r\n */\r\n filter(opts = {}) {\r\n\r\n let theseFilters = opts.filters instanceof Array ? opts.filters : [];\r\n\r\n let o = this.ws.opts.autoFilter;\r\n o.startRow = this.r;\r\n if (typeof opts.lastRow === 'number') {\r\n o.endRow = opts.lastRow;\r\n }\r\n\r\n if (typeof opts.firstColumn === 'number' && typeof opts.lastColumn === 'number') {\r\n o.startCol = opts.firstColumn;\r\n o.endCol = opts.lastColumn;\r\n }\r\n\r\n // Programmer Note: DefinedName class is added to workbook during workbook write process for filters\r\n\r\n this.ws.opts.autoFilter.filters = theseFilters;\r\n }\r\n\r\n /**\r\n * @alias Row.hide\r\n * @desc Hides the row\r\n * @func Row.hide\r\n * @returns {Row} Excel Row with attached methods\r\n */\r\n hide() {\r\n this.hidden = true;\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Row.group\r\n * @desc Hides the row\r\n * @func Row.group\r\n * @param {Number} level Group level of row\r\n * @param {Boolean} collapsed States whether group should be collapsed or expanded by default\r\n * @returns {Row} Excel Row with attached methods\r\n */\r\n group(level, collapsed) {\r\n if (parseInt(level) === level) {\r\n this.outlineLevel = level;\r\n } else {\r\n throw new TypeError('Row group level must be a positive integer');\r\n }\r\n\r\n if (collapsed === undefined) {\r\n return this;\r\n }\r\n\r\n if (typeof collapsed === 'boolean') {\r\n this.collapsed = collapsed;\r\n this.hidden = collapsed;\r\n } else {\r\n throw new TypeError('Row group collapse flag must be a boolean');\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * @alias Row.freeze\r\n * @desc Creates Worksheet panes and freezes the top pane\r\n * @func Row.freeze\r\n * @param {Number} jumpTo Row that the bottom pane should be scrolled to by default\r\n * @returns {Row} Excel Row with attached methods\r\n */\r\n freeze(jumpTo) {\r\n let o = this.ws.opts.sheetView.pane;\r\n jumpTo = typeof jumpTo === 'number' && jumpTo > this.r ? jumpTo : this.r + 1;\r\n o.state = 'frozen';\r\n o.ySplit = this.r;\r\n o.activePane = 'bottomRight';\r\n o.xSplit === null ?\r\n o.topLeftCell = utils.getExcelCellRef(jumpTo, 1) :\r\n o.topLeftCell = utils.getExcelCellRef(jumpTo, utils.getExcelRowCol(o.topLeftCell).col);\r\n return this;\r\n }\r\n}\r\n\r\nmodule.exports = Row;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/alignment.js b/distribution/lib/style/classes/alignment.js new file mode 100644 index 00000000..7c9478d2 --- /dev/null +++ b/distribution/lib/style/classes/alignment.js @@ -0,0 +1,142 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var types = require('../../types/index.js'); +var xmlbuilder = require('xmlbuilder'); + +var Alignment = function () { + // §18.8.1 alignment (Alignment) + /** + * @class Alignment + * @param {Object} opts Properties of Alignment object + * @param {String} opts.horizontal Horizontal Alignment property of text. + * @param {String} opts.vertical Vertical Alignment property of text. + * @param {String} opts.readingOrder Reading order for language of text. + * @param {Number} opts.indent How much text should be indented. Setting indent to 1 will indent text 3 spaces + * @param {Boolean} opts.justifyLastLine Specifies whether to justify last line of text + * @param {Number} opts.relativeIndent Used in conditional formatting to state how much more text should be indented if rule passes + * @param {Boolean} opts.shrinkToFit Indicates if text should be shrunk to fit into cell + * @param {Number} opts.textRotation Number of degrees to rotate text counterclockwise + * @param {Boolean} opts.wrapText States whether text with newline characters should wrap + * @returns {Alignment} + */ + function Alignment(opts) { + _classCallCheck(this, Alignment); + + if (opts.horizontal !== undefined) { + this.horizontal = types.alignment.horizontal.validate(opts.horizontal) === true ? opts.horizontal : null; + } + + if (opts.vertical !== undefined) { + this.vertical = types.alignment.vertical.validate(opts.vertical) === true ? opts.vertical : null; + } + + if (opts.readingOrder !== undefined) { + this.readingOrder = types.alignment.readingOrder.validate(opts.readingOrder) === true ? opts.readingOrder : null; + } + + if (opts.indent !== undefined) { + if (typeof opts.indent === 'number' && parseInt(opts.indent) === opts.indent && opts.indent > 0) { + this.indent = opts.indent; + } else { + throw new TypeError('alignment indent must be a positive integer.'); + } + } + + if (opts.justifyLastLine !== undefined) { + if (typeof opts.justifyLastLine === 'boolean') { + this.justifyLastLine = opts.justifyLastLine; + } else { + throw new TypeError('justifyLastLine alignment option must be of type boolean'); + } + } + + if (opts.relativeIndent !== undefined) { + if (typeof opts.relativeIndent === 'number' && parseInt(opts.relativeIndent) === opts.relativeIndent && opts.relativeIndent > 0) { + this.relativeIndent = opts.relativeIndent; + } else { + throw new TypeError('alignment indent must be a positive integer.'); + } + } + + if (opts.shrinkToFit !== undefined) { + if (typeof opts.shrinkToFit === 'boolean') { + this.shrinkToFit = opts.shrinkToFit; + } else { + throw new TypeError('justifyLastLine alignment option must be of type boolean'); + } + } + + if (opts.textRotation !== undefined) { + if (typeof opts.textRotation === 'number' && parseInt(opts.textRotation) === opts.textRotation) { + this.textRotation = opts.textRotation; + } else if (opts.textRotation !== undefined) { + throw new TypeError('alignment indent must be an integer.'); + } + } + + if (opts.wrapText !== undefined) { + if (typeof opts.wrapText === 'boolean') { + this.wrapText = opts.wrapText; + } else { + throw new TypeError('justifyLastLine alignment option must be of type boolean'); + } + } + } + + /** + * @func Alignment.toObject + * @desc Converts the Alignment instance to a javascript object + * @returns {Object} + */ + + + _createClass(Alignment, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + + this.horizontal !== undefined ? obj.horizontal = this.horizontal : null; + this.indent !== undefined ? obj.indent = this.indent : null; + this.justifyLastLine !== undefined ? obj.justifyLastLine = this.justifyLastLine : null; + this.readingOrder !== undefined ? obj.readingOrder = this.readingOrder : null; + this.relativeIndent !== undefined ? obj.relativeIndent = this.relativeIndent : null; + this.shrinkToFit !== undefined ? obj.shrinkToFit = this.shrinkToFit : null; + this.textRotation !== undefined ? obj.textRotation = this.textRotation : null; + this.vertical !== undefined ? obj.vertical = this.vertical : null; + this.wrapText !== undefined ? obj.wrapText = this.wrapText : null; + + return obj; + } + + /** + * @alias Alignment.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func Alignment.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var thisEle = ele.ele('alignment'); + this.horizontal !== undefined ? thisEle.att('horizontal', this.horizontal) : null; + this.indent !== undefined ? thisEle.att('indent', this.indent) : null; + this.justifyLastLine === true ? thisEle.att('justifyLastLine', 1) : null; + this.readingOrder !== undefined ? thisEle.att('readingOrder', this.readingOrder) : null; + this.relativeIndent !== undefined ? thisEle.att('relativeIndent', this.relativeIndent) : null; + this.shrinkToFit === true ? thisEle.att('shrinkToFit', 1) : null; + this.textRotation !== undefined ? thisEle.att('textRotation', this.textRotation) : null; + this.vertical !== undefined ? thisEle.att('vertical', this.vertical) : null; + this.wrapText === true ? thisEle.att('wrapText', 1) : null; + } + }]); + + return Alignment; +}(); + +module.exports = Alignment; +//# sourceMappingURL=alignment.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/alignment.js.map b/distribution/lib/style/classes/alignment.js.map new file mode 100644 index 00000000..6fc58244 --- /dev/null +++ b/distribution/lib/style/classes/alignment.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/alignment.js"],"names":["types","require","xmlbuilder","Alignment","opts","horizontal","undefined","alignment","validate","vertical","readingOrder","indent","parseInt","TypeError","justifyLastLine","relativeIndent","shrinkToFit","textRotation","wrapText","ob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,CAAY,iBAAZ,EAA+B,CAA/B,CAAhC,GAAoE,IAApE;AACA,iBAAKZ,YAAL,KAAsBJ,SAAtB,GAAkCe,QAAQC,GAAR,CAAY,cAAZ,EAA4B,KAAKZ,YAAjC,CAAlC,GAAmF,IAAnF;AACA,iBAAKK,cAAL,KAAwBT,SAAxB,GAAoCe,QAAQC,GAAR,CAAY,gBAAZ,EAA8B,KAAKP,cAAnC,CAApC,GAAyF,IAAzF;AACA,iBAAKC,WAAL,KAAqB,IAArB,GAA4BK,QAAQC,GAAR,CAAY,aAAZ,EAA2B,CAA3B,CAA5B,GAA4D,IAA5D;AACA,iBAAKL,YAAL,KAAsBX,SAAtB,GAAkCe,QAAQC,GAAR,CAAY,cAAZ,EAA4B,KAAKL,YAAjC,CAAlC,GAAmF,IAAnF;AACA,iBAAKR,QAAL,KAAkBH,SAAlB,GAA8Be,QAAQC,GAAR,CAAY,UAAZ,EAAwB,KAAKb,QAA7B,CAA9B,GAAuE,IAAvE;AACA,iBAAKS,QAAL,KAAkB,IAAlB,GAAyBG,QAAQC,GAAR,CAAY,UAAZ,EAAwB,CAAxB,CAAzB,GAAsD,IAAtD;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiBrB,SAAjB","file":"alignment.js","sourcesContent":["const types = require('../../types/index.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\n\r\nclass Alignment { // §18.8.1 alignment (Alignment)\r\n /**\r\n * @class Alignment\r\n * @param {Object} opts Properties of Alignment object\r\n * @param {String} opts.horizontal Horizontal Alignment property of text. \r\n * @param {String} opts.vertical Vertical Alignment property of text. \r\n * @param {String} opts.readingOrder Reading order for language of text.\r\n * @param {Number} opts.indent How much text should be indented. Setting indent to 1 will indent text 3 spaces\r\n * @param {Boolean} opts.justifyLastLine Specifies whether to justify last line of text\r\n * @param {Number} opts.relativeIndent Used in conditional formatting to state how much more text should be indented if rule passes\r\n * @param {Boolean} opts.shrinkToFit Indicates if text should be shrunk to fit into cell\r\n * @param {Number} opts.textRotation Number of degrees to rotate text counterclockwise\r\n * @param {Boolean} opts.wrapText States whether text with newline characters should wrap\r\n * @returns {Alignment}\r\n */\r\n constructor(opts) {\r\n\r\n if (opts.horizontal !== undefined) {\r\n this.horizontal = types.alignment.horizontal.validate(opts.horizontal) === true ? opts.horizontal : null;\r\n }\r\n\r\n if (opts.vertical !== undefined) {\r\n this.vertical = types.alignment.vertical.validate(opts.vertical) === true ? opts.vertical : null;\r\n }\r\n\r\n if (opts.readingOrder !== undefined) {\r\n this.readingOrder = types.alignment.readingOrder.validate(opts.readingOrder) === true ? opts.readingOrder : null;\r\n }\r\n\r\n if (opts.indent !== undefined) {\r\n if (typeof opts.indent === 'number' && parseInt(opts.indent) === opts.indent && opts.indent > 0) {\r\n this.indent = opts.indent;\r\n } else {\r\n throw new TypeError('alignment indent must be a positive integer.');\r\n }\r\n }\r\n\r\n if (opts.justifyLastLine !== undefined) {\r\n if (typeof opts.justifyLastLine === 'boolean') {\r\n this.justifyLastLine = opts.justifyLastLine;\r\n } else {\r\n throw new TypeError('justifyLastLine alignment option must be of type boolean');\r\n }\r\n }\r\n\r\n if (opts.relativeIndent !== undefined) {\r\n if (typeof opts.relativeIndent === 'number' && parseInt(opts.relativeIndent) === opts.relativeIndent && opts.relativeIndent > 0) {\r\n this.relativeIndent = opts.relativeIndent;\r\n } else {\r\n throw new TypeError('alignment indent must be a positive integer.');\r\n }\r\n }\r\n\r\n if (opts.shrinkToFit !== undefined) {\r\n if (typeof opts.shrinkToFit === 'boolean') {\r\n this.shrinkToFit = opts.shrinkToFit;\r\n } else {\r\n throw new TypeError('justifyLastLine alignment option must be of type boolean');\r\n }\r\n }\r\n\r\n if (opts.textRotation !== undefined) {\r\n if (typeof opts.textRotation === 'number' && parseInt(opts.textRotation) === opts.textRotation) {\r\n this.textRotation = opts.textRotation;\r\n } else if (opts.textRotation !== undefined) {\r\n throw new TypeError('alignment indent must be an integer.');\r\n }\r\n }\r\n\r\n if (opts.wrapText !== undefined) {\r\n if (typeof opts.wrapText === 'boolean') {\r\n this.wrapText = opts.wrapText;\r\n } else {\r\n throw new TypeError('justifyLastLine alignment option must be of type boolean');\r\n }\r\n }\r\n }\r\n\r\n /** \r\n * @func Alignment.toObject\r\n * @desc Converts the Alignment instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n\r\n this.horizontal !== undefined ? obj.horizontal = this.horizontal : null;\r\n this.indent !== undefined ? obj.indent = this.indent : null;\r\n this.justifyLastLine !== undefined ? obj.justifyLastLine = this.justifyLastLine : null;\r\n this.readingOrder !== undefined ? obj.readingOrder = this.readingOrder : null;\r\n this.relativeIndent !== undefined ? obj.relativeIndent = this.relativeIndent : null;\r\n this.shrinkToFit !== undefined ? obj.shrinkToFit = this.shrinkToFit : null;\r\n this.textRotation !== undefined ? obj.textRotation = this.textRotation : null;\r\n this.vertical !== undefined ? obj.vertical = this.vertical : null;\r\n this.wrapText !== undefined ? obj.wrapText = this.wrapText : null;\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * @alias Alignment.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func Alignment.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n let thisEle = ele.ele('alignment');\r\n this.horizontal !== undefined ? thisEle.att('horizontal', this.horizontal) : null;\r\n this.indent !== undefined ? thisEle.att('indent', this.indent) : null;\r\n this.justifyLastLine === true ? thisEle.att('justifyLastLine', 1) : null;\r\n this.readingOrder !== undefined ? thisEle.att('readingOrder', this.readingOrder) : null;\r\n this.relativeIndent !== undefined ? thisEle.att('relativeIndent', this.relativeIndent) : null;\r\n this.shrinkToFit === true ? thisEle.att('shrinkToFit', 1) : null;\r\n this.textRotation !== undefined ? thisEle.att('textRotation', this.textRotation) : null;\r\n this.vertical !== undefined ? thisEle.att('vertical', this.vertical) : null;\r\n this.wrapText === true ? thisEle.att('wrapText', 1) : null;\r\n }\r\n}\r\n\r\nmodule.exports = Alignment;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/border.js b/distribution/lib/style/classes/border.js new file mode 100644 index 00000000..eaa25973 --- /dev/null +++ b/distribution/lib/style/classes/border.js @@ -0,0 +1,177 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var types = require('../../types/index.js'); +var xmlbuilder = require('xmlbuilder'); +var CTColor = require('./ctColor.js'); + +var BorderOrdinal = function () { + function BorderOrdinal(opts) { + _classCallCheck(this, BorderOrdinal); + + opts = opts ? opts : {}; + if (opts.color !== undefined) { + this.color = new CTColor(opts.color); + } + if (opts.style !== undefined) { + this.style = types.borderStyle.validate(opts.style) === true ? opts.style : null; + } + } + + _createClass(BorderOrdinal, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + if (this.color !== undefined) { + obj.color = this.color.toObject(); + } + if (this.style !== undefined) { + obj.style = this.style; + } + return obj; + } + }]); + + return BorderOrdinal; +}(); + +var Border = function () { + /** + * @class Border + * @desc Border object for Style + * @param {Object} opts Options for Border object + * @param {Object} opts.left Options for left side of Border + * @param {String} opts.left.color HEX represenation of color + * @param {String} opts.left.style Border style + * @param {Object} opts.right Options for right side of Border + * @param {String} opts.right.color HEX represenation of color + * @param {String} opts.right.style Border style + * @param {Object} opts.top Options for top side of Border + * @param {String} opts.top.color HEX represenation of color + * @param {String} opts.top.style Border style + * @param {Object} opts.bottom Options for bottom side of Border + * @param {String} opts.bottom.color HEX represenation of color + * @param {String} opts.bottom.style Border style + * @param {Object} opts.diagonal Options for diagonal side of Border + * @param {String} opts.diagonal.color HEX represenation of color + * @param {String} opts.diagonal.style Border style + * @param {Boolean} opts.outline States whether borders should be applied only to the outside borders of a cell range + * @param {Boolean} opts.diagonalDown States whether diagonal border should go from top left to bottom right + * @param {Boolean} opts.diagonalUp States whether diagonal border should go from bottom left to top right + * @returns {Border} + */ + function Border(opts) { + var _this = this; + + _classCallCheck(this, Border); + + opts = opts ? opts : {}; + this.left; + this.right; + this.top; + this.bottom; + this.diagonal; + this.outline; + this.diagonalDown; + this.diagonalUp; + + Object.keys(opts).forEach(function (opt) { + if (['outline', 'diagonalDown', 'diagonalUp'].indexOf(opt) >= 0) { + if (typeof opts[opt] === 'boolean') { + _this[opt] = opts[opt]; + } else { + throw new TypeError('Border outline option must be of type Boolean'); + } + } else if (['left', 'right', 'top', 'bottom', 'diagonal'].indexOf(opt) < 0) { + //TODO: move logic to types folder + throw new TypeError('Invalid key for border declaration ' + opt + '. Must be one of left, right, top, bottom, diagonal'); + } else { + _this[opt] = new BorderOrdinal(opts[opt]); + } + }); + } + + /** + * @func Border.toObject + * @desc Converts the Border instance to a javascript object + * @returns {Object} + */ + + + _createClass(Border, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + obj.left; + obj.right; + obj.top; + obj.bottom; + obj.diagonal; + + if (this.left !== undefined) { + obj.left = this.left.toObject(); + } + if (this.right !== undefined) { + obj.right = this.right.toObject(); + } + if (this.top !== undefined) { + obj.top = this.top.toObject(); + } + if (this.bottom !== undefined) { + obj.bottom = this.bottom.toObject(); + } + if (this.diagonal !== undefined) { + obj.diagonal = this.diagonal.toObject(); + } + typeof this.outline === 'boolean' ? obj.outline = this.outline : null; + typeof this.diagonalDown === 'boolean' ? obj.diagonalDown = this.diagonalDown : null; + typeof this.diagonalUp === 'boolean' ? obj.diagonalUp = this.diagonalUp : null; + + return obj; + } + + /** + * @alias Border.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func Border.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addToXMLele', + value: function addToXMLele(borderXML) { + var _this2 = this; + + var bXML = borderXML.ele('border'); + if (this.outline === true) { + bXML.att('outline', '1'); + } + if (this.diagonalUp === true) { + bXML.att('diagonalUp', '1'); + } + if (this.diagonalDown === true) { + bXML.att('diagonalDown', '1'); + } + + ['left', 'right', 'top', 'bottom', 'diagonal'].forEach(function (ord) { + var thisOEle = bXML.ele(ord); + if (_this2[ord] !== undefined) { + if (_this2[ord].style !== undefined) { + thisOEle.att('style', _this2[ord].style); + } + if (_this2[ord].color instanceof CTColor) { + _this2[ord].color.addToXMLele(thisOEle); + } + } + }); + } + }]); + + return Border; +}(); + +module.exports = Border; +//# sourceMappingURL=border.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/border.js.map b/distribution/lib/style/classes/border.js.map new file mode 100644 index 00000000..e50e4b0a --- /dev/null +++ b/distribution/lib/style/classes/border.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/border.js"],"names":["types","require","xmlbuilder","CTColor","BorderOrdinal","opts","color","undefined","style","borderStyle","validate","obj","toObject","Border","left","right","top","bottom","diagonal","outline","diagonalDown","diagonalUp","Object","keys","forEach","opt","indexOf","TypeError","borderXML","bXML","ele","att","ord","thisOEle","addToXMLele","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,sBAAR,CAAd;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;AACA,IAAME,UAAUF,QAAQ,cAAR,CAAhB;;IAEMG,a;AACF,2BAAYC,IAAZ,EAAkB;AAAA;;AACdA,eAAOA,OAAOA,IAAP,GAAc,EAArB;AACA,YAAIA,KAAKC,KAAL,KAAeC,SAAnB,EAA8B;AAC1B,iBAAKD,KAAL,GAAa,IAAIH,OAAJ,CAAYE,KAAKC,KAAjB,CAAb;AACH;AACD,YAAID,KAAKG,KAAL,KAAeD,SAAnB,EAA8B;AAC1B,iBAAKC,KAAL,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BAAIC,OAAOD,UAAUE,GAAV,CAAc,QAAd,CAAX;AACA,gBAAI,KAAKX,OAAL,KAAiB,IAArB,EAA2B;AACvBU,qBAAKE,GAAL,CAAS,SAAT,EAAoB,GAApB;AACH;AACD,gBAAI,KAAKV,UAAL,KAAoB,IAAxB,EAA8B;AAC1BQ,qBAAKE,GAAL,CAAS,YAAT,EAAuB,GAAvB;AACH;AACD,gBAAI,KAAKX,YAAL,KAAsB,IAA1B,EAAgC;AAC5BS,qBAAKE,GAAL,CAAS,cAAT,EAAyB,GAAzB;AACH;;AAED,aAAC,MAAD,EAAS,OAAT,EAAkB,KAAlB,EAAyB,QAAzB,EAAmC,UAAnC,EAA+CP,OAA/C,CAAuD,UAACQ,GAAD,EAAS;AAC5D,oBAAIC,WAAWJ,KAAKC,GAAL,CAASE,GAAT,CAAf;AACA,oBAAI,OAAKA,GAAL,MAAczB,SAAlB,EAA6B;AACzB,wBAAI,OAAKyB,GAAL,EAAUxB,KAAV,KAAoBD,SAAxB,EAAmC;AAC/B0B,iCAASF,GAAT,CAAa,OAAb,EAAsB,OAAKC,GAAL,EAAUxB,KAAhC;AACH;AACD,wBAAI,OAAKwB,GAAL,EAAU1B,KAAV,YAA2BH,OAA/B,EAAwC;AACpC,+BAAK6B,GAAL,EAAU1B,KAAV,CAAgB4B,WAAhB,CAA4BD,QAA5B;AACH;AACJ;AACJ,aAVD;AAWH;;;;;;AAGLE,OAAOC,OAAP,GAAiBvB,MAAjB","file":"border.js","sourcesContent":["const types = require('../../types/index.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst CTColor = require('./ctColor.js');\r\n\r\nclass BorderOrdinal {\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n if (opts.color !== undefined) {\r\n this.color = new CTColor(opts.color);\r\n }\r\n if (opts.style !== undefined) {\r\n this.style = types.borderStyle.validate(opts.style) === true ? opts.style : null;\r\n }\r\n }\r\n\r\n toObject() {\r\n let obj = {};\r\n if (this.color !== undefined) {\r\n obj.color = this.color.toObject();\r\n }\r\n if (this.style !== undefined) {\r\n obj.style = this.style;\r\n }\r\n return obj;\r\n }\r\n}\r\n\r\nclass Border {\r\n /** \r\n * @class Border\r\n * @desc Border object for Style\r\n * @param {Object} opts Options for Border object\r\n * @param {Object} opts.left Options for left side of Border\r\n * @param {String} opts.left.color HEX represenation of color\r\n * @param {String} opts.left.style Border style\r\n * @param {Object} opts.right Options for right side of Border\r\n * @param {String} opts.right.color HEX represenation of color\r\n * @param {String} opts.right.style Border style\r\n * @param {Object} opts.top Options for top side of Border\r\n * @param {String} opts.top.color HEX represenation of color\r\n * @param {String} opts.top.style Border style\r\n * @param {Object} opts.bottom Options for bottom side of Border\r\n * @param {String} opts.bottom.color HEX represenation of color\r\n * @param {String} opts.bottom.style Border style\r\n * @param {Object} opts.diagonal Options for diagonal side of Border\r\n * @param {String} opts.diagonal.color HEX represenation of color\r\n * @param {String} opts.diagonal.style Border style\r\n * @param {Boolean} opts.outline States whether borders should be applied only to the outside borders of a cell range\r\n * @param {Boolean} opts.diagonalDown States whether diagonal border should go from top left to bottom right\r\n * @param {Boolean} opts.diagonalUp States whether diagonal border should go from bottom left to top right\r\n * @returns {Border}\r\n */\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n this.left;\r\n this.right;\r\n this.top;\r\n this.bottom;\r\n this.diagonal;\r\n this.outline;\r\n this.diagonalDown;\r\n this.diagonalUp;\r\n\r\n Object.keys(opts).forEach((opt) => {\r\n if (['outline', 'diagonalDown', 'diagonalUp'].indexOf(opt) >= 0) {\r\n if (typeof opts[opt] === 'boolean') {\r\n this[opt] = opts[opt];\r\n } else {\r\n throw new TypeError('Border outline option must be of type Boolean');\r\n }\r\n } else if (['left', 'right', 'top', 'bottom', 'diagonal'].indexOf(opt) < 0) { //TODO: move logic to types folder\r\n throw new TypeError(`Invalid key for border declaration ${opt}. Must be one of left, right, top, bottom, diagonal`);\r\n } else {\r\n this[opt] = new BorderOrdinal(opts[opt]);\r\n }\r\n });\r\n }\r\n\r\n /** \r\n * @func Border.toObject\r\n * @desc Converts the Border instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n obj.left;\r\n obj.right;\r\n obj.top;\r\n obj.bottom;\r\n obj.diagonal;\r\n\r\n if (this.left !== undefined) {\r\n obj.left = this.left.toObject();\r\n }\r\n if (this.right !== undefined) {\r\n obj.right = this.right.toObject();\r\n }\r\n if (this.top !== undefined) {\r\n obj.top = this.top.toObject();\r\n }\r\n if (this.bottom !== undefined) {\r\n obj.bottom = this.bottom.toObject();\r\n }\r\n if (this.diagonal !== undefined) {\r\n obj.diagonal = this.diagonal.toObject();\r\n }\r\n typeof this.outline === 'boolean' ? obj.outline = this.outline : null;\r\n typeof this.diagonalDown === 'boolean' ? obj.diagonalDown = this.diagonalDown : null;\r\n typeof this.diagonalUp === 'boolean' ? obj.diagonalUp = this.diagonalUp : null;\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * @alias Border.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func Border.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(borderXML) {\r\n let bXML = borderXML.ele('border');\r\n if (this.outline === true) {\r\n bXML.att('outline', '1');\r\n }\r\n if (this.diagonalUp === true) {\r\n bXML.att('diagonalUp', '1');\r\n }\r\n if (this.diagonalDown === true) {\r\n bXML.att('diagonalDown', '1');\r\n }\r\n\r\n ['left', 'right', 'top', 'bottom', 'diagonal'].forEach((ord) => {\r\n let thisOEle = bXML.ele(ord);\r\n if (this[ord] !== undefined) {\r\n if (this[ord].style !== undefined) {\r\n thisOEle.att('style', this[ord].style);\r\n }\r\n if (this[ord].color instanceof CTColor) {\r\n this[ord].color.addToXMLele(thisOEle);\r\n }\r\n }\r\n });\r\n }\r\n}\r\n\r\nmodule.exports = Border;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/ctColor.js b/distribution/lib/style/classes/ctColor.js new file mode 100644 index 00000000..7620d880 --- /dev/null +++ b/distribution/lib/style/classes/ctColor.js @@ -0,0 +1,75 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var types = require('../../types/index.js'); +var xmlbuilder = require('xmlbuilder'); + +var CTColor = function () { + //§18.8.3 && §18.8.19 + /** + * @class CTColor + * @desc Excel color representation + * @param {String} color Excel Color scheme or Excel Color name or HEX value of Color + * @properties {String} type Type of color object. defaults to rgb + * @properties {String} rgb ARGB representation of Color + * @properties {String} theme Excel Color Scheme + * @returns {CTColor} + */ + function CTColor(color) { + _classCallCheck(this, CTColor); + + this.type; + this.rgb; + this.theme; //§20.1.6.2 clrScheme (Color Scheme) : types.colorSchemes + + if (typeof color === 'string') { + if (types.colorScheme[color.toLowerCase()] !== undefined) { + this.theme = color; + this.type = 'theme'; + } else { + try { + this.rgb = types.excelColor.getColor(color); + this.type = 'rgb'; + } catch (e) { + throw new TypeError('Fill color must be an RGB value, Excel color (' + types.excelColor.opts.join(', ') + ') or Excel theme (' + types.colorScheme.opts.join(', ') + ')'); + } + } + } + } + + /** + * @func CTColor.toObject + * @desc Converts the CTColor instance to a javascript object + * @returns {Object} + */ + + + _createClass(CTColor, [{ + key: 'toObject', + value: function toObject() { + return this[this.type]; + } + + /** + * @alias CTColor.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func CTColor.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var colorEle = ele.ele('color'); + colorEle.att(this.type, this[this.type]); + } + }]); + + return CTColor; +}(); + +module.exports = CTColor; +//# sourceMappingURL=ctColor.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/ctColor.js.map b/distribution/lib/style/classes/ctColor.js.map new file mode 100644 index 00000000..747d777b --- /dev/null +++ b/distribution/lib/style/classes/ctColor.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/ctColor.js"],"names":["types","require","xmlbuilder","CTColor","color","type","rgb","theme","colorScheme","toLowerCase","undefined","excelColor","getColor","e","TypeError","opts","join","ele","colorEle","att","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,sBAAR,CAAd;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;;IAEME,O;AAAU;AACZ;;;;;;;;;AASA,qBAAYC,KAAZ,EAAmB;AAAA;;AACf,aAAKC,IAAL;AACA,aAAKC,GAAL;AACA,aAAKC,KAAL,CAHe,CAGH;;AAEZ,YAAI,OAAOH,KAAP,KAAiB,QAArB,EAA+B;AAC3B,gBAAIJ,MAAMQ,WAAN,CAAkBJ,MAAMK,WAAN,EAAlB,MAA2CC,SAA/C,EAA0D;AACtD,qBAAKH,KAAL,GAAaH,KAAb;AACA,qBAAKC,IAAL,GAAY,OAAZ;AACH,aAHD,MAGO;AACH,oBAAI;AACA,yBAAKC,GAAL,GAAWN,MAAMW,UAAN,CAAiBC,QAAjB,CAA0BR,KAA1B,CAAX;AACA,yBAAKC,IAAL,GAAY,KAAZ;AACH,iBAHD,CAGE,OAAOQ,CAAP,EAAU;AACR,0BAAM,IAAIC,SAAJ,oDAA+Dd,MAAMW,UAAN,CAAiBI,IAAjB,CAAsBC,IAAtB,CAA2B,IAA3B,CAA/D,0BAAoHhB,MAAMQ,WAAN,CAAkBO,IAAlB,CAAuBC,IAAvB,CAA4B,IAA5B,CAApH,OAAN;AACH;AACJ;AACJ;AACJ;;AAED;;;;;;;;;mCAKW;AACP,mBAAO,KAAK,KAAKX,IAAV,CAAP;AACH;;AAED;;;;;;;;;oCAMYY,G,EAAK;AACb,gBAAIC,WAAWD,IAAIA,GAAJ,CAAQ,OAAR,CAAf;AACAC,qBAASC,GAAT,CAAa,KAAKd,IAAlB,EAAwB,KAAK,KAAKA,IAAV,CAAxB;AACH;;;;;;AAGLe,OAAOC,OAAP,GAAiBlB,OAAjB","file":"ctColor.js","sourcesContent":["const types = require('../../types/index.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\n\r\nclass CTColor { //§18.8.3 && §18.8.19\r\n /** \r\n * @class CTColor\r\n * @desc Excel color representation\r\n * @param {String} color Excel Color scheme or Excel Color name or HEX value of Color\r\n * @properties {String} type Type of color object. defaults to rgb\r\n * @properties {String} rgb ARGB representation of Color\r\n * @properties {String} theme Excel Color Scheme\r\n * @returns {CTColor}\r\n */\r\n constructor(color) {\r\n this.type;\r\n this.rgb;\r\n this.theme; //§20.1.6.2 clrScheme (Color Scheme) : types.colorSchemes\r\n\r\n if (typeof color === 'string') {\r\n if (types.colorScheme[color.toLowerCase()] !== undefined) {\r\n this.theme = color;\r\n this.type = 'theme';\r\n } else {\r\n try {\r\n this.rgb = types.excelColor.getColor(color);\r\n this.type = 'rgb';\r\n } catch (e) {\r\n throw new TypeError(`Fill color must be an RGB value, Excel color (${types.excelColor.opts.join(', ')}) or Excel theme (${types.colorScheme.opts.join(', ')})`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** \r\n * @func CTColor.toObject\r\n * @desc Converts the CTColor instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n return this[this.type];\r\n }\r\n\r\n /**\r\n * @alias CTColor.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func CTColor.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n let colorEle = ele.ele('color');\r\n colorEle.att(this.type, this[this.type]);\r\n }\r\n}\r\n\r\nmodule.exports = CTColor;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/fill.js b/distribution/lib/style/classes/fill.js new file mode 100644 index 00000000..eab3c1b8 --- /dev/null +++ b/distribution/lib/style/classes/fill.js @@ -0,0 +1,209 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var types = require('../../types/index.js'); +var xmlbuilder = require('xmlbuilder'); +var CTColor = require('./ctColor.js'); + +var Stop = function () { + //§18.8.38 + /** + * @class Stop + * @desc Stops for Gradient fills + * @param {Object} opts Options for Stop + * @param {String} opts.color Color of Stop + * @param {Number} opts.position Order of Stop with first stop being 0 + * @returns {Stop} + */ + function Stop(opts, position) { + _classCallCheck(this, Stop); + + this.color = new CTColor(opts.color); + this.position = position; + } + + /** + * @func Stop.toObject + * @desc Converts the Stop instance to a javascript object + * @returns {Object} + */ + + + _createClass(Stop, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + this.color !== undefined ? obj.color = this.color.toObject() : null; + this.position !== undefined ? obj.position = this.position : null; + return obj; + } + }]); + + return Stop; +}(); + +var Fill = function () { + //§18.8.20 fill (Fill) + + /** + * @class Fill + * @desc Excel Fill + * @param {Object} opts + * @param {String} opts.type Type of Excel fill (gradient or pattern) + * @param {Number} opts.bottom If Gradient fill, the position of the bottom edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1) + * @param {Number} opts.top If Gradient fill, the position of the top edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1) + * @param {Number} opts.left If Gradient fill, the position of the left edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1) + * @param {Number} opts.right If Gradient fill, the position of the right edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1) + * @param {Number} opts.degree Angle of the Gradient + * @param {Array.Stop} opts.stops Array of position stops for gradient + * @returns {Fill} + */ + function Fill(opts) { + var _this = this; + + _classCallCheck(this, Fill); + + if (['gradient', 'pattern', 'none'].indexOf(opts.type) >= 0) { + this.type = opts.type; + } else { + throw new TypeError('Fill type must be one of gradient, pattern or none.'); + } + + switch (this.type) { + case 'gradient': + //§18.8.24 + if (opts.bottom !== undefined) { + if (opts.bottom < 0 || opts.bottom > 1) { + throw new TypeError('Values for gradient fill bottom attribute must be a decimal between 0 and 1'); + } else { + this.bottom = opts.bottom; + } + } + + if (opts.degree !== undefined) { + if (typeof opts.degree === 'number') { + this.degree = opts.degree; + } else { + throw new TypeError('Values of gradient fill degree must be of type number.'); + } + } + + if (opts.left !== undefined) { + if (opts.left < 0 || opts.left > 1) { + throw new TypeError('Values for gradient fill left attribute must be a decimal between 0 and 1'); + } else { + this.left = opts.left; + } + } + + if (opts.right !== undefined) { + if (opts.right < 0 || opts.right > 1) { + throw new TypeError('Values for gradient fill right attribute must be a decimal between 0 and 1'); + } else { + this.right = opts.right; + } + } + + if (opts.top !== undefined) { + if (opts.top < 0 || opts.top > 1) { + throw new TypeError('Values for gradient fill top attribute must be a decimal between 0 and 1'); + } else { + this.top = opts.top; + } + } + + if (opts.stops !== undefined) { + if (opts.stops instanceof Array) { + opts.stops.forEach(function (s, i) { + _this.stops.push(new Stop(s, i)); + }); + } else { + throw new TypeError('Stops for gradient fills must be sent as an Array'); + } + } + + break; + + case 'pattern': + //§18.8.32 + if (opts.bgColor !== undefined) { + this.bgColor = new CTColor(opts.bgColor); + } + + if (opts.fgColor !== undefined) { + this.fgColor = new CTColor(opts.fgColor); + } + + if (opts.patternType !== undefined) { + types.fillPattern.validate(opts.patternType) === true ? this.patternType = opts.patternType : null; + } + break; + + case 'none': + this.patternType = 'none'; + break; + } + } + + /** + * @func Fill.toObject + * @desc Converts the Fill instance to a javascript object + * @returns {Object} + */ + + + _createClass(Fill, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + + this.type !== undefined ? obj.type = this.type : null; + this.bottom !== undefined ? obj.bottom = this.bottom : null; + this.degree !== undefined ? obj.degree = this.degree : null; + this.left !== undefined ? obj.left = this.left : null; + this.right !== undefined ? obj.right = this.right : null; + this.top !== undefined ? obj.top = this.top : null; + this.bgColor !== undefined ? obj.bgColor = this.bgColor.toObject() : null; + this.fgColor !== undefined ? obj.fgColor = this.fgColor.toObject() : null; + this.patternType !== undefined ? obj.patternType = this.patternType : null; + + if (this.stops !== undefined) { + obj.stop = []; + this.stops.forEach(function (s) { + obj.stops.push(s.toObject()); + }); + } + + return obj; + } + + /** + * @alias Fill.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func Fill.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addToXMLele', + value: function addToXMLele(fXML) { + var pFill = fXML.ele('patternFill').att('patternType', this.patternType); + + if (this.fgColor instanceof CTColor) { + pFill.ele('fgColor').att(this.fgColor.type, this.fgColor[this.fgColor.type]); + } + + if (this.bgColor instanceof CTColor) { + pFill.ele('bgColor').att(this.bgColor.type, this.bgColor[this.bgColor.type]); + } + } + }]); + + return Fill; +}(); + +module.exports = Fill; +//# sourceMappingURL=fill.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/fill.js.map b/distribution/lib/style/classes/fill.js.map new file mode 100644 index 00000000..edd4152c --- /dev/null +++ b/distribution/lib/style/classes/fill.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/fill.js"],"names":["types","require","xmlbuilder","CTColor","Stop","opts","position","color","obj","undefined","toObject","Fill","indexOf","type","TypeError","bottom","degree","left","right","top","stops","Array","forEach","s","i","push","bgColor","fgColor","patternType","fillPattern","validate","stop","fXML","pFill","ele","att","module","exports"],"mappings":";;;;;;AAAA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or = require('./ctColor.js');\r\n\r\nclass Stop { //§18.8.38\r\n /** \r\n * @class Stop\r\n * @desc Stops for Gradient fills\r\n * @param {Object} opts Options for Stop\r\n * @param {String} opts.color Color of Stop\r\n * @param {Number} opts.position Order of Stop with first stop being 0\r\n * @returns {Stop}\r\n */\r\n constructor(opts, position) {\r\n this.color = new CTColor(opts.color);\r\n this.position = position;\r\n }\r\n\r\n /** \r\n * @func Stop.toObject\r\n * @desc Converts the Stop instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n this.color !== undefined ? obj.color = this.color.toObject() : null;\r\n this.position !== undefined ? obj.position = this.position : null;\r\n return obj;\r\n }\r\n}\r\n\r\nclass Fill { //§18.8.20 fill (Fill)\r\n\r\n /** \r\n * @class Fill\r\n * @desc Excel Fill \r\n * @param {Object} opts\r\n * @param {String} opts.type Type of Excel fill (gradient or pattern)\r\n * @param {Number} opts.bottom If Gradient fill, the position of the bottom edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1)\r\n * @param {Number} opts.top If Gradient fill, the position of the top edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1)\r\n * @param {Number} opts.left If Gradient fill, the position of the left edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1)\r\n * @param {Number} opts.right If Gradient fill, the position of the right edge of the inner rectange as a percentage in decimal form. (must be between 0 and 1)\r\n * @param {Number} opts.degree Angle of the Gradient\r\n * @param {Array.Stop} opts.stops Array of position stops for gradient\r\n * @returns {Fill}\r\n */\r\n constructor(opts) {\r\n\r\n if (['gradient', 'pattern', 'none'].indexOf(opts.type) >= 0) {\r\n this.type = opts.type;\r\n } else {\r\n throw new TypeError('Fill type must be one of gradient, pattern or none.');\r\n }\r\n\r\n switch (this.type) {\r\n case 'gradient': //§18.8.24\r\n if (opts.bottom !== undefined) {\r\n if (opts.bottom < 0 || opts.bottom > 1) {\r\n throw new TypeError('Values for gradient fill bottom attribute must be a decimal between 0 and 1');\r\n } else {\r\n this.bottom = opts.bottom;\r\n }\r\n }\r\n\r\n if (opts.degree !== undefined) {\r\n if (typeof opts.degree === 'number') {\r\n this.degree = opts.degree;\r\n } else {\r\n throw new TypeError('Values of gradient fill degree must be of type number.');\r\n }\r\n }\r\n\r\n\r\n if (opts.left !== undefined) {\r\n if (opts.left < 0 || opts.left > 1) {\r\n throw new TypeError('Values for gradient fill left attribute must be a decimal between 0 and 1');\r\n } else {\r\n this.left = opts.left;\r\n }\r\n }\r\n\r\n if (opts.right !== undefined) {\r\n if (opts.right < 0 || opts.right > 1) {\r\n throw new TypeError('Values for gradient fill right attribute must be a decimal between 0 and 1');\r\n } else {\r\n this.right = opts.right;\r\n }\r\n }\r\n\r\n if (opts.top !== undefined) {\r\n if (opts.top < 0 || opts.top > 1) {\r\n throw new TypeError('Values for gradient fill top attribute must be a decimal between 0 and 1');\r\n } else {\r\n this.top = opts.top;\r\n }\r\n }\r\n\r\n if (opts.stops !== undefined) {\r\n if (opts.stops instanceof Array) {\r\n opts.stops.forEach((s, i) => {\r\n this.stops.push(new Stop(s, i));\r\n });\r\n } else {\r\n throw new TypeError('Stops for gradient fills must be sent as an Array');\r\n }\r\n }\r\n\r\n break;\r\n\r\n case 'pattern': //§18.8.32\r\n if (opts.bgColor !== undefined) {\r\n this.bgColor = new CTColor(opts.bgColor);\r\n }\r\n\r\n if (opts.fgColor !== undefined) {\r\n this.fgColor = new CTColor(opts.fgColor);\r\n }\r\n\r\n if (opts.patternType !== undefined) {\r\n types.fillPattern.validate(opts.patternType) === true ? this.patternType = opts.patternType : null;\r\n }\r\n break;\r\n\r\n case 'none':\r\n this.patternType = 'none';\r\n break;\r\n }\r\n }\r\n\r\n /** \r\n * @func Fill.toObject\r\n * @desc Converts the Fill instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n\r\n this.type !== undefined ? obj.type = this.type : null;\r\n this.bottom !== undefined ? obj.bottom = this.bottom : null;\r\n this.degree !== undefined ? obj.degree = this.degree : null;\r\n this.left !== undefined ? obj.left = this.left : null;\r\n this.right !== undefined ? obj.right = this.right : null;\r\n this.top !== undefined ? obj.top = this.top : null;\r\n this.bgColor !== undefined ? obj.bgColor = this.bgColor.toObject() : null;\r\n this.fgColor !== undefined ? obj.fgColor = this.fgColor.toObject() : null;\r\n this.patternType !== undefined ? obj.patternType = this.patternType : null;\r\n\r\n if (this.stops !== undefined) {\r\n obj.stop = [];\r\n this.stops.forEach((s) => {\r\n obj.stops.push(s.toObject());\r\n });\r\n }\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * @alias Fill.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func Fill.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(fXML) {\r\n let pFill = fXML.ele('patternFill').att('patternType', this.patternType);\r\n\r\n if (this.fgColor instanceof CTColor) {\r\n pFill.ele('fgColor').att(this.fgColor.type, this.fgColor[this.fgColor.type]);\r\n }\r\n\r\n if (this.bgColor instanceof CTColor) {\r\n pFill.ele('bgColor').att(this.bgColor.type, this.bgColor[this.bgColor.type]);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Fill;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/font.js b/distribution/lib/style/classes/font.js new file mode 100644 index 00000000..16198509 --- /dev/null +++ b/distribution/lib/style/classes/font.js @@ -0,0 +1,129 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var xmlbuilder = require('xmlbuilder'); +var types = require('../../types/index.js'); + +var Font = function () { + /** + * @class Font + * @desc Instance of Font with properties + * @param {Object} opts Options for Font + * @param {String} opts.color HEX color of font + * @param {String} opts.name Name of Font. i.e. Calibri + * @param {String} opts.scheme Font Scheme. defaults to major + * @param {Number} opts.size Pt size of Font + * @param {String} opts.family Font Family. defaults to roman + * @param {String} opts.vertAlign Specifies font as subscript or superscript + * @param {Number} opts.charset Character set of font as defined in §18.4.1 charset (Character Set) or standard + * @param {Boolean} opts.condense Macintosh compatibility settings to squeeze text together when rendering + * @param {Boolean} opts.extend Stretches out the text when rendering + * @param {Boolean} opts.bold States whether font should be bold + * @param {Boolean} opts.italics States whether font should be in italics + * @param {Boolean} opts.outline States whether font should be outlined + * @param {Boolean} opts.shadow States whether font should have a shadow + * @param {Boolean} opts.strike States whether font should have a strikethrough + * @param {Boolean} opts.underline States whether font should be underlined + * @retuns {Font} + */ + function Font(opts) { + _classCallCheck(this, Font); + + opts = opts ? opts : {}; + + typeof opts.color === 'string' ? this.color = types.excelColor.getColor(opts.color) : null; + typeof opts.name === 'string' ? this.name = opts.name : null; + typeof opts.scheme === 'string' ? this.scheme = opts.scheme : null; + typeof opts.size === 'number' ? this.size = opts.size : null; + typeof opts.family === 'string' && types.fontFamily.validate(opts.family) === true ? this.family = opts.family : null; + + typeof opts.vertAlign === 'string' ? this.vertAlign = opts.vertAlign : null; + typeof opts.charset === 'number' ? this.charset = opts.charset : null; + + typeof opts.condense === 'boolean' ? this.condense = opts.condense : null; + typeof opts.extend === 'boolean' ? this.extend = opts.extend : null; + typeof opts.bold === 'boolean' ? this.bold = opts.bold : null; + typeof opts.italics === 'boolean' ? this.italics = opts.italics : null; + typeof opts.outline === 'boolean' ? this.outline = opts.outline : null; + typeof opts.shadow === 'boolean' ? this.shadow = opts.shadow : null; + typeof opts.strike === 'boolean' ? this.strike = opts.strike : null; + typeof opts.underline === 'boolean' ? this.underline = opts.underline : null; + } + + /** + * @func Font.toObject + * @desc Converts the Font instance to a javascript object + * @returns {Object} + */ + + + _createClass(Font, [{ + key: 'toObject', + value: function toObject() { + var obj = {}; + + typeof this.charset === 'number' ? obj.charset = this.charset : null; + typeof this.color === 'string' ? obj.color = this.color : null; + typeof this.family === 'string' ? obj.family = this.family : null; + typeof this.name === 'string' ? obj.name = this.name : null; + typeof this.scheme === 'string' ? obj.scheme = this.scheme : null; + typeof this.size === 'number' ? obj.size = this.size : null; + typeof this.vertAlign === 'string' ? obj.vertAlign = this.vertAlign : null; + + typeof this.condense === 'boolean' ? obj.condense = this.condense : null; + typeof this.extend === 'boolean' ? obj.extend = this.extend : null; + typeof this.bold === 'boolean' ? obj.bold = this.bold : null; + typeof this.italics === 'boolean' ? obj.italics = this.italics : null; + typeof this.outline === 'boolean' ? obj.outline = this.outline : null; + typeof this.shadow === 'boolean' ? obj.shadow = this.shadow : null; + typeof this.strike === 'boolean' ? obj.strike = this.strike : null; + typeof this.underline === 'boolean' ? obj.underline = this.underline : null; + + return obj; + } + + /** + * @alias Font.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func Font.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addToXMLele', + value: function addToXMLele(fontXML) { + var fEle = fontXML.ele('font'); + + // Place styling elements first to avoid validation errors with .NET validator + this.condense === true ? fEle.ele('condense') : null; + this.extend === true ? fEle.ele('extend') : null; + this.bold === true ? fEle.ele('b') : null; + this.italics === true ? fEle.ele('i') : null; + this.outline === true ? fEle.ele('outline') : null; + this.shadow === true ? fEle.ele('shadow') : null; + this.strike === true ? fEle.ele('strike') : null; + this.underline === true ? fEle.ele('u') : null; + this.vertAlign === true ? fEle.ele('vertAlign') : null; + + fEle.ele('sz').att('val', this.size !== undefined ? this.size : 12); + fEle.ele('color').att('rgb', this.color !== undefined ? this.color : 'FF000000'); + fEle.ele('name').att('val', this.name !== undefined ? this.name : 'Calibri'); + if (this.family !== undefined) { + fEle.ele('family').att('val', types.fontFamily[this.family.toLowerCase()]); + } + if (this.scheme !== undefined) { + fEle.ele('scheme').att('val', this.scheme); + } + + return true; + } + }]); + + return Font; +}(); + +module.exports = Font; +//# sourceMappingURL=font.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/font.js.map b/distribution/lib/style/classes/font.js.map new file mode 100644 index 00000000..79ee00a2 --- /dev/null +++ b/distribution/lib/style/classes/font.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/font.js"],"names":["xmlbuilder","require","types","Font","opts","color","excelColor","getColor","name","scheme","size","family","fontFamily","validate","vertAlign","charset","condense","extend","bold","italics","outline","shadow","strike","underline","obj","fontXML","fEle","ele","att","undefined","toLowerCase","module","exports"],"mappings":";;;;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ,sBAAR,CAAd;;IAEME,I;AACF;;;;;;;;;;;;;;;;;;;;;AAqBA,sBAAYC,IAAZ,EAAkB;AAAA;;AACdA,uBAAOA,OAAOA,IAAP,GAAc,EAArB;;AAEA,uBAAOA,KAAKC,KAAZ,KAAsB,QAAtB,GAAiC,KAAKA,KAAL,GAAaH,MAAMI,UAAN,CAAiBC,QAAjB,CAA0BH,KAAKC,KAA/B,CAA9C,GAAsF,IAAtF;AACA,uBAAOD,KAAKI,IAAZ,KAAqB,QAArB,GAAgC,KAAKA,IAAL,GAAYJ,KAAKI,IAAjD,GAAwD,IAAxD;AACA,uBAAOJ,KAAKK,MAAZ,KAAuB,QAAvB,GAAkC,KAAKA,MAAL,GAAcL,KAAKK,MAArD,GAA8D,IAA9D;AACA,uBAAOL,KAAKM,IAAZ,KAAqB,QAArB,GAAgC,KAAKA,IAAL,GAAYN,KAAKM,IAAjD,GAAwD,IAAxD;AACA,uBAAON,KAAKO,MAAZ,KAAuB,QAAvB,IAAmCT,MAAMU,UAAN,CAAiBC,QAAjB,CAA0BT,KAAKO,MAA/B,MAA2C,IAA9E,GAAqF,KAAKA,MAAL,GAAcP,KAAKO,MAA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AAL,KAAewB,SAAf,GAA2B,KAAKxB,KAAhC,GAAwC,UAArE;AACAqB,6BAAKC,GAAL,CAAS,MAAT,EAAiBC,GAAjB,CAAqB,KAArB,EAA4B,KAAKpB,IAAL,KAAcqB,SAAd,GAA0B,KAAKrB,IAA/B,GAAsC,SAAlE;AACA,4BAAI,KAAKG,MAAL,KAAgBkB,SAApB,EAA+B;AAC3BH,qCAAKC,GAAL,CAAS,QAAT,EAAmBC,GAAnB,CAAuB,KAAvB,EAA8B1B,MAAMU,UAAN,CAAiB,KAAKD,MAAL,CAAYmB,WAAZ,EAAjB,CAA9B;AACH;AACD,4BAAI,KAAKrB,MAAL,KAAgBoB,SAApB,EAA+B;AAC3BH,qCAAKC,GAAL,CAAS,QAAT,EAAmBC,GAAnB,CAAuB,KAAvB,EAA8B,KAAKnB,MAAnC;AACH;;AAGD,+BAAO,IAAP;AACH;;;;;;AAKLsB,OAAOC,OAAP,GAAiB7B,IAAjB","file":"font.js","sourcesContent":["const xmlbuilder = require('xmlbuilder');\r\nconst types = require('../../types/index.js');\r\n\r\nclass Font {\r\n /**\r\n * @class Font\r\n * @desc Instance of Font with properties\r\n * @param {Object} opts Options for Font\r\n * @param {String} opts.color HEX color of font\r\n * @param {String} opts.name Name of Font. i.e. Calibri\r\n * @param {String} opts.scheme Font Scheme. defaults to major\r\n * @param {Number} opts.size Pt size of Font\r\n * @param {String} opts.family Font Family. defaults to roman\r\n * @param {String} opts.vertAlign Specifies font as subscript or superscript\r\n * @param {Number} opts.charset Character set of font as defined in §18.4.1 charset (Character Set) or standard\r\n * @param {Boolean} opts.condense Macintosh compatibility settings to squeeze text together when rendering\r\n * @param {Boolean} opts.extend Stretches out the text when rendering\r\n * @param {Boolean} opts.bold States whether font should be bold\r\n * @param {Boolean} opts.italics States whether font should be in italics\r\n * @param {Boolean} opts.outline States whether font should be outlined\r\n * @param {Boolean} opts.shadow States whether font should have a shadow\r\n * @param {Boolean} opts.strike States whether font should have a strikethrough\r\n * @param {Boolean} opts.underline States whether font should be underlined\r\n * @retuns {Font}\r\n */\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n\r\n typeof opts.color === 'string' ? this.color = types.excelColor.getColor(opts.color) : null;\r\n typeof opts.name === 'string' ? this.name = opts.name : null;\r\n typeof opts.scheme === 'string' ? this.scheme = opts.scheme : null;\r\n typeof opts.size === 'number' ? this.size = opts.size : null;\r\n typeof opts.family === 'string' && types.fontFamily.validate(opts.family) === true ? this.family = opts.family : null;\r\n\r\n typeof opts.vertAlign === 'string' ? this.vertAlign = opts.vertAlign : null;\r\n typeof opts.charset === 'number' ? this.charset = opts.charset : null;\r\n\r\n typeof opts.condense === 'boolean' ? this.condense = opts.condense : null;\r\n typeof opts.extend === 'boolean' ? this.extend = opts.extend : null;\r\n typeof opts.bold === 'boolean' ? this.bold = opts.bold : null;\r\n typeof opts.italics === 'boolean' ? this.italics = opts.italics : null;\r\n typeof opts.outline === 'boolean' ? this.outline = opts.outline : null;\r\n typeof opts.shadow === 'boolean' ? this.shadow = opts.shadow : null;\r\n typeof opts.strike === 'boolean' ? this.strike = opts.strike : null;\r\n typeof opts.underline === 'boolean' ? this.underline = opts.underline : null;\r\n }\r\n\r\n /** \r\n * @func Font.toObject\r\n * @desc Converts the Font instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n\r\n typeof this.charset === 'number' ? obj.charset = this.charset : null;\r\n typeof this.color === 'string' ? obj.color = this.color : null;\r\n typeof this.family === 'string' ? obj.family = this.family : null;\r\n typeof this.name === 'string' ? obj.name = this.name : null;\r\n typeof this.scheme === 'string' ? obj.scheme = this.scheme : null;\r\n typeof this.size === 'number' ? obj.size = this.size : null;\r\n typeof this.vertAlign === 'string' ? obj.vertAlign = this.vertAlign : null;\r\n\r\n typeof this.condense === 'boolean' ? obj.condense = this.condense : null;\r\n typeof this.extend === 'boolean' ? obj.extend = this.extend : null;\r\n typeof this.bold === 'boolean' ? obj.bold = this.bold : null;\r\n typeof this.italics === 'boolean' ? obj.italics = this.italics : null;\r\n typeof this.outline === 'boolean' ? obj.outline = this.outline : null;\r\n typeof this.shadow === 'boolean' ? obj.shadow = this.shadow : null;\r\n typeof this.strike === 'boolean' ? obj.strike = this.strike : null;\r\n typeof this.underline === 'boolean' ? obj.underline = this.underline : null;\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * @alias Font.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func Font.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(fontXML) {\r\n let fEle = fontXML.ele('font');\r\n\r\n // Place styling elements first to avoid validation errors with .NET validator\r\n this.condense === true ? fEle.ele('condense') : null;\r\n this.extend === true ? fEle.ele('extend') : null;\r\n this.bold === true ? fEle.ele('b') : null;\r\n this.italics === true ? fEle.ele('i') : null;\r\n this.outline === true ? fEle.ele('outline') : null;\r\n this.shadow === true ? fEle.ele('shadow') : null;\r\n this.strike === true ? fEle.ele('strike') : null;\r\n this.underline === true ? fEle.ele('u') : null;\r\n this.vertAlign === true ? fEle.ele('vertAlign') : null;\r\n\r\n fEle.ele('sz').att('val', this.size !== undefined ? this.size : 12);\r\n fEle.ele('color').att('rgb', this.color !== undefined ? this.color : 'FF000000');\r\n fEle.ele('name').att('val', this.name !== undefined ? this.name : 'Calibri');\r\n if (this.family !== undefined) {\r\n fEle.ele('family').att('val', types.fontFamily[this.family.toLowerCase()]);\r\n }\r\n if (this.scheme !== undefined) {\r\n fEle.ele('scheme').att('val', this.scheme);\r\n }\r\n\r\n\r\n return true;\r\n }\r\n\r\n\r\n}\r\n\r\nmodule.exports = Font;"]} \ No newline at end of file diff --git a/distribution/lib/style/classes/numberFormat.js b/distribution/lib/style/classes/numberFormat.js new file mode 100644 index 00000000..8efdc3c3 --- /dev/null +++ b/distribution/lib/style/classes/numberFormat.js @@ -0,0 +1,49 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var NumberFormat = function () { + /** + * @class NumberFormat + * @param {String} fmt Format of the Number + * @returns {NumberFormat} + */ + function NumberFormat(fmt) { + _classCallCheck(this, NumberFormat); + + this.formatCode = fmt; + this.id; + } + + _createClass(NumberFormat, [{ + key: 'addToXMLele', + + + /** + * @alias NumberFormat.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func NumberFormat.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + value: function addToXMLele(ele) { + if (this.formatCode !== undefined) { + ele.ele('numFmt').att('formatCode', this.formatCode).att('numFmtId', this.numFmtId); + } + } + }, { + key: 'numFmtId', + get: function get() { + return this.id; + }, + set: function set(id) { + this.id = id; + } + }]); + + return NumberFormat; +}(); + +module.exports = NumberFormat; +//# sourceMappingURL=numberFormat.js.map \ No newline at end of file diff --git a/distribution/lib/style/classes/numberFormat.js.map b/distribution/lib/style/classes/numberFormat.js.map new file mode 100644 index 00000000..d2c01527 --- /dev/null +++ b/distribution/lib/style/classes/numberFormat.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/style/classes/numberFormat.js"],"names":["NumberFormat","fmt","formatCode","id","ele","undefined","att","numFmtId","module","exports"],"mappings":";;;;;;IAAMA,Y;AACF;;;;;AAKA,0BAAYC,GAAZ,EAAiB;AAAA;;AACb,aAAKC,UAAL,GAAkBD,GAAlB;AACA,aAAKE,EAAL;AACH;;;;;;AASD;;;;;;oCAMYC,G,EAAK;AACb,gBAAI,KAAKF,UAAL,KAAoBG,SAAxB,EAAmC;AAC/BD,oBAAIA,GAAJ,CAAQ,QAAR,EACCE,GADD,CACK,YADL,EACmB,KAAKJ,UADxB,EAECI,GAFD,CAEK,UAFL,EAEiB,KAAKC,QAFtB;AAGH;AACJ;;;4BAnBc;AACX,mBAAO,KAAKJ,EAAZ;AACH,S;0BACYA,E,EAAI;AACb,iBAAKA,EAAL,GAAUA,EAAV;AACH;;;;;;AAiBLK,OAAOC,OAAP,GAAiBT,YAAjB","file":"numberFormat.js","sourcesContent":["class NumberFormat {\r\n /**\r\n * @class NumberFormat\r\n * @param {String} fmt Format of the Number\r\n * @returns {NumberFormat}\r\n */\r\n constructor(fmt) {\r\n this.formatCode = fmt;\r\n this.id;\r\n }\r\n\r\n get numFmtId() {\r\n return this.id;\r\n }\r\n set numFmtId(id) {\r\n this.id = id;\r\n }\r\n\r\n /**\r\n * @alias NumberFormat.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func NumberFormat.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n if (this.formatCode !== undefined) {\r\n ele.ele('numFmt')\r\n .att('formatCode', this.formatCode)\r\n .att('numFmtId', this.numFmtId);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = NumberFormat;"]} \ No newline at end of file diff --git a/distribution/lib/style/index.js b/distribution/lib/style/index.js new file mode 100644 index 00000000..7e02c120 --- /dev/null +++ b/distribution/lib/style/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./style.js'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/style/index.js.map b/distribution/lib/style/index.js.map new file mode 100644 index 00000000..27b6e655 --- /dev/null +++ b/distribution/lib/style/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/style/index.js"],"names":["module","exports","require"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiBC,QAAQ,YAAR,CAAjB","file":"index.js","sourcesContent":["module.exports = require('./style.js');"]} \ No newline at end of file diff --git a/distribution/lib/style/style.js b/distribution/lib/style/style.js new file mode 100644 index 00000000..e8d3ffa8 --- /dev/null +++ b/distribution/lib/style/style.js @@ -0,0 +1,361 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var utils = require('../utils.js'); +var deepmerge = require('deepmerge'); + +var Alignment = require('./classes/alignment.js'); +var Border = require('./classes/border.js'); +var Fill = require('./classes/fill.js'); +var Font = require('./classes/font.js'); +var NumberFormat = require('./classes/numberFormat.js'); + +var _getFontId = function _getFontId(wb) { + var font = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + + // Create the Font and lookup key + font = deepmerge(wb.opts.defaultFont, font); + var thisFont = new Font(font); + var lookupKey = JSON.stringify(thisFont.toObject()); + + // Find an existing entry, creating a new one if it does not exist + var id = wb.styleDataLookup.fonts[lookupKey]; + if (id === undefined) { + id = wb.styleData.fonts.push(thisFont) - 1; + wb.styleDataLookup.fonts[lookupKey] = id; + } + + return id; +}; + +var _getFillId = function _getFillId(wb, fill) { + if (fill === undefined) { + return null; + } + + // Create the Fill and lookup key + var thisFill = new Fill(fill); + var lookupKey = JSON.stringify(thisFill.toObject()); + + // Find an existing entry, creating a new one if it does not exist + var id = wb.styleDataLookup.fills[lookupKey]; + if (id === undefined) { + id = wb.styleData.fills.push(thisFill) - 1; + wb.styleDataLookup.fills[lookupKey] = id; + } + + return id; +}; + +var _getBorderId = function _getBorderId(wb, border) { + if (border === undefined) { + return null; + } + + // Create the Border and lookup key + var thisBorder = new Border(border); + var lookupKey = JSON.stringify(thisBorder.toObject()); + + // Find an existing entry, creating a new one if it does not exist + var id = wb.styleDataLookup.borders[lookupKey]; + if (id === undefined) { + id = wb.styleData.borders.push(thisBorder) - 1; + wb.styleDataLookup.borders[lookupKey] = id; + } + + return id; +}; + +var _getNumFmt = function _getNumFmt(wb, val) { + var fmt = void 0; + wb.styleData.numFmts.forEach(function (f) { + if (f.formatCode === val) { + fmt = f; + } + }); + + if (fmt === undefined) { + var fmtId = wb.styleData.numFmts.length + 164; + fmt = new NumberFormat(val); + fmt.numFmtId = fmtId; + wb.styleData.numFmts.push(fmt); + } + + return fmt; +}; + +/* + Style Opts + { + alignment: { // §18.8.1 + horizontal: ['center', 'centerContinuous', 'distributed', 'fill', 'general', 'justify', 'left', 'right'], + indent: integer, // Number of spaces to indent = indent value * 3 + justifyLastLine: boolean, + readingOrder: ['contextDependent', 'leftToRight', 'rightToLeft'], + relativeIndent: integer, // number of additional spaces to indent + shrinkToFit: boolean, + textRotation: integer, // number of degrees to rotate text counter-clockwise + vertical: ['bottom', 'center', 'distributed', 'justify', 'top'], + wrapText: boolean + }, + font: { // §18.8.22 + bold: boolean, + charset: integer, + color: string, + condense: boolean, + extend: boolean, + family: string, + italics: boolean, + name: string, + outline: boolean, + scheme: string, // §18.18.33 ST_FontScheme (Font scheme Styles) + shadow: boolean, + strike: boolean, + size: integer, + underline: boolean, + vertAlign: string // §22.9.2.17 ST_VerticalAlignRun (Vertical Positioning Location) + }, + border: { // §18.8.4 border (Border) + left: { + style: string, + color: string + }, + right: { + style: string, + color: string + }, + top: { + style: string, + color: string + }, + bottom: { + style: string, + color: string + }, + diagonal: { + style: string, + color: string + }, + diagonalDown: boolean, + diagonalUp: boolean, + outline: boolean + }, + fill: { // §18.8.20 fill (Fill) + type: 'pattern', + patternType: 'solid', + color: 'Yellow' + }, + numberFormat: integer or string // §18.8.30 numFmt (Number Format) + } +*/ + +var Style = function () { + function Style(wb, opts) { + _classCallCheck(this, Style); + + /** + * Excel Style object + * @class Style + * @desc Style object for formatting Excel Cells + * @param {Workbook} wb Excel Workbook object + * @param {Object} opts Options for style + * @param {Object} opts.alignment Options for creating an Alignment instance + * @param {Object} opts.font Options for creating a Font instance + * @param {Object} opts.border Options for creating a Border instance + * @param {Object} opts.fill Options for creating a Fill instance + * @param {String} opts.numberFormat + * @property {Alignment} alignment Alignment instance associated with Style + * @property {Border} border Border instance associated with Style + * @property {Number} borderId ID of Border instance in the Workbook + * @property {Fill} fill Fill instance associated with Style + * @property {Number} fillId ID of Fill instance in the Workbook + * @property {Font} font Font instance associated with Style + * @property {Number} fontId ID of Font instance in the Workbook + * @property {String} numberFormat String represenation of the way a number should be formatted + * @property {Number} xf XF id of the Style in the Workbook + * @returns {Style} + */ + opts = opts ? opts : {}; + opts = deepmerge(wb.styles[0] ? wb.styles[0] : {}, opts); + + if (opts.alignment !== undefined) { + this.alignment = new Alignment(opts.alignment); + } + + if (opts.border !== undefined) { + this.borderId = _getBorderId(wb, opts.border); // attribute 0 based index + this.border = wb.styleData.borders[this.borderId]; + } + if (opts.fill !== undefined) { + this.fillId = _getFillId(wb, opts.fill); // attribute 0 based index + this.fill = wb.styleData.fills[this.fillId]; + } + + if (opts.font !== undefined) { + this.fontId = _getFontId(wb, opts.font); // attribute 0 based index + this.font = wb.styleData.fonts[this.fontId]; + } + + if (opts.numberFormat !== undefined) { + if (typeof opts.numberFormat === 'number' && opts.numberFormat <= 164) { + this.numFmtId = opts.numberFormat; + } else if (typeof opts.numberFormat === 'string') { + this.numFmt = _getNumFmt(wb, opts.numberFormat); + } + } + + if (opts.pivotButton !== undefined) { + this.pivotButton = null; // attribute boolean + } + + if (opts.quotePrefix !== undefined) { + this.quotePrefix = null; // attribute boolean + } + + this.ids = {}; + } + + _createClass(Style, [{ + key: 'toObject', + + + /** + * @func Style.toObject + * @desc Converts the Style instance to a javascript object + * @returns {Object} + */ + value: function toObject() { + var obj = {}; + + if (typeof this.fontId === 'number') { + obj.font = this.font.toObject(); + } + + if (typeof this.fillId === 'number') { + obj.fill = this.fill.toObject(); + } + + if (typeof this.borderId === 'number') { + obj.border = this.border.toObject(); + } + + if (typeof this.numFmtId === 'number' && this.numFmtId < 164) { + obj.numberFormat = this.numFmtId; + } else if (this.numFmt !== undefined && this.numFmt !== null) { + obj.numberFormat = this.numFmt.formatCode; + } + + if (this.alignment instanceof Alignment) { + obj.alignment = this.alignment.toObject(); + } + + if (this.pivotButton !== undefined) { + obj.pivotButton = this.pivotButton; + } + + if (this.quotePrefix !== undefined) { + obj.quotePrefix = this.quotePrefix; + } + + return obj; + } + + /** + * @alias Style.addToXMLele + * @desc When generating Workbook output, attaches style to the styles xml file + * @func Style.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addXFtoXMLele', + value: function addXFtoXMLele(ele) { + var thisEle = ele.ele('xf'); + var thisXF = this.xf; + Object.keys(thisXF).forEach(function (a) { + if (a === 'alignment') { + thisXF[a].addToXMLele(thisEle); + } else { + thisEle.att(a, thisXF[a]); + } + }); + } + + /** + * @alias Style.addDXFtoXMLele + * @desc When generating Workbook output, attaches style to the styles xml file as a dxf for use with conditional formatting rules + * @func Style.addDXFtoXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + + }, { + key: 'addDXFtoXMLele', + value: function addDXFtoXMLele(ele) { + var thisEle = ele.ele('dxf'); + + if (this.font instanceof Font) { + this.font.addToXMLele(thisEle); + } + + if (this.numFmt instanceof NumberFormat) { + this.numFmt.addToXMLele(thisEle); + } + + if (this.fill instanceof Fill) { + this.fill.addToXMLele(thisEle.ele('fill')); + } + + if (this.alignment instanceof Alignment) { + this.alignment.addToXMLele(thisEle); + } + + if (this.border instanceof Border) { + this.border.addToXMLele(thisEle); + } + } + }, { + key: 'xf', + get: function get() { + var thisXF = {}; + + if (typeof this.fontId === 'number') { + thisXF.applyFont = 1; + thisXF.fontId = this.fontId; + } + + if (typeof this.fillId === 'number') { + thisXF.applyFill = 1; + thisXF.fillId = this.fillId; + } + + if (typeof this.borderId === 'number') { + thisXF.applyBorder = 1; + thisXF.borderId = this.borderId; + } + + if (typeof this.numFmtId === 'number') { + thisXF.applyNumberFormat = 1; + thisXF.numFmtId = this.numFmtId; + } else if (this.numFmt !== undefined && this.numFmt !== null) { + thisXF.applyNumberFormat = 1; + thisXF.numFmtId = this.numFmt.numFmtId; + } + + if (this.alignment instanceof Alignment) { + thisXF.applyAlignment = 1; + thisXF.alignment = this.alignment; + } + + return thisXF; + } + }]); + + return Style; +}(); + +module.exports = Style; +//# sourceMappingURL=style.js.map \ No newline at end of file diff --git a/distribution/lib/style/style.js.map b/distribution/lib/style/style.js.map new file mode 100644 index 00000000..18cf3b23 --- /dev/null +++ b/distribution/lib/style/style.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/style/style.js"],"names":["utils","require","deepmerge","Alignment","Border","Fill","Font","NumberFormat","_getFontId","wb","font","opts","defaultFont","thisFont","lookupKey","JSON","stringify","toObject","id","styleDataLookup","fonts","undefined","styleData","push","_getFillId","fill","thisFill","fills","_getBorderId","border","thisBorder","borders","_getNumFmt","val","fmt","numFmts","forEach","f","formatCode","fmtId","length","numFmtId","Style","styles","alignment","borderId","fillId","fontId","numberFormat","numFmt","pivotButton","quotePrefix","ids","obj","ele","thisEle","thisXF","xf","Object","keys","a","addToXMLele","att","applyFont","applyFill","applyBorder","applyNumberFormat","applyAlignment","module","exports"],"mappings":";;;;;;AAAA,IAAMA,QAAQC,QAAQ,aAAR,CAAd;AACA,IAAMC,YAAYD,QAAQ,WAAR,CAAlB;;AAEA,IAAME,YAAYF,QAAQ,wBAAR,CAAlB;AACA,IAAMG,SAASH,QAAQ,qBAAR,CAAf;AACA,IAAMI,OAAOJ,QAAQ,mBAAR,CAAb;AACA,IAAMK,OAAOL,QAAQ,mBAAR,CAAb;AACA,IAAMM,eAAeN,QAAQ,2BAAR,CAArB;;AAEA,IAAIO,aAAa,SAAbA,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,EAAqC;AACjCS,uBAAOO,SAAP,GAAmB,CAAnB;AACAP,uBAAOT,MAAP,GAAgB,KAAKA,MAArB;AACH;;AAED,gBAAI,OAAO,KAAKD,MAAZ,KAAuB,QAA3B,EAAqC;AACjCU,uBAAOQ,SAAP,GAAmB,CAAnB;AACAR,uBAAOV,MAAP,GAAgB,KAAKA,MAArB;AACH;;AAED,gBAAI,OAAO,KAAKD,QAAZ,KAAyB,QAA7B,EAAuC;AACnCW,uBAAOS,WAAP,GAAqB,CAArB;AACAT,uBAAOX,QAAP,GAAkB,KAAKA,QAAvB;AACH;;AAED,gBAAI,OAAO,KAAKJ,QAAZ,KAAyB,QAA7B,EAAuC;AACnCe,uBAAOU,iBAAP,GAA2B,CAA3B;AACAV,uBAAOf,QAAP,GAAkB,KAAKA,QAAvB;AACH,aAHD,MAGO,IAAI,KAAKQ,MAAL,KAAgB5B,SAAhB,IAA6B,KAAK4B,MAAL,KAAgB,IAAjD,EAAuD;AAC1DO,uBAAOU,iBAAP,GAA2B,CAA3B;AACAV,uBAAOf,QAAP,GAAkB,KAAKQ,MAAL,CAAYR,QAA9B;AACH;;AAED,gBAAI,KAAKG,SAAL,YAA0BzC,SAA9B,EAAyC;AACrCqD,uBAAOW,cAAP,GAAwB,CAAxB;AACAX,uBAAOZ,SAAP,GAAmB,KAAKA,SAAxB;AACH;;AAED,mBAAOY,MAAP;AACH;;;;;;AA6FLY,OAAOC,OAAP,GAAiB3B,KAAjB","file":"style.js","sourcesContent":["const utils = require('../utils.js');\r\nconst deepmerge = require('deepmerge');\r\n\r\nconst Alignment = require('./classes/alignment.js');\r\nconst Border = require('./classes/border.js');\r\nconst Fill = require('./classes/fill.js');\r\nconst Font = require('./classes/font.js');\r\nconst NumberFormat = require('./classes/numberFormat.js');\r\n\r\nlet _getFontId = (wb, font = {}) => {\r\n\r\n // Create the Font and lookup key\r\n font = deepmerge(wb.opts.defaultFont, font);\r\n const thisFont = new Font(font);\r\n const lookupKey = JSON.stringify(thisFont.toObject());\r\n\r\n // Find an existing entry, creating a new one if it does not exist\r\n let id = wb.styleDataLookup.fonts[lookupKey];\r\n if (id === undefined) {\r\n id = wb.styleData.fonts.push(thisFont) - 1;\r\n wb.styleDataLookup.fonts[lookupKey] = id;\r\n }\r\n\r\n return id;\r\n};\r\n\r\nlet _getFillId = (wb, fill) => {\r\n if (fill === undefined) {\r\n return null;\r\n }\r\n\r\n // Create the Fill and lookup key\r\n const thisFill = new Fill(fill);\r\n const lookupKey = JSON.stringify(thisFill.toObject());\r\n\r\n // Find an existing entry, creating a new one if it does not exist\r\n let id = wb.styleDataLookup.fills[lookupKey];\r\n if (id === undefined) {\r\n id = wb.styleData.fills.push(thisFill) - 1;\r\n wb.styleDataLookup.fills[lookupKey] = id;\r\n }\r\n\r\n return id;\r\n};\r\n\r\nlet _getBorderId = (wb, border) => {\r\n if (border === undefined) {\r\n return null;\r\n }\r\n\r\n // Create the Border and lookup key\r\n const thisBorder = new Border(border);\r\n const lookupKey = JSON.stringify(thisBorder.toObject());\r\n\r\n // Find an existing entry, creating a new one if it does not exist\r\n let id = wb.styleDataLookup.borders[lookupKey];\r\n if (id === undefined) {\r\n id = wb.styleData.borders.push(thisBorder) - 1;\r\n wb.styleDataLookup.borders[lookupKey] = id;\r\n }\r\n\r\n return id;\r\n};\r\n\r\nlet _getNumFmt = (wb, val) => {\r\n let fmt;\r\n wb.styleData.numFmts.forEach((f) => {\r\n if (f.formatCode === val) {\r\n fmt = f;\r\n }\r\n });\r\n\r\n if (fmt === undefined) {\r\n let fmtId = wb.styleData.numFmts.length + 164;\r\n fmt = new NumberFormat(val);\r\n fmt.numFmtId = fmtId;\r\n wb.styleData.numFmts.push(fmt);\r\n }\r\n\r\n return fmt;\r\n};\r\n\r\n\r\n/*\r\n Style Opts\r\n {\r\n alignment: { // §18.8.1\r\n horizontal: ['center', 'centerContinuous', 'distributed', 'fill', 'general', 'justify', 'left', 'right'],\r\n indent: integer, // Number of spaces to indent = indent value * 3\r\n justifyLastLine: boolean,\r\n readingOrder: ['contextDependent', 'leftToRight', 'rightToLeft'], \r\n relativeIndent: integer, // number of additional spaces to indent\r\n shrinkToFit: boolean,\r\n textRotation: integer, // number of degrees to rotate text counter-clockwise\r\n vertical: ['bottom', 'center', 'distributed', 'justify', 'top'],\r\n wrapText: boolean\r\n },\r\n font: { // §18.8.22\r\n bold: boolean,\r\n charset: integer,\r\n color: string,\r\n condense: boolean,\r\n extend: boolean,\r\n family: string,\r\n italics: boolean,\r\n name: string,\r\n outline: boolean,\r\n scheme: string, // §18.18.33 ST_FontScheme (Font scheme Styles)\r\n shadow: boolean,\r\n strike: boolean,\r\n size: integer,\r\n underline: boolean,\r\n vertAlign: string // §22.9.2.17 ST_VerticalAlignRun (Vertical Positioning Location)\r\n },\r\n border: { // §18.8.4 border (Border)\r\n left: {\r\n style: string,\r\n color: string\r\n },\r\n right: {\r\n style: string,\r\n color: string\r\n },\r\n top: {\r\n style: string,\r\n color: string\r\n },\r\n bottom: {\r\n style: string,\r\n color: string\r\n },\r\n diagonal: {\r\n style: string,\r\n color: string\r\n },\r\n diagonalDown: boolean,\r\n diagonalUp: boolean,\r\n outline: boolean\r\n },\r\n fill: { // §18.8.20 fill (Fill)\r\n type: 'pattern',\r\n patternType: 'solid',\r\n color: 'Yellow'\r\n },\r\n numberFormat: integer or string // §18.8.30 numFmt (Number Format)\r\n }\r\n*/\r\nclass Style {\r\n constructor(wb, opts) {\r\n /**\r\n * Excel Style object\r\n * @class Style\r\n * @desc Style object for formatting Excel Cells\r\n * @param {Workbook} wb Excel Workbook object\r\n * @param {Object} opts Options for style\r\n * @param {Object} opts.alignment Options for creating an Alignment instance\r\n * @param {Object} opts.font Options for creating a Font instance\r\n * @param {Object} opts.border Options for creating a Border instance\r\n * @param {Object} opts.fill Options for creating a Fill instance\r\n * @param {String} opts.numberFormat\r\n * @property {Alignment} alignment Alignment instance associated with Style\r\n * @property {Border} border Border instance associated with Style\r\n * @property {Number} borderId ID of Border instance in the Workbook\r\n * @property {Fill} fill Fill instance associated with Style\r\n * @property {Number} fillId ID of Fill instance in the Workbook\r\n * @property {Font} font Font instance associated with Style\r\n * @property {Number} fontId ID of Font instance in the Workbook\r\n * @property {String} numberFormat String represenation of the way a number should be formatted\r\n * @property {Number} xf XF id of the Style in the Workbook\r\n * @returns {Style} \r\n */\r\n opts = opts ? opts : {};\r\n opts = deepmerge(wb.styles[0] ? wb.styles[0] : {}, opts);\r\n\r\n if (opts.alignment !== undefined) {\r\n this.alignment = new Alignment(opts.alignment);\r\n }\r\n\r\n if (opts.border !== undefined) {\r\n this.borderId = _getBorderId(wb, opts.border); // attribute 0 based index\r\n this.border = wb.styleData.borders[this.borderId];\r\n }\r\n if (opts.fill !== undefined) {\r\n this.fillId = _getFillId(wb, opts.fill); // attribute 0 based index\r\n this.fill = wb.styleData.fills[this.fillId];\r\n }\r\n\r\n if (opts.font !== undefined) {\r\n this.fontId = _getFontId(wb, opts.font); // attribute 0 based index\r\n this.font = wb.styleData.fonts[this.fontId];\r\n }\r\n\r\n if (opts.numberFormat !== undefined) {\r\n if (typeof opts.numberFormat === 'number' && opts.numberFormat <= 164) {\r\n this.numFmtId = opts.numberFormat;\r\n } else if (typeof opts.numberFormat === 'string') {\r\n this.numFmt = _getNumFmt(wb, opts.numberFormat);\r\n }\r\n }\r\n\r\n if (opts.pivotButton !== undefined) {\r\n this.pivotButton = null; // attribute boolean\r\n }\r\n\r\n if (opts.quotePrefix !== undefined) {\r\n this.quotePrefix = null; // attribute boolean\r\n }\r\n\r\n this.ids = {};\r\n }\r\n\r\n get xf() {\r\n let thisXF = {};\r\n\r\n if (typeof this.fontId === 'number') {\r\n thisXF.applyFont = 1;\r\n thisXF.fontId = this.fontId;\r\n }\r\n\r\n if (typeof this.fillId === 'number') {\r\n thisXF.applyFill = 1;\r\n thisXF.fillId = this.fillId;\r\n }\r\n\r\n if (typeof this.borderId === 'number') {\r\n thisXF.applyBorder = 1;\r\n thisXF.borderId = this.borderId;\r\n }\r\n\r\n if (typeof this.numFmtId === 'number') {\r\n thisXF.applyNumberFormat = 1;\r\n thisXF.numFmtId = this.numFmtId;\r\n } else if (this.numFmt !== undefined && this.numFmt !== null) {\r\n thisXF.applyNumberFormat = 1;\r\n thisXF.numFmtId = this.numFmt.numFmtId;\r\n }\r\n\r\n if (this.alignment instanceof Alignment) {\r\n thisXF.applyAlignment = 1;\r\n thisXF.alignment = this.alignment;\r\n }\r\n\r\n return thisXF;\r\n }\r\n\r\n\r\n /** \r\n * @func Style.toObject\r\n * @desc Converts the Style instance to a javascript object\r\n * @returns {Object}\r\n */\r\n toObject() {\r\n let obj = {};\r\n\r\n if (typeof this.fontId === 'number') {\r\n obj.font = this.font.toObject();\r\n }\r\n\r\n if (typeof this.fillId === 'number') {\r\n obj.fill = this.fill.toObject();\r\n }\r\n\r\n if (typeof this.borderId === 'number') {\r\n obj.border = this.border.toObject();\r\n }\r\n\r\n if (typeof this.numFmtId === 'number' && this.numFmtId < 164) {\r\n obj.numberFormat = this.numFmtId;\r\n } else if (this.numFmt !== undefined && this.numFmt !== null) {\r\n obj.numberFormat = this.numFmt.formatCode;\r\n }\r\n\r\n if (this.alignment instanceof Alignment) {\r\n obj.alignment = this.alignment.toObject();\r\n }\r\n\r\n if (this.pivotButton !== undefined) {\r\n obj.pivotButton = this.pivotButton;\r\n }\r\n\r\n if (this.quotePrefix !== undefined) {\r\n obj.quotePrefix = this.quotePrefix;\r\n }\r\n\r\n return obj;\r\n }\r\n\r\n /**\r\n * @alias Style.addToXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file\r\n * @func Style.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addXFtoXMLele(ele) {\r\n let thisEle = ele.ele('xf');\r\n let thisXF = this.xf;\r\n Object.keys(thisXF).forEach((a) => {\r\n if (a === 'alignment') {\r\n thisXF[a].addToXMLele(thisEle);\r\n } else {\r\n thisEle.att(a, thisXF[a]);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * @alias Style.addDXFtoXMLele\r\n * @desc When generating Workbook output, attaches style to the styles xml file as a dxf for use with conditional formatting rules\r\n * @func Style.addDXFtoXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addDXFtoXMLele(ele) {\r\n let thisEle = ele.ele('dxf');\r\n\r\n if (this.font instanceof Font) {\r\n this.font.addToXMLele(thisEle);\r\n }\r\n\r\n if (this.numFmt instanceof NumberFormat) {\r\n this.numFmt.addToXMLele(thisEle);\r\n }\r\n\r\n if (this.fill instanceof Fill) {\r\n this.fill.addToXMLele(thisEle.ele('fill'));\r\n }\r\n\r\n if (this.alignment instanceof Alignment) {\r\n this.alignment.addToXMLele(thisEle);\r\n }\r\n\r\n if (this.border instanceof Border) {\r\n this.border.addToXMLele(thisEle);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Style;"]} \ No newline at end of file diff --git a/distribution/lib/types/alignment.js b/distribution/lib/types/alignment.js new file mode 100644 index 00000000..a03b0081 --- /dev/null +++ b/distribution/lib/types/alignment.js @@ -0,0 +1,75 @@ +'use strict'; + +function horizontalAlignments() { + var _this = this; + + this.opts = [// §18.18.40 ST_HorizontalAlignment (Horizontal Alignment Type) + 'center', 'centerContinuous', 'distributed', 'fill', 'general', 'justify', 'left', 'right']; + this.opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +function verticalAlignments() { + var _this2 = this; + + this.opts = [//§18.18.88 ST_VerticalAlignment (Vertical Alignment Types) + 'bottom', 'center', 'distributed', 'justify', 'top']; + this.opts.forEach(function (o, i) { + _this2[o] = i + 1; + }); +} + +function readingOrders() { + this['contextDependent'] = 0; + this['leftToRight'] = 1; + this['rightToLeft'] = 2; + this.opts = ['contextDependent', 'leftToRight', 'rightToLeft']; +} + +horizontalAlignments.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for alignment.horizontal ' + val + '; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +verticalAlignments.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for alignment.vertical ' + val + '; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +readingOrders.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for alignment.readingOrder ' + val + '; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports.vertical = new verticalAlignments(); +module.exports.horizontal = new horizontalAlignments(); +module.exports.readingOrder = new readingOrders(); +//# sourceMappingURL=alignment.js.map \ No newline at end of file diff --git a/distribution/lib/types/alignment.js.map b/distribution/lib/types/alignment.js.map new file mode 100644 index 00000000..66a36629 --- /dev/null +++ b/distribution/lib/types/alignment.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/alignment.js"],"names":["horizontalAlignments","opts","forEach","o","i","verticalAlignments","readingOrders","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports","vertical","horizontal","readingOrder"],"mappings":";;AAAA,SAASA,oBAAT,GAAgC;AAAA;;AAC5B,SAAKC,IAAL,GAAY,CAAE;AACV,YADQ,EAER,kBAFQ,EAGR,aAHQ,EAIR,MAJQ,EAKR,SALQ,EAMR,SANQ,EAOR,MAPQ,EAQR,OARQ,CAAZ;AAUA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAED,SAASC,kBAAT,GAA8B;AAAA;;AAC1B,SAAKJ,IAAL,GAAY,CAAE;AACV,YADQ,EAER,QAFQ,EAGR,aAHQ,EAIR,SAJQ,EAKR,KALQ,CAAZ;AAOA,SAAKA,IAAL,CAAU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V,EAAe;AAC9C,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIT,OAAO,EAAX;AACA,aAAK,IAAIU,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BV,qBAAKY,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,+CAA0DL,GAA1D,+BAAuF,KAAKR,IAAL,CAAUc,IAAV,CAAe,IAAf,CAAvF,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,CAAeC,QAAf,GAA0B,IAAIb,kBAAJ,EAA1B;AACAW,OAAOC,OAAP,CAAeE,UAAf,GAA4B,IAAInB,oBAAJ,EAA5B;AACAgB,OAAOC,OAAP,CAAeG,YAAf,GAA8B,IAAId,aAAJ,EAA9B","file":"alignment.js","sourcesContent":["function horizontalAlignments() {\r\n this.opts = [ // §18.18.40 ST_HorizontalAlignment (Horizontal Alignment Type)\r\n 'center', \r\n 'centerContinuous', \r\n 'distributed', \r\n 'fill', \r\n 'general', \r\n 'justify', \r\n 'left', \r\n 'right'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\nfunction verticalAlignments() {\r\n this.opts = [ //§18.18.88 ST_VerticalAlignment (Vertical Alignment Types)\r\n 'bottom', \r\n 'center', \r\n 'distributed', \r\n 'justify', \r\n 'top'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\nfunction readingOrders() {\r\n this['contextDependent'] = 0;\r\n this['leftToRight'] = 1;\r\n this['rightToLeft'] = 2;\r\n this.opts = ['contextDependent', 'leftToRight', 'rightToLeft'];\r\n}\r\n\r\nhorizontalAlignments.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError(`Invalid value for alignment.horizontal ${val}; Value must be one of ${this.opts.join(', ')}`);\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nverticalAlignments.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError(`Invalid value for alignment.vertical ${val}; Value must be one of ${this.opts.join(', ')}`);\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nreadingOrders.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError(`Invalid value for alignment.readingOrder ${val}; Value must be one of ${this.opts.join(', ')}`);\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports.vertical = new verticalAlignments();\r\nmodule.exports.horizontal = new horizontalAlignments();\r\nmodule.exports.readingOrder = new readingOrders();"]} \ No newline at end of file diff --git a/distribution/lib/types/borderStyle.js b/distribution/lib/types/borderStyle.js new file mode 100644 index 00000000..f1bbcfd0 --- /dev/null +++ b/distribution/lib/types/borderStyle.js @@ -0,0 +1,28 @@ +'use strict'; + +function items() { + var _this = this; + + this.opts = [//§18.18.3 ST_BorderStyle (Border Line Styles) + 'none', 'thin', 'medium', 'dashed', 'dotted', 'thick', 'double', 'hair', 'mediumDashed', 'dashDot', 'mediumDashDot', 'dashDotDot', 'mediumDashDotDot', 'slantDashDot']; + this.opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for ST_BorderStyle; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=borderStyle.js.map \ No newline at end of file diff --git a/distribution/lib/types/borderStyle.js.map b/distribution/lib/types/borderStyle.js.map new file mode 100644 index 00000000..e16ee8b3 --- /dev/null +++ b/distribution/lib/types/borderStyle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/borderStyle.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AACb,SAAKC,IAAL,GAAY,CAAC;AACT,UADQ,EAER,MAFQ,EAGR,QAHQ,EAIR,QAJQ,EAKR,QALQ,EAMR,OANQ,EAOR,QAPQ,EAQR,MARQ,EASR,cATQ,EAUR,SAVQ,EAWR,eAXQ,EAYR,YAZQ,EAaR,kBAbQ,EAcR,cAdQ,CAAZ;AAgBA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,4DAA4D,KAAKX,IAAL,CAAUY,IAAV,CAAe,IAAf,CAA1E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"borderStyle.js","sourcesContent":["function items() {\r\n this.opts = [//§18.18.3 ST_BorderStyle (Border Line Styles)\r\n 'none', \r\n 'thin', \r\n 'medium', \r\n 'dashed', \r\n 'dotted', \r\n 'thick', \r\n 'double', \r\n 'hair', \r\n 'mediumDashed', \r\n 'dashDot', \r\n 'mediumDashDot', \r\n 'dashDotDot', \r\n 'mediumDashDotDot', \r\n 'slantDashDot'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for ST_BorderStyle; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/cellComment.js b/distribution/lib/types/cellComment.js new file mode 100644 index 00000000..2b8c7469 --- /dev/null +++ b/distribution/lib/types/cellComment.js @@ -0,0 +1,29 @@ +'use strict'; + +//§18.18.5 ST_CellComments (Cell Comments) + +function items() { + var _this = this; + + this.opts = ['none', 'asDisplayed', 'atEnd']; + this.opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for ST_CellComments; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=cellComment.js.map \ No newline at end of file diff --git a/distribution/lib/types/cellComment.js.map b/distribution/lib/types/cellComment.js.map new file mode 100644 index 00000000..d4ccab62 --- /dev/null +++ b/distribution/lib/types/cellComment.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/cellComment.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,KAAT,GAAiB;AAAA;;AACb,SAAKC,IAAL,GAAY,CAAC,MAAD,EAAS,aAAT,EAAwB,OAAxB,CAAZ;AACA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,6DAA6D,KAAKX,IAAL,CAAUY,IAAV,CAAe,IAAf,CAA3E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"cellComment.js","sourcesContent":["//§18.18.5 ST_CellComments (Cell Comments)\r\n\r\nfunction items() {\r\n this.opts = ['none', 'asDisplayed', 'atEnd'];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for ST_CellComments; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/colorScheme.js b/distribution/lib/types/colorScheme.js new file mode 100644 index 00000000..2e9fa0b4 --- /dev/null +++ b/distribution/lib/types/colorScheme.js @@ -0,0 +1,28 @@ +'use strict'; + +function items() { + var _this = this; + + this.opts = [//§20.1.6.2 clrScheme (Color Scheme) + 'dark 1', 'light 1', 'dark 2', 'light 2', 'accent 1', 'accent 2', 'accent 3', 'accent 4', 'accent 5', 'accent 6', 'hyperlink', 'followed hyperlink']; + this.opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val.toLowerCase()] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for clrScheme; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=colorScheme.js.map \ No newline at end of file diff --git a/distribution/lib/types/colorScheme.js.map b/distribution/lib/types/colorScheme.js.map new file mode 100644 index 00000000..44850323 --- /dev/null +++ b/distribution/lib/types/colorScheme.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/colorScheme.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","toLowerCase","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AACb,SAAKC,IAAL,GAAY,CAAC;AACT,YADQ,EAER,SAFQ,EAGR,QAHQ,EAIR,SAJQ,EAKR,UALQ,EAMR,UANQ,EAOR,UAPQ,EAQR,UARQ,EASR,UATQ,EAUR,UAVQ,EAWR,WAXQ,EAYR,oBAZQ,CAAZ;AAcA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,IAAIC,WAAJ,EAAL,MAA4BC,SAAhC,EAA2C;AACvC,YAAIR,OAAO,EAAX;AACA,aAAK,IAAIS,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BT,qBAAKW,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,uDAAuD,KAAKZ,IAAL,CAAUa,IAAV,CAAe,IAAf,CAArE,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIhB,KAAJ,EAAjB","file":"colorScheme.js","sourcesContent":["function items() {\r\n this.opts = [//§20.1.6.2 clrScheme (Color Scheme)\r\n 'dark 1', \r\n 'light 1', \r\n 'dark 2', \r\n 'light 2', \r\n 'accent 1', \r\n 'accent 2', \r\n 'accent 3', \r\n 'accent 4', \r\n 'accent 5', \r\n 'accent 6', \r\n 'hyperlink', \r\n 'followed hyperlink'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val.toLowerCase()] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for clrScheme; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/excelColor.js b/distribution/lib/types/excelColor.js new file mode 100644 index 00000000..660cd766 --- /dev/null +++ b/distribution/lib/types/excelColor.js @@ -0,0 +1,92 @@ +'use strict'; + +function items() { + var _this = this; + + // subset of §20.1.10.48 ST_PresetColorVal (Preset Color Value) + this['aqua'] = 'FF33CCCC'; + this['black'] = 'FF000000'; + this['blue'] = 'FF0000FF'; + this['blue-gray'] = 'FF666699'; + this['bright green'] = 'FF00FF00'; + this['brown'] = 'FF993300'; + this['dark blue'] = 'FF000080'; + this['dark green'] = 'FF003300'; + this['dark red'] = 'FF800000'; + this['dark teal'] = 'FF003366'; + this['dark yellow'] = 'FF808000'; + this['gold'] = 'FFFFCC00'; + this['gray-25'] = 'FFC0C0C0'; + this['gray-40'] = 'FF969696'; + this['gray-50'] = 'FF808080'; + this['gray-80'] = 'FF333333'; + this['green'] = 'FF008000'; + this['indigo'] = 'FF333399'; + this['lavender'] = 'FFCC99FF'; + this['light blue'] = 'FF3366FF'; + this['light green'] = 'FFCCFFCC'; + this['light orange'] = 'FFFF9900'; + this['light turquoise'] = 'FFCCFFFF'; + this['light yellow'] = 'FFFFFF99'; + this['lime'] = 'FF99CC00'; + this['olive green'] = 'FF333300'; + this['orange'] = 'FFFF6600'; + this['pale blue'] = 'FF99CCFF'; + this['pink'] = 'FFFF00FF'; + this['plum'] = 'FF993366'; + this['red'] = 'FFFF0000'; + this['rose'] = 'FFFF99CC'; + this['sea green'] = 'FF339966'; + this['sky blue'] = 'FF00CCFF'; + this['tan'] = 'FFFFCC99'; + this['teal'] = 'FF008080'; + this['turquoise'] = 'FF00FFFF'; + this['violet'] = 'FF800080'; + this['white'] = 'FFFFFFFF'; + this['yellow'] = 'FFFFFF00'; + + this.opts = []; + Object.keys(this).forEach(function (k) { + if (typeof _this[k] === 'string') { + _this.opts.push(k); + } + }); +} + +items.prototype.validate = function (val) { + if (this[val.toLowerCase()] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for ST_PresetColorVal; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +items.prototype.getColor = function (val) { + // check for RGB, RGBA or Excel Color Names and return RGBA + + if (typeof this[val.toLowerCase()] === 'string') { + // val was a named color that matches predefined list. return corresponding color + return this[val.toLowerCase()]; + } else if (val.length === 8 && /^[a-fA-F0-9()]+$/.test(val)) { + // val is already a properly formatted color string, return upper case version of itself + return val.toUpperCase(); + } else if (val.length === 6 && /^[a-fA-F0-9()]+$/.test(val)) { + // val is color code without Alpha, add it and return + return 'FF' + val.toUpperCase(); + } else if (val.length === 7 && val.substr(0, 1) === '#' && /^[a-fA-F0-9()]+$/.test(val.substr(1))) { + // val was sent as html style hex code, remove # and add alpha + return 'FF' + val.substr(1).toUpperCase(); + } else { + // I don't know what this is, return valid color and console.log error + throw new TypeError('valid color options are html style hex codes, ARGB strings or these colors by name: %s', this.opts.join(', ')); + } +}; + +module.exports = new items(); +//# sourceMappingURL=excelColor.js.map \ No newline at end of file diff --git a/distribution/lib/types/excelColor.js.map b/distribution/lib/types/excelColor.js.map new file mode 100644 index 00000000..f0126012 --- /dev/null +++ b/distribution/lib/types/excelColor.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/excelColor.js"],"names":["items","opts","Object","keys","forEach","k","push","prototype","validate","val","toLowerCase","undefined","name","hasOwnProperty","TypeError","join","getColor","length","test","toUpperCase","substr","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AACb;AACA,SAAK,MAAL,IAAe,UAAf;AACA,SAAK,OAAL,IAAgB,UAAhB;AACA,SAAK,MAAL,IAAe,UAAf;AACA,SAAK,WAAL,IAAoB,UAApB;AACA,SAAK,cAAL,IAAuB,UAAvB;AACA,SAAK,OAAL,IAAgB,UAAhB;AACA,SAAK,WAAL,IAAoB,UAApB;AACA,SAAK,YAAL,IAAqB,UAArB;AACA,SAAK,UAAL,IAAmB,UAAnB;AACA,SAAK,WAAL,IAAoB,UAApB;AACA,SAAK,aAAL,IAAsB,UAAtB;AACA,SAAK,MAAL,IAAe,UAAf;AACA,SAAK,SAAL,IAAkB,UAAlB;AACA,SAAK,SAAL,IAAkB,UAAlB;AACA,SAAK,SAAL,IAAkB,UAAlB;AACA,SAAK,SAAL,IAAkB,UAAlB;AACA,SAAK,OAAL,IAAgB,UAAhB;AACA,SAAK,QAAL,IAAiB,UAAjB;AACA,SAAK,UAAL,IAAmB,UAAnB;AACA,SAAK,YAAL,IAAqB,UAArB;AACA,SAAK,aAAL,IAAsB,UAAtB;AACA,SAAK,cAAL,IAAuB,UAAvB;AACA,SAAK,iBAAL,IAA0B,UAA1B;AACA,SAAK,cAAL,IAAuB,UAAvB;AACA,SAAK,MAAL,IAAe,UAAf;AACA,SAAK,aAA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,CAAP,KAAmC,QAAvC,EAAiD;AAC7C;AACA,eAAO,KAAKD,IAAIC,WAAJ,EAAL,CAAP;AACH,KAHD,MAGO,IAAID,IAAIQ,MAAJ,KAAe,CAAf,IAAoB,mBAAmBC,IAAnB,CAAwBT,GAAxB,CAAxB,EAAsD;AACzD;AACA,eAAOA,IAAIU,WAAJ,EAAP;AACH,KAHM,MAGA,IAAIV,IAAIQ,MAAJ,KAAe,CAAf,IAAoB,mBAAmBC,IAAnB,CAAwBT,GAAxB,CAAxB,EAAsD;AACzD;AACA,eAAO,OAAOA,IAAIU,WAAJ,EAAd;AACH,KAHM,MAGA,IAAIV,IAAIQ,MAAJ,KAAe,CAAf,IAAoBR,IAAIW,MAAJ,CAAW,CAAX,EAAc,CAAd,MAAqB,GAAzC,IAAgD,mBAAmBF,IAAnB,CAAwBT,IAAIW,MAAJ,CAAW,CAAX,CAAxB,CAApD,EAA4F;AAC/F;AACA,eAAO,OAAOX,IAAIW,MAAJ,CAAW,CAAX,EAAcD,WAAd,EAAd;AACH,KAHM,MAGA;AACH;AACA,cAAM,IAAIL,SAAJ,CAAc,wFAAd,EAAwG,KAAKb,IAAL,CAAUc,IAAV,CAAe,IAAf,CAAxG,CAAN;AACH;AACJ,CAnBD;;AAqBAM,OAAOC,OAAP,GAAiB,IAAItB,KAAJ,EAAjB","file":"excelColor.js","sourcesContent":["function items() {\r\n // subset of §20.1.10.48 ST_PresetColorVal (Preset Color Value)\r\n this['aqua'] = 'FF33CCCC';\r\n this['black'] = 'FF000000';\r\n this['blue'] = 'FF0000FF';\r\n this['blue-gray'] = 'FF666699';\r\n this['bright green'] = 'FF00FF00';\r\n this['brown'] = 'FF993300';\r\n this['dark blue'] = 'FF000080';\r\n this['dark green'] = 'FF003300';\r\n this['dark red'] = 'FF800000';\r\n this['dark teal'] = 'FF003366';\r\n this['dark yellow'] = 'FF808000';\r\n this['gold'] = 'FFFFCC00';\r\n this['gray-25'] = 'FFC0C0C0';\r\n this['gray-40'] = 'FF969696';\r\n this['gray-50'] = 'FF808080';\r\n this['gray-80'] = 'FF333333';\r\n this['green'] = 'FF008000';\r\n this['indigo'] = 'FF333399';\r\n this['lavender'] = 'FFCC99FF';\r\n this['light blue'] = 'FF3366FF';\r\n this['light green'] = 'FFCCFFCC';\r\n this['light orange'] = 'FFFF9900';\r\n this['light turquoise'] = 'FFCCFFFF';\r\n this['light yellow'] = 'FFFFFF99';\r\n this['lime'] = 'FF99CC00';\r\n this['olive green'] = 'FF333300';\r\n this['orange'] = 'FFFF6600';\r\n this['pale blue'] = 'FF99CCFF';\r\n this['pink'] = 'FFFF00FF';\r\n this['plum'] = 'FF993366';\r\n this['red'] = 'FFFF0000';\r\n this['rose'] = 'FFFF99CC';\r\n this['sea green'] = 'FF339966';\r\n this['sky blue'] = 'FF00CCFF';\r\n this['tan'] = 'FFFFCC99';\r\n this['teal'] = 'FF008080';\r\n this['turquoise'] = 'FF00FFFF';\r\n this['violet'] = 'FF800080';\r\n this['white'] = 'FFFFFFFF';\r\n this['yellow'] = 'FFFFFF00';\r\n\r\n this.opts = [];\r\n Object.keys(this).forEach((k) => {\r\n if (typeof this[k] === 'string') {\r\n this.opts.push(k);\r\n }\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val.toLowerCase()] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for ST_PresetColorVal; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nitems.prototype.getColor = function (val) {\r\n // check for RGB, RGBA or Excel Color Names and return RGBA\r\n\r\n if (typeof this[val.toLowerCase()] === 'string') {\r\n // val was a named color that matches predefined list. return corresponding color\r\n return this[val.toLowerCase()];\r\n } else if (val.length === 8 && /^[a-fA-F0-9()]+$/.test(val)) {\r\n // val is already a properly formatted color string, return upper case version of itself\r\n return val.toUpperCase();\r\n } else if (val.length === 6 && /^[a-fA-F0-9()]+$/.test(val)) {\r\n // val is color code without Alpha, add it and return\r\n return 'FF' + val.toUpperCase();\r\n } else if (val.length === 7 && val.substr(0, 1) === '#' && /^[a-fA-F0-9()]+$/.test(val.substr(1))) {\r\n // val was sent as html style hex code, remove # and add alpha\r\n return 'FF' + val.substr(1).toUpperCase();\r\n } else {\r\n // I don't know what this is, return valid color and console.log error\r\n throw new TypeError('valid color options are html style hex codes, ARGB strings or these colors by name: %s', this.opts.join(', '));\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/fillPattern.js b/distribution/lib/types/fillPattern.js new file mode 100644 index 00000000..3fb25cd6 --- /dev/null +++ b/distribution/lib/types/fillPattern.js @@ -0,0 +1,28 @@ +'use strict'; + +function items() { + var _this = this; + + this.opts = [//§18.18.55 ST_PatternType (Pattern Type) + 'darkDown', 'darkGray', 'darkGrid', 'darkHorizontal', 'darkTrellis', 'darkUp', 'darkVerical', 'gray0625', 'gray125', 'lightDown', 'lightGray', 'lightGrid', 'lightHorizontal', 'lightTrellis', 'lightUp', 'lightVertical', 'mediumGray', 'none', 'solid']; + this.opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for ST_PatternType; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=fillPattern.js.map \ No newline at end of file diff --git a/distribution/lib/types/fillPattern.js.map b/distribution/lib/types/fillPattern.js.map new file mode 100644 index 00000000..f5e313ec --- /dev/null +++ b/distribution/lib/types/fillPattern.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/fillPattern.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AACb,SAAKC,IAAL,GAAY,CAAC;AACT,cADQ,EAER,UAFQ,EAGR,UAHQ,EAIR,gBAJQ,EAKR,aALQ,EAMR,QANQ,EAOR,aAPQ,EAQR,UARQ,EASR,SATQ,EAUR,WAVQ,EAWR,WAXQ,EAYR,WAZQ,EAaR,iBAbQ,EAcR,cAdQ,EAeR,SAfQ,EAgBR,eAhBQ,EAiBR,YAjBQ,EAkBR,MAlBQ,EAmBR,OAnBQ,CAAZ;AAqBA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,4DAA4D,KAAKX,IAAL,CAAUY,IAAV,CAAe,IAAf,CAA1E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"fillPattern.js","sourcesContent":["function items() {\r\n this.opts = [//§18.18.55 ST_PatternType (Pattern Type)\r\n 'darkDown', \r\n 'darkGray', \r\n 'darkGrid', \r\n 'darkHorizontal', \r\n 'darkTrellis', \r\n 'darkUp', \r\n 'darkVerical', \r\n 'gray0625', \r\n 'gray125', \r\n 'lightDown', \r\n 'lightGray', \r\n 'lightGrid', \r\n 'lightHorizontal', \r\n 'lightTrellis', \r\n 'lightUp', \r\n 'lightVertical', \r\n 'mediumGray', \r\n 'none', \r\n 'solid'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for ST_PatternType; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/fontFamily.js b/distribution/lib/types/fontFamily.js new file mode 100644 index 00000000..5b9a8c35 --- /dev/null +++ b/distribution/lib/types/fontFamily.js @@ -0,0 +1,32 @@ +'use strict'; + +function items() { + var _this = this; + + this.opts = [//§18.8.18 family (Font Family) + 'n/a', 'roman', 'swiss', 'modern', 'script', 'decorative']; + this.opts.forEach(function (o, i) { + _this[o] = i; + }); +} + +items.prototype.validate = function (val) { + if (typeof val !== 'string') { + throw new TypeError('Invalid value for Font Family ' + val + '; Value must be one of ' + this.opts.join(', ')); + } + + if (this[val.toLowerCase()] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for Font Family ' + val + '; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=fontFamily.js.map \ No newline at end of file diff --git a/distribution/lib/types/fontFamily.js.map b/distribution/lib/types/fontFamily.js.map new file mode 100644 index 00000000..f57525ea --- /dev/null +++ b/distribution/lib/types/fontFamily.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/fontFamily.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","TypeError","join","toLowerCase","undefined","name","hasOwnProperty","push","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AACb,SAAKC,IAAL,GAAY,CAAC;AACT,SADQ,EAER,OAFQ,EAGR,OAHQ,EAIR,QAJQ,EAKR,QALQ,EAMR,YANQ,CAAZ;AAQA,SAAKA,IAAL,CAAUC,OAAV,CAAkB,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACxB,cAAKD,CAAL,IAAUC,CAAV;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AACzB,cAAM,IAAIC,SAAJ,oCAA+CD,GAA/C,+BAA4E,KAAKN,IAAL,CAAUQ,IAAV,CAAe,IAAf,CAA5E,CAAN;AACH;;AAED,QAAI,KAAKF,IAAIG,WAAJ,EAAL,MAA4BC,SAAhC,EAA2C;AACvC,YAAIV,OAAO,EAAX;AACA,aAAK,IAAIW,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BX,qBAAKa,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIJ,SAAJ,oCAA+CD,GAA/C,+BAA4E,KAAKN,IAAL,CAAUQ,IAAV,CAAe,IAAf,CAA5E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAhBD;;AAkBAM,OAAOC,OAAP,GAAiB,IAAIhB,KAAJ,EAAjB","file":"fontFamily.js","sourcesContent":["function items() {\r\n this.opts = [//§18.8.18 family (Font Family)\r\n 'n/a', \r\n 'roman', \r\n 'swiss', \r\n 'modern', \r\n 'script', \r\n 'decorative'\r\n ];\r\n this.opts.forEach((o, i) => {\r\n this[o] = i;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (typeof val !== 'string') {\r\n throw new TypeError(`Invalid value for Font Family ${val}; Value must be one of ${this.opts.join(', ')}`);\r\n }\r\n\r\n if (this[val.toLowerCase()] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError(`Invalid value for Font Family ${val}; Value must be one of ${this.opts.join(', ')}`);\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/index.js b/distribution/lib/types/index.js new file mode 100644 index 00000000..96ccc582 --- /dev/null +++ b/distribution/lib/types/index.js @@ -0,0 +1,17 @@ +'use strict'; + +exports.alignment = require('./alignment'); +exports.borderStyle = require('./borderStyle'); +exports.cellComment = require('./cellComment'); +exports.colorScheme = require('./colorScheme'); +exports.excelColor = require('./excelColor'); +exports.fillPattern = require('./fillPattern'); +exports.fontFamily = require('./fontFamily'); +exports.orientation = require('./orientation'); +exports.pageOrder = require('./pageOrder'); +exports.pane = require('./pane'); +exports.paneState = require('./paneState'); +exports.paperSize = require('./paperSize'); +exports.positiveUniversalMeasure = require('./positiveUniversalMeasure'); +exports.printError = require('./printError'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/types/index.js.map b/distribution/lib/types/index.js.map new file mode 100644 index 00000000..75c93eae --- /dev/null +++ b/distribution/lib/types/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/index.js"],"names":["exports","alignment","require","borderStyle","cellComment","colorScheme","excelColor","fillPattern","fontFamily","orientation","pageOrder","pane","paneState","paperSize","positiveUniversalMeasure","printError"],"mappings":"AAAA;;AAEAA,QAAQC,SAAR,GAAoBC,QAAQ,aAAR,CAApB;AACAF,QAAQG,WAAR,GAAsBD,QAAQ,eAAR,CAAtB;AACAF,QAAQI,WAAR,GAAsBF,QAAQ,eAAR,CAAtB;AACAF,QAAQK,WAAR,GAAsBH,QAAQ,eAAR,CAAtB;AACAF,QAAQM,UAAR,GAAqBJ,QAAQ,cAAR,CAArB;AACAF,QAAQO,WAAR,GAAsBL,QAAQ,eAAR,CAAtB;AACAF,QAAQQ,UAAR,GAAqBN,QAAQ,cAAR,CAArB;AACAF,QAAQS,WAAR,GAAsBP,QAAQ,eAAR,CAAtB;AACAF,QAAQU,SAAR,GAAoBR,QAAQ,aAAR,CAApB;AACAF,QAAQW,IAAR,GAAeT,QAAQ,QAAR,CAAf;AACAF,QAAQY,SAAR,GAAoBV,QAAQ,aAAR,CAApB;AACAF,QAAQa,SAAR,GAAoBX,QAAQ,aAAR,CAApB;AACAF,QAAQc,wBAAR,GAAmCZ,QAAQ,4BAAR,CAAnC;AACAF,QAAQe,UAAR,GAAqBb,QAAQ,cAAR,CAArB","file":"index.js","sourcesContent":["'use strict';\r\n\r\nexports.alignment = require('./alignment');\r\nexports.borderStyle = require('./borderStyle');\r\nexports.cellComment = require('./cellComment');\r\nexports.colorScheme = require('./colorScheme');\r\nexports.excelColor = require('./excelColor');\r\nexports.fillPattern = require('./fillPattern');\r\nexports.fontFamily = require('./fontFamily');\r\nexports.orientation = require('./orientation');\r\nexports.pageOrder = require('./pageOrder');\r\nexports.pane = require('./pane');\r\nexports.paneState = require('./paneState');\r\nexports.paperSize = require('./paperSize');\r\nexports.positiveUniversalMeasure = require('./positiveUniversalMeasure');\r\nexports.printError = require('./printError');\r\n"]} \ No newline at end of file diff --git a/distribution/lib/types/orientation.js b/distribution/lib/types/orientation.js new file mode 100644 index 00000000..f5de9a01 --- /dev/null +++ b/distribution/lib/types/orientation.js @@ -0,0 +1,29 @@ +'use strict'; + +//§18.18.50 ST_Orientation (Orientation) + +function items() { + var _this = this; + + var opts = ['default', 'portrait', 'landscape']; + opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val.toLowerCase()] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for pageSetup.orientation; Value must be one of ' + opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=orientation.js.map \ No newline at end of file diff --git a/distribution/lib/types/orientation.js.map b/distribution/lib/types/orientation.js.map new file mode 100644 index 00000000..868861a9 --- /dev/null +++ b/distribution/lib/types/orientation.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/orientation.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","toLowerCase","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,KAAT,GAAiB;AAAA;;AACb,QAAIC,OAAO,CAAC,SAAD,EAAY,UAAZ,EAAwB,WAAxB,CAAX;AACAA,SAAKC,OAAL,CAAa,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACnB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,IAAIC,WAAJ,EAAL,MAA4BC,SAAhC,EAA2C;AACvC,YAAIR,OAAO,EAAX;AACA,aAAK,IAAIS,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BT,qBAAKW,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,mEAAmEZ,KAAKa,IAAL,CAAU,IAAV,CAAjF,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIhB,KAAJ,EAAjB","file":"orientation.js","sourcesContent":["//§18.18.50 ST_Orientation (Orientation)\r\n\r\nfunction items() {\r\n let opts = ['default', 'portrait', 'landscape'];\r\n opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val.toLowerCase()] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for pageSetup.orientation; Value must be one of ' + opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/pageOrder.js b/distribution/lib/types/pageOrder.js new file mode 100644 index 00000000..6cf72080 --- /dev/null +++ b/distribution/lib/types/pageOrder.js @@ -0,0 +1,29 @@ +'use strict'; + +//§18.18.51 ST_PageOrder (Page Order) + +function items() { + var _this = this; + + var opts = ['downThenOver', 'overThenDown']; + opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for pageSetup.pageOrder; Value must be one of ' + opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=pageOrder.js.map \ No newline at end of file diff --git a/distribution/lib/types/pageOrder.js.map b/distribution/lib/types/pageOrder.js.map new file mode 100644 index 00000000..537bfa4b --- /dev/null +++ b/distribution/lib/types/pageOrder.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/pageOrder.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,KAAT,GAAiB;AAAA;;AACb,QAAIC,OAAO,CAAC,cAAD,EAAiB,cAAjB,CAAX;AACAA,SAAKC,OAAL,CAAa,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACnB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,iEAAiEX,KAAKY,IAAL,CAAU,IAAV,CAA/E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"pageOrder.js","sourcesContent":["//§18.18.51 ST_PageOrder (Page Order)\r\n\r\nfunction items() {\r\n let opts = ['downThenOver', 'overThenDown'];\r\n opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for pageSetup.pageOrder; Value must be one of ' + opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/pane.js b/distribution/lib/types/pane.js new file mode 100644 index 00000000..42909d96 --- /dev/null +++ b/distribution/lib/types/pane.js @@ -0,0 +1,29 @@ +'use strict'; + +//§18.18.52 ST_Pane (Pane Types) + +function items() { + var _this = this; + + var opts = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight']; + opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for sheetview.pane.activePane; Value must be one of ' + opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=pane.js.map \ No newline at end of file diff --git a/distribution/lib/types/pane.js.map b/distribution/lib/types/pane.js.map new file mode 100644 index 00000000..4ce1e566 --- /dev/null +++ b/distribution/lib/types/pane.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/pane.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,KAAT,GAAiB;AAAA;;AACb,QAAIC,OAAO,CAAC,YAAD,EAAe,aAAf,EAA8B,SAA9B,EAAyC,UAAzC,CAAX;AACAA,SAAKC,OAAL,CAAa,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACnB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,uEAAuEX,KAAKY,IAAL,CAAU,IAAV,CAArF,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"pane.js","sourcesContent":["//§18.18.52 ST_Pane (Pane Types)\r\n\r\nfunction items() {\r\n let opts = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'];\r\n opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for sheetview.pane.activePane; Value must be one of ' + opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/paneState.js b/distribution/lib/types/paneState.js new file mode 100644 index 00000000..f26e12b0 --- /dev/null +++ b/distribution/lib/types/paneState.js @@ -0,0 +1,29 @@ +'use strict'; + +//§ST_PaneState (Pane State) + +function items() { + var _this = this; + + var opts = ['split', 'frozen', 'frozenSplit']; + opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for sheetView.pane.state; Value must be one of ' + opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=paneState.js.map \ No newline at end of file diff --git a/distribution/lib/types/paneState.js.map b/distribution/lib/types/paneState.js.map new file mode 100644 index 00000000..61795c74 --- /dev/null +++ b/distribution/lib/types/paneState.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/paneState.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,KAAT,GAAiB;AAAA;;AACb,QAAIC,OAAO,CAAC,OAAD,EAAU,QAAV,EAAoB,aAApB,CAAX;AACAA,SAAKC,OAAL,CAAa,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACnB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,kEAAkEX,KAAKY,IAAL,CAAU,IAAV,CAAhF,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"paneState.js","sourcesContent":["//§ST_PaneState (Pane State)\r\n\r\nfunction items() {\r\n let opts = ['split', 'frozen', 'frozenSplit'];\r\n opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for sheetView.pane.state; Value must be one of ' + opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/paperSize.js b/distribution/lib/types/paperSize.js new file mode 100644 index 00000000..039a2dbb --- /dev/null +++ b/distribution/lib/types/paperSize.js @@ -0,0 +1,97 @@ +'use strict'; + +function items() { + var _this = this; + + // As defined in §18.3.1.63 pageSetup (Page Setup Settings) + this.LETTER_PAPER = 1; // Letter paper (8.5 in. by 11 in.) + this.LETTER_SMALL_PAPER = 2; // Letter small paper (8.5 in. by 11 in.) + this.TABLOID_PAPER = 3; // Tabloid paper (11 in. by 17 in.) + this.LEDGER_PAPER = 4; // Ledger paper (17 in. by 11 in.) + this.LEGAL_PAPER = 5; // Legal paper (8.5 in. by 14 in.) + this.STATEMENT_PAPER = 6; // Statement paper (5.5 in. by 8.5 in.) + this.EXECUTIVE_PAPER = 7; // Executive paper (7.25 in. by 10.5 in.) + this.A3_PAPER = 8; // A3 paper (297 mm by 420 mm) + this.A4_PAPER = 9; // A4 paper (210 mm by 297 mm) + this.A4_SMALL_PAPER = 10; // A4 small paper (210 mm by 297 mm) + this.A5_PAPER = 11; // A5 paper (148 mm by 210 mm) + this.B4_PAPER = 12; // B4 paper (250 mm by 353 mm) + this.B5_PAPER = 13; // B5 paper (176 mm by 250 mm) + this.FOLIO_PAPER = 14; // Folio paper (8.5 in. by 13 in.) + this.QUARTO_PAPER = 15; // Quarto paper (215 mm by 275 mm) + this.STANDARD_PAPER_10_BY_14_IN = 16; // Standard paper (10 in. by 14 in.) + this.STANDARD_PAPER_11_BY_17_IN = 17; // Standard paper (11 in. by 17 in.) + this.NOTE_PAPER = 18; // Note paper (8.5 in. by 11 in.) + this.NUMBER_9_ENVELOPE = 19; // #9 envelope (3.875 in. by 8.875 in.) + this.NUMBER_10_ENVELOPE = 20; // #10 envelope (4.125 in. by 9.5 in.) + this.NUMBER_11_ENVELOPE = 21; // #11 envelope (4.5 in. by 10.375 in.) + this.NUMBER_12_ENVELOPE = 22; // #12 envelope (4.75 in. by 11 in.) + this.NUMBER_14_ENVELOPE = 23; // #14 envelope (5 in. by 11.5 in.) + this.C_PAPER = 24; // C paper (17 in. by 22 in.) + this.D_PAPER = 25; // D paper (22 in. by 34 in.) + this.E_PAPER = 26; // E paper (34 in. by 44 in.) + this.DL_PAPER = 27; // DL envelope (110 mm by 220 mm) + this.C5_ENVELOPE = 28; // C5 envelope (162 mm by 229 mm) + this.C3_ENVELOPE = 29; // C3 envelope (324 mm by 458 mm) + this.C4_ENVELOPE = 30; // C4 envelope (229 mm by 324 mm) + this.C6_ENVELOPE = 31; // C6 envelope (114 mm by 162 mm) + this.C65_ENVELOPE = 32; // C65 envelope (114 mm by 229 mm) + this.B4_ENVELOPE = 33; // B4 envelope (250 mm by 353 mm) + this.B5_ENVELOPE = 34; // B5 envelope (176 mm by 250 mm) + this.B6_ENVELOPE = 35; // B6 envelope (176 mm by 125 mm) + this.ITALY_ENVELOPE = 36; // Italy envelope (110 mm by 230 mm) + this.MONARCH_ENVELOPE = 37; // Monarch envelope (3.875 in. by 7.5 in.). + this.SIX_THREE_QUARTERS_ENVELOPE = 38; // 6 3/4 envelope (3.625 in. by 6.5 in.) + this.US_STANDARD_FANFOLD = 39; // US standard fanfold (14.875 in. by 11 in.) + this.GERMAN_STANDARD_FANFOLD = 40; // German standard fanfold (8.5 in. by 12 in.) + this.GERMAN_LEGAL_FANFOLD = 41; // German legal fanfold (8.5 in. by 13 in.) + this.ISO_B4 = 42; // ISO B4 (250 mm by 353 mm) + this.JAPANESE_DOUBLE_POSTCARD = 43; // Japanese double postcard (200 mm by 148 mm) + this.STANDARD_PAPER_9_BY_11_IN = 44; // Standard paper (9 in. by 11 in.) + this.STANDARD_PAPER_10_BY_11_IN = 45; // Standard paper (10 in. by 11 in.) + this.STANDARD_PAPER_15_BY_11_IN = 46; // Standard paper (15 in. by 11 in.) + this.INVITE_ENVELOPE = 47; // Invite envelope (220 mm by 220 mm) + this.LETTER_EXTRA_PAPER = 50; // Letter extra paper (9.275 in. by 12 in.) + this.LEGAL_EXTRA_PAPER = 51; // Legal extra paper (9.275 in. by 15 in.) + this.TABLOID_EXTRA_PAPER = 52; // Tabloid extra paper (11.69 in. by 18 in.) + this.A4_EXTRA_PAPER = 53; // A4 extra paper (236 mm by 322 mm) + this.LETTER_TRANSVERSE_PAPER = 54; // Letter transverse paper (8.275 in. by 11 in.) + this.A4_TRANSVERSE_PAPER = 55; // A4 transverse paper (210 mm by 297 mm) + this.LETTER_EXTRA_TRANSVERSE_PAPER = 56; // Letter extra transverse paper (9.275 in. by 12 in.) + this.SUPER_A_SUPER_A_A4_PAPER = 57; // SuperA/SuperA/A4 paper (227 mm by 356 mm) + this.SUPER_B_SUPER_B_A3_PAPER = 58; // SuperB/SuperB/A3 paper (305 mm by 487 mm) + this.LETTER_PLUS_PAPER = 59; // Letter plus paper (8.5 in. by 12.69 in.) + this.A4_PLUS_PAPER = 60; // A4 plus paper (210 mm by 330 mm) + this.A5_TRANSVERSE_PAPER = 61; // A5 transverse paper (148 mm by 210 mm) + this.JIS_B5_TRANSVERSE_PAPER = 62; // JIS B5 transverse paper (182 mm by 257 mm) + this.A3_EXTRA_PAPER = 63; // A3 extra paper (322 mm by 445 mm) + this.A5_EXTRA_PAPER = 64; // A5 extra paper (174 mm by 235 mm) + this.ISO_B5_EXTRA_PAPER = 65; // ISO B5 extra paper (201 mm by 276 mm) + this.A2_PAPER = 66; // A2 paper (420 mm by 594 mm) + this.A3_TRANSVERSE_PAPER = 67; // A3 transverse paper (297 mm by 420 mm) + this.A3_EXTRA_TRANSVERSE_PAPER = 68; // A3 extra transverse paper (322 mm by 445 mm) + + this.opts = []; + Object.keys(this).forEach(function (k) { + if (typeof _this[k] === 'number') { + _this.opts.push(k); + } + }); +} + +items.prototype.validate = function (val) { + if (this[val.toUpperCase()] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for PAPER_SIZE; Value must be one of ' + this.opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=paperSize.js.map \ No newline at end of file diff --git a/distribution/lib/types/paperSize.js.map b/distribution/lib/types/paperSize.js.map new file mode 100644 index 00000000..c6946552 --- /dev/null +++ b/distribution/lib/types/paperSize.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/paperSize.js"],"names":["items","LETTER_PAPER","LETTER_SMALL_PAPER","TABLOID_PAPER","LEDGER_PAPER","LEGAL_PAPER","STATEMENT_PAPER","EXECUTIVE_PAPER","A3_PAPER","A4_PAPER","A4_SMALL_PAPER","A5_PAPER","B4_PAPER","B5_PAPER","FOLIO_PAPER","QUARTO_PAPER","STANDARD_PAPER_10_BY_14_IN","STANDARD_PAPER_11_BY_17_IN","NOTE_PAPER","NUMBER_9_ENVELOPE","NUMBER_10_ENVELOPE","NUMBER_11_ENVELOPE","NUMBER_12_ENVELOPE","NUMBER_14_ENVELOPE","C_PAPER","D_PAPER","E_PAPER","DL_PAPER","C5_ENVELOPE","C3_ENVELOPE","C4_ENVELOPE","C6_ENVELOPE","C65_ENVELOPE","B4_ENVELOPE","B5_ENVELOPE","B6_ENVELOPE","ITALY_ENVELOPE","MONARCH_ENVELOPE","SIX_THREE_QUARTERS_ENVELOPE","US_STANDARD_FANFOLD","GERMAN_STANDARD_FANFOLD","GERMAN_LEGAL_FANFOLD","ISO_B4","JAPANESE_DOUBLE_POSTCARD","STANDARD_PAPER_9_BY_11_IN","STANDARD_PAPER_10_BY_11_IN","STANDARD_PAPER_15_BY_11_IN","INVITE_ENVELOPE","LETTER_EXTRA_PAPER","LEGAL_EXTRA_PAPER","TABLOID_EXTRA_PAPER","A4_EXTRA_PAPER","LETTER_TRANSVERSE_PAPER","A4_TRANSVERSE_PAPER","LETTER_EXTRA_TRANSVERSE_PAPER","SUPER_A_SUPER_A_A4_PAPER","SUPER_B_SUPER_B_A3_PAPER","LETTER_PLUS_PAPER","A4_PLUS_PAPER","A5_TRANSVERSE_PAPER","JIS_B5_TRANSVERSE_PAPER","A3_EXTRA_PAPER","A5_EXTRA_PAPER","ISO_B5_EXTRA_PAPER","A2_PAPER","A3_TRANSVERSE_PAPER","A3_EXTRA_TRANSVERSE_PAPER","opts","Object","keys","forEach","k","push","prototype","validate","val","toUpperCase","undefined","name","hasOwnProperty","TypeError","join","module","exports"],"mappings":";;AAAA,SAASA,KAAT,GAAiB;AAAA;;AAAE;AACf,SAAKC,YAAL,GAAoB,CAApB,CADa,CACU;AACvB,SAAKC,kBAAL,GAA0B,CAA1B,CAFa,CAEgB;AAC7B,SAAKC,aAAL,GAAqB,CAArB,CAHa,CAGW;AACxB,SAAKC,YAAL,GAAoB,CAApB,CAJa,CAIU;AACvB,SAAKC,WAAL,GAAmB,CAAnB,CALa,CAKS;AACtB,SAAKC,eAAL,GAAuB,CAAvB,CANa,CAMa;AAC1B,SAAKC,eAAL,GAAuB,CAAvB,CAPa,CAOa;AAC1B,SAAKC,QAAL,GAAgB,CAAhB,CARa,CAQM;AACnB,SAAKC,QAAL,GAAgB,CAAhB,CATa,CASM;AACnB,SAAKC,cAAL,GAAsB,EAAtB,CAVa,CAUa;AAC1B,SAAKC,QAAL,GAAgB,EAAhB,CAXa,CAWO;AACpB,SAAKC,QAAL,GAAgB,EAAhB,CAZa,CAYO;AACpB,SAAKC,QAAL,GAAgB,EAAhB,CAba,CAaO;AACpB,SAAKC,WAAL,GAAmB,EAAnB,CAda,CAcU;AACvB,SAAKC,YAAL,GAAoB,EA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AKC,mBAAL,GAA2B,EAA3B,CAjEa,CAiEkB;AAC/B,SAAKC,yBAAL,GAAiC,EAAjC,CAlEa,CAkEwB;;AAErC,SAAKC,IAAL,GAAY,EAAZ;AACAC,WAAOC,IAAP,CAAY,IAAZ,EAAkBC,OAAlB,CAA0B,UAACC,CAAD,EAAO;AAC7B,YAAI,OAAO,MAAKA,CAAL,CAAP,KAAmB,QAAvB,EAAiC;AAC7B,kBAAKJ,IAAL,CAAUK,IAAV,CAAeD,CAAf;AACH;AACJ,KAJD;AAKH;;AAGDvE,MAAMyE,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,IAAIC,WAAJ,EAAL,MAA4BC,SAAhC,EAA2C;AACvC,YAAIV,OAAO,EAAX;AACA,aAAK,IAAIW,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BX,qBAAKK,IAAL,CAAUM,IAAV;AACH;AACJ;AACD,cAAM,IAAIE,SAAJ,CAAc,wDAAwD,KAAKb,IAAL,CAAUc,IAAV,CAAe,IAAf,CAAtE,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAInF,KAAJ,EAAjB","file":"paperSize.js","sourcesContent":["function items() { // As defined in §18.3.1.63 pageSetup (Page Setup Settings)\r\n this.LETTER_PAPER = 1; // Letter paper (8.5 in. by 11 in.)\r\n this.LETTER_SMALL_PAPER = 2; // Letter small paper (8.5 in. by 11 in.)\r\n this.TABLOID_PAPER = 3; // Tabloid paper (11 in. by 17 in.)\r\n this.LEDGER_PAPER = 4; // Ledger paper (17 in. by 11 in.)\r\n this.LEGAL_PAPER = 5; // Legal paper (8.5 in. by 14 in.)\r\n this.STATEMENT_PAPER = 6; // Statement paper (5.5 in. by 8.5 in.)\r\n this.EXECUTIVE_PAPER = 7; // Executive paper (7.25 in. by 10.5 in.)\r\n this.A3_PAPER = 8; // A3 paper (297 mm by 420 mm)\r\n this.A4_PAPER = 9; // A4 paper (210 mm by 297 mm)\r\n this.A4_SMALL_PAPER = 10; // A4 small paper (210 mm by 297 mm)\r\n this.A5_PAPER = 11; // A5 paper (148 mm by 210 mm)\r\n this.B4_PAPER = 12; // B4 paper (250 mm by 353 mm)\r\n this.B5_PAPER = 13; // B5 paper (176 mm by 250 mm)\r\n this.FOLIO_PAPER = 14; // Folio paper (8.5 in. by 13 in.)\r\n this.QUARTO_PAPER = 15; // Quarto paper (215 mm by 275 mm)\r\n this.STANDARD_PAPER_10_BY_14_IN = 16; // Standard paper (10 in. by 14 in.)\r\n this.STANDARD_PAPER_11_BY_17_IN = 17; // Standard paper (11 in. by 17 in.)\r\n this.NOTE_PAPER = 18; // Note paper (8.5 in. by 11 in.)\r\n this.NUMBER_9_ENVELOPE = 19; // #9 envelope (3.875 in. by 8.875 in.)\r\n this.NUMBER_10_ENVELOPE = 20; // #10 envelope (4.125 in. by 9.5 in.)\r\n this.NUMBER_11_ENVELOPE = 21; // #11 envelope (4.5 in. by 10.375 in.)\r\n this.NUMBER_12_ENVELOPE = 22; // #12 envelope (4.75 in. by 11 in.)\r\n this.NUMBER_14_ENVELOPE = 23; // #14 envelope (5 in. by 11.5 in.)\r\n this.C_PAPER = 24; // C paper (17 in. by 22 in.)\r\n this.D_PAPER = 25; // D paper (22 in. by 34 in.)\r\n this.E_PAPER = 26; // E paper (34 in. by 44 in.)\r\n this.DL_PAPER = 27; // DL envelope (110 mm by 220 mm)\r\n this.C5_ENVELOPE = 28; // C5 envelope (162 mm by 229 mm)\r\n this.C3_ENVELOPE = 29; // C3 envelope (324 mm by 458 mm)\r\n this.C4_ENVELOPE = 30; // C4 envelope (229 mm by 324 mm)\r\n this.C6_ENVELOPE = 31; // C6 envelope (114 mm by 162 mm)\r\n this.C65_ENVELOPE = 32; // C65 envelope (114 mm by 229 mm)\r\n this.B4_ENVELOPE = 33; // B4 envelope (250 mm by 353 mm)\r\n this.B5_ENVELOPE = 34; // B5 envelope (176 mm by 250 mm)\r\n this.B6_ENVELOPE = 35; // B6 envelope (176 mm by 125 mm)\r\n this.ITALY_ENVELOPE = 36; // Italy envelope (110 mm by 230 mm)\r\n this.MONARCH_ENVELOPE = 37; // Monarch envelope (3.875 in. by 7.5 in.).\r\n this.SIX_THREE_QUARTERS_ENVELOPE = 38; // 6 3/4 envelope (3.625 in. by 6.5 in.)\r\n this.US_STANDARD_FANFOLD = 39; // US standard fanfold (14.875 in. by 11 in.)\r\n this.GERMAN_STANDARD_FANFOLD = 40; // German standard fanfold (8.5 in. by 12 in.)\r\n this.GERMAN_LEGAL_FANFOLD = 41; // German legal fanfold (8.5 in. by 13 in.)\r\n this.ISO_B4 = 42; // ISO B4 (250 mm by 353 mm)\r\n this.JAPANESE_DOUBLE_POSTCARD = 43; // Japanese double postcard (200 mm by 148 mm)\r\n this.STANDARD_PAPER_9_BY_11_IN = 44; // Standard paper (9 in. by 11 in.)\r\n this.STANDARD_PAPER_10_BY_11_IN = 45; // Standard paper (10 in. by 11 in.)\r\n this.STANDARD_PAPER_15_BY_11_IN = 46; // Standard paper (15 in. by 11 in.)\r\n this.INVITE_ENVELOPE = 47; // Invite envelope (220 mm by 220 mm)\r\n this.LETTER_EXTRA_PAPER = 50; // Letter extra paper (9.275 in. by 12 in.)\r\n this.LEGAL_EXTRA_PAPER = 51; // Legal extra paper (9.275 in. by 15 in.)\r\n this.TABLOID_EXTRA_PAPER = 52; // Tabloid extra paper (11.69 in. by 18 in.)\r\n this.A4_EXTRA_PAPER = 53; // A4 extra paper (236 mm by 322 mm)\r\n this.LETTER_TRANSVERSE_PAPER = 54; // Letter transverse paper (8.275 in. by 11 in.)\r\n this.A4_TRANSVERSE_PAPER = 55; // A4 transverse paper (210 mm by 297 mm)\r\n this.LETTER_EXTRA_TRANSVERSE_PAPER = 56; // Letter extra transverse paper (9.275 in. by 12 in.)\r\n this.SUPER_A_SUPER_A_A4_PAPER = 57; // SuperA/SuperA/A4 paper (227 mm by 356 mm)\r\n this.SUPER_B_SUPER_B_A3_PAPER = 58; // SuperB/SuperB/A3 paper (305 mm by 487 mm)\r\n this.LETTER_PLUS_PAPER = 59; // Letter plus paper (8.5 in. by 12.69 in.)\r\n this.A4_PLUS_PAPER = 60; // A4 plus paper (210 mm by 330 mm)\r\n this.A5_TRANSVERSE_PAPER = 61; // A5 transverse paper (148 mm by 210 mm)\r\n this.JIS_B5_TRANSVERSE_PAPER = 62; // JIS B5 transverse paper (182 mm by 257 mm)\r\n this.A3_EXTRA_PAPER = 63; // A3 extra paper (322 mm by 445 mm)\r\n this.A5_EXTRA_PAPER = 64; // A5 extra paper (174 mm by 235 mm)\r\n this.ISO_B5_EXTRA_PAPER = 65; // ISO B5 extra paper (201 mm by 276 mm)\r\n this.A2_PAPER = 66; // A2 paper (420 mm by 594 mm)\r\n this.A3_TRANSVERSE_PAPER = 67; // A3 transverse paper (297 mm by 420 mm)\r\n this.A3_EXTRA_TRANSVERSE_PAPER = 68; // A3 extra transverse paper (322 mm by 445 mm)\r\n\r\n this.opts = [];\r\n Object.keys(this).forEach((k) => {\r\n if (typeof this[k] === 'number') {\r\n this.opts.push(k);\r\n }\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val.toUpperCase()] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for PAPER_SIZE; Value must be one of ' + this.opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/types/positiveUniversalMeasure.js b/distribution/lib/types/positiveUniversalMeasure.js new file mode 100644 index 00000000..ffa63485 --- /dev/null +++ b/distribution/lib/types/positiveUniversalMeasure.js @@ -0,0 +1,17 @@ +'use strict'; + +//§22.9.2.12 ST_PositiveUniversalMeasure (Positive Universal Measurement) + +function measure() {} + +measure.prototype.validate = function (val) { + var re = new RegExp('[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)'); + if (re.test(val) !== true) { + throw new TypeError('Invalid value for universal positive measure. Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. 10.5cm'); + } else { + return true; + } +}; + +module.exports = new measure(); +//# sourceMappingURL=positiveUniversalMeasure.js.map \ No newline at end of file diff --git a/distribution/lib/types/positiveUniversalMeasure.js.map b/distribution/lib/types/positiveUniversalMeasure.js.map new file mode 100644 index 00000000..87be0e2a --- /dev/null +++ b/distribution/lib/types/positiveUniversalMeasure.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/positiveUniversalMeasure.js"],"names":["measure","prototype","validate","val","re","RegExp","test","TypeError","module","exports"],"mappings":";;AAAA;;AAEA,SAASA,OAAT,GAAmB,CAClB;;AAEDA,QAAQC,SAAR,CAAkBC,QAAlB,GAA6B,UAAUC,GAAV,EAAe;AACxC,QAAIC,KAAK,IAAIC,MAAJ,CAAW,sCAAX,CAAT;AACA,QAAID,GAAGE,IAAH,CAAQH,GAAR,MAAiB,IAArB,EAA2B;AACvB,cAAM,IAAII,SAAJ,CAAc,iKAAd,CAAN;AACH,KAFD,MAEO;AACH,eAAO,IAAP;AACH;AACJ,CAPD;;AASAC,OAAOC,OAAP,GAAiB,IAAIT,OAAJ,EAAjB","file":"positiveUniversalMeasure.js","sourcesContent":["//§22.9.2.12 ST_PositiveUniversalMeasure (Positive Universal Measurement)\r\n\r\nfunction measure() {\r\n}\r\n\r\nmeasure.prototype.validate = function (val) {\r\n let re = new RegExp('[0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi)');\r\n if (re.test(val) !== true) {\r\n throw new TypeError('Invalid value for universal positive measure. Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. 10.5cm');\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new measure();"]} \ No newline at end of file diff --git a/distribution/lib/types/printError.js b/distribution/lib/types/printError.js new file mode 100644 index 00000000..fc7f9010 --- /dev/null +++ b/distribution/lib/types/printError.js @@ -0,0 +1,28 @@ +'use strict'; + +//§18.18.60 ST_PrintError (Print Errors) +function items() { + var _this = this; + + var opts = ['displayed', 'blank', 'dash', 'NA']; + opts.forEach(function (o, i) { + _this[o] = i + 1; + }); +} + +items.prototype.validate = function (val) { + if (this[val] === undefined) { + var opts = []; + for (var name in this) { + if (this.hasOwnProperty(name)) { + opts.push(name); + } + } + throw new TypeError('Invalid value for pageSetup.errors; Value must be one of ' + opts.join(', ')); + } else { + return true; + } +}; + +module.exports = new items(); +//# sourceMappingURL=printError.js.map \ No newline at end of file diff --git a/distribution/lib/types/printError.js.map b/distribution/lib/types/printError.js.map new file mode 100644 index 00000000..4d79df3c --- /dev/null +++ b/distribution/lib/types/printError.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/types/printError.js"],"names":["items","opts","forEach","o","i","prototype","validate","val","undefined","name","hasOwnProperty","push","TypeError","join","module","exports"],"mappings":";;AAAA;AACA,SAASA,KAAT,GAAiB;AAAA;;AACb,QAAIC,OAAO,CAAC,WAAD,EAAc,OAAd,EAAuB,MAAvB,EAA+B,IAA/B,CAAX;AACAA,SAAKC,OAAL,CAAa,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACnB,cAAKD,CAAL,IAAUC,IAAI,CAAd;AACH,KAFD;AAGH;;AAGDJ,MAAMK,SAAN,CAAgBC,QAAhB,GAA2B,UAAUC,GAAV,EAAe;AACtC,QAAI,KAAKA,GAAL,MAAcC,SAAlB,EAA6B;AACzB,YAAIP,OAAO,EAAX;AACA,aAAK,IAAIQ,IAAT,IAAiB,IAAjB,EAAuB;AACnB,gBAAI,KAAKC,cAAL,CAAoBD,IAApB,CAAJ,EAA+B;AAC3BR,qBAAKU,IAAL,CAAUF,IAAV;AACH;AACJ;AACD,cAAM,IAAIG,SAAJ,CAAc,8DAA8DX,KAAKY,IAAL,CAAU,IAAV,CAA5E,CAAN;AACH,KARD,MAQO;AACH,eAAO,IAAP;AACH;AACJ,CAZD;;AAcAC,OAAOC,OAAP,GAAiB,IAAIf,KAAJ,EAAjB","file":"printError.js","sourcesContent":["//§18.18.60 ST_PrintError (Print Errors)\r\nfunction items() {\r\n let opts = ['displayed', 'blank', 'dash', 'NA'];\r\n opts.forEach((o, i) => {\r\n this[o] = i + 1;\r\n });\r\n}\r\n\r\n\r\nitems.prototype.validate = function (val) {\r\n if (this[val] === undefined) {\r\n let opts = [];\r\n for (let name in this) {\r\n if (this.hasOwnProperty(name)) {\r\n opts.push(name);\r\n }\r\n }\r\n throw new TypeError('Invalid value for pageSetup.errors; Value must be one of ' + opts.join(', '));\r\n } else {\r\n return true;\r\n }\r\n};\r\n\r\nmodule.exports = new items();"]} \ No newline at end of file diff --git a/distribution/lib/utils.js b/distribution/lib/utils.js new file mode 100644 index 00000000..4f19e7e5 --- /dev/null +++ b/distribution/lib/utils.js @@ -0,0 +1,249 @@ +'use strict'; + +var types = require('./types/index.js'); + +var _bitXOR = function _bitXOR(a, b) { + var maxLength = a.length > b.length ? a.length : b.length; + + var padString = ''; + for (var i = 0; i < maxLength; i++) { + padString += '0'; + } + + a = String(padString + a).substr(-maxLength); + b = String(padString + b).substr(-maxLength); + + var response = ''; + for (var _i = 0; _i < a.length; _i++) { + response += a[_i] === b[_i] ? 0 : 1; + } + return response; +}; + +var generateRId = function generateRId() { + var text = 'R'; + var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + for (var i = 0; i < 16; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; +}; + +var _rotateBinary = function _rotateBinary(bin) { + return bin.substr(1, bin.length - 1) + bin.substr(0, 1); +}; + +var _getHashForChar = function _getHashForChar(char, hash) { + hash = hash ? hash : '0000'; + var charCode = char.charCodeAt(0); + var hashBin = parseInt(hash, 16).toString(2); + var charBin = parseInt(charCode, 10).toString(2); + hashBin = String('000000000000000' + hashBin).substr(-15); + charBin = String('000000000000000' + charBin).substr(-15); + var nextHash = _bitXOR(hashBin, charBin); + nextHash = _rotateBinary(nextHash); + nextHash = parseInt(nextHash, 2).toString(16); + + return nextHash; +}; + +// http://www.openoffice.org/sc/excelfileformat.pdf section 4.18.4 +var getHashOfPassword = function getHashOfPassword(str) { + var curHash = '0000'; + for (var i = str.length - 1; i >= 0; i--) { + curHash = _getHashForChar(str[i], curHash); + } + var curHashBin = parseInt(curHash, 16).toString(2); + var charCountBin = parseInt(str.length, 10).toString(2); + var saltBin = parseInt('CE4B', 16).toString(2); + + var firstXOR = _bitXOR(curHashBin, charCountBin); + var finalHashBin = _bitXOR(firstXOR, saltBin); + var finalHash = String('0000' + parseInt(finalHashBin, 2).toString(16).toUpperCase()).slice(-4); + + return finalHash; +}; + +/** + * Translates a column number into the Alpha equivalent used by Excel + * @function getExcelAlpha + * @param {Number} colNum Column number that is to be transalated + * @returns {String} The Excel alpha representation of the column number + * @example + * // returns B + * getExcelAlpha(2); + */ +var getExcelAlpha = function getExcelAlpha(colNum) { + var remaining = colNum; + var aCharCode = 65; + var columnName = ''; + while (remaining > 0) { + var mod = (remaining - 1) % 26; + columnName = String.fromCharCode(aCharCode + mod) + columnName; + remaining = (remaining - 1 - mod) / 26; + } + return columnName; +}; + +/** + * Translates a column number into the Alpha equivalent used by Excel + * @function getExcelAlpha + * @param {Number} rowNum Row number that is to be transalated + * @param {Number} colNum Column number that is to be transalated + * @returns {String} The Excel alpha representation of the column number + * @example + * // returns B1 + * getExcelCellRef(1, 2); + */ +var getExcelCellRef = function getExcelCellRef(rowNum, colNum) { + var remaining = colNum; + var aCharCode = 65; + var columnName = ''; + while (remaining > 0) { + var mod = (remaining - 1) % 26; + columnName = String.fromCharCode(aCharCode + mod) + columnName; + remaining = (remaining - 1 - mod) / 26; + } + return columnName + rowNum; +}; + +/** + * Translates a Excel cell represenation into row and column numerical equivalents + * @function getExcelRowCol + * @param {String} str Excel cell representation + * @returns {Object} Object keyed with row and col + * @example + * // returns {row: 2, col: 3} + * getExcelRowCol('C2') + */ +var getExcelRowCol = function getExcelRowCol(str) { + var numeric = str.split(/\D/).filter(function (el) { + return el !== ''; + })[0]; + var alpha = str.split(/\d/).filter(function (el) { + return el !== ''; + })[0]; + var row = parseInt(numeric, 10); + var col = alpha.toUpperCase().split('').reduce(function (a, b, index, arr) { + return a + (b.charCodeAt(0) - 64) * Math.pow(26, arr.length - index - 1); + }, 0); + return { row: row, col: col }; +}; + +/** + * Translates a date into Excel timestamp + * @function getExcelTS + * @param {Date} date Date to translate + * @returns {Number} Excel timestamp + * @example + * // returns 29810.958333333332 + * getExcelTS(new Date('08/13/1981')); + */ +var getExcelTS = function getExcelTS(date) { + + var thisDt = new Date(date); + thisDt.setDate(thisDt.getDate() + 1); + + var epoch = new Date('1900-01-01T00:00:00.0000Z'); + + // Handle legacy leap year offset as described in §18.17.4.1 + var legacyLeapDate = new Date('1900-02-28T23:59:59.999Z'); + if (thisDt - legacyLeapDate > 0) { + thisDt.setDate(thisDt.getDate() + 1); + } + + // Get milliseconds between date sent to function and epoch + var diff2 = thisDt.getTime() - epoch.getTime(); + + var ts = diff2 / (1000 * 60 * 60 * 24); + + return parseFloat(ts.toFixed(7)); +}; + +var sortCellRefs = function sortCellRefs(a, b) { + var aAtt = getExcelRowCol(a); + var bAtt = getExcelRowCol(b); + if (aAtt.col === bAtt.col) { + return aAtt.row - bAtt.row; + } else { + return aAtt.col - bAtt.col; + } +}; + +var arrayIntersectSafe = function arrayIntersectSafe(a, b) { + + if (a instanceof Array && b instanceof Array) { + var ai = 0, + bi = 0; + var result = new Array(); + + while (ai < a.length && bi < b.length) { + if (a[ai] < b[bi]) { + ai++; + } else if (a[ai] > b[bi]) { + bi++; + } else { + result.push(a[ai]); + ai++; + bi++; + } + } + return result; + } else { + throw new TypeError('Both variables sent to arrayIntersectSafe must be arrays'); + } +}; + +var getAllCellsInExcelRange = function getAllCellsInExcelRange(range) { + var cells = range.split(':'); + var cell1props = getExcelRowCol(cells[0]); + var cell2props = getExcelRowCol(cells[1]); + return getAllCellsInNumericRange(cell1props.row, cell1props.col, cell2props.row, cell2props.col); +}; + +var getAllCellsInNumericRange = function getAllCellsInNumericRange(row1, col1, row2, col2) { + var response = []; + row2 = row2 ? row2 : row1; + col2 = col2 ? col2 : col1; + for (var i = row1; i <= row2; i++) { + for (var j = col1; j <= col2; j++) { + response.push(getExcelAlpha(j) + i); + } + } + return response.sort(sortCellRefs); +}; + +var boolToInt = function boolToInt(bool) { + if (bool === true) { + return 1; + } + if (bool === false) { + return 0; + } + if (parseInt(bool) === 1) { + return 1; + } + if (parseInt(bool) === 0) { + return 0; + } + throw new TypeError('Value sent to boolToInt must be true, false, 1 or 0'); +}; + +/* + * Helper Functions + */ + +module.exports = { + generateRId: generateRId, + getHashOfPassword: getHashOfPassword, + getExcelAlpha: getExcelAlpha, + getExcelCellRef: getExcelCellRef, + getExcelRowCol: getExcelRowCol, + getExcelTS: getExcelTS, + sortCellRefs: sortCellRefs, + arrayIntersectSafe: arrayIntersectSafe, + getAllCellsInExcelRange: getAllCellsInExcelRange, + getAllCellsInNumericRange: getAllCellsInNumericRange, + boolToInt: boolToInt +}; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/distribution/lib/utils.js.map b/distribution/lib/utils.js.map new file mode 100644 index 00000000..ac9c020e --- /dev/null +++ b/distribution/lib/utils.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../source/lib/utils.js"],"names":["types","require","_bitXOR","a","b","maxLength","length","padString","i","String","substr","response","generateRId","text","possible","charAt","Math","floor","random","_rotateBinary","bin","_getHashForChar","char","hash","charCode","charCodeAt","hashBin","parseInt","toString","charBin","nextHash","getHashOfPassword","str","curHash","curHashBin","charCountBin","saltBin","firstXOR","finalHashBin","finalHash","toUpperCase","slice","getExcelAlpha","colNum","remaining","aCharCode","columnName","mod","fromCharCode","getExcelCellRef","rowNum","getExcelRowCol","numeric","split","filter","el","alpha","row","col","reduce","index","arr","pow","getExcelTS","date","thisDt","Date","setDate","getDate","epoch","legacyLeapDate","diff2","getTime","ts","parseFloat","toFixed","sortCellRefs","aAtt","bAtt","arrayIntersectSafe","Array","ai","bi","result","push","TypeError","getAllCellsInExcelRange","range","cells","cell1props","cell2props","getAllCellsInNumericRange","row1","col1","row2","col2","j","sort","boolToInt","bool","module","exports"],"mappings":";;AAAA,IAAIA,QAAQC,QAAQ,kBAAR,CAAZ;;AAEA,IAAIC,UAAU,SAAVA,OAAU,CAACC,CAAD,EAAIC,CAAJ,EAAU;AACpB,QAAIC,YAAYF,EAAEG,MAAF,GAAWF,EAAEE,MAAb,GAAsBH,EAAEG,MAAxB,GAAiCF,EAAEE,MAAnD;;AAEA,QAAIC,YAAY,EAAhB;AACA,SAAK,IAAIC,IAAI,CAAb,EAAgBA,IAAIH,SAApB,EAA+BG,GAA/B,EAAoC;AAChCD,qBAAa,GAAb;AACH;;AAEDJ,QAAIM,OAAOF,YAAYJ,CAAnB,EAAsBO,MAAtB,CAA6B,CAACL,SAA9B,CAAJ;AACAD,QAAIK,OAAOF,YAAYH,CAAnB,EAAsBM,MAAtB,CAA6B,CAACL,SAA9B,CAAJ;;AAEA,QAAIM,WAAW,EAAf;AACA,SAAK,IAAIH,KAAI,CAAb,EAAgBA,KAAIL,EAAEG,MAAtB,EAA8BE,IAA9B,EAAmC;AAC/BG,oBAAYR,EAAEK,EAAF,MAASJ,EAAEI,EAAF,CAAT,GAAgB,CAAhB,GAAoB,CAAhC;AACH;AACD,WAAOG,QAAP;AACH,CAhBD;;AAkBA,IAAIC,cAAc,SAAdA,WAAc,GAAM;AACpB,QAAIC,OAAO,GAAX;AACA,QAAIC,WAAW,gEAAf;AACA,SAAK,IAAIN,IAAI,CAAb,EAAgBA,IAAI,EAApB,EAAwBA,GAAxB,EAA6B;AACzBK,gBAAQC,SAASC,MAAT,CAAgBC,KAAKC,KAAL,CAAWD,KAAKE,MAAL,KAAgBJ,SAASR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AAP;AACH;AACD,UAAM,IAAId,SAAJ,CAAc,qDAAd,CAAN;AACH,CAdD;;AAgBA;;;;AAIAe,OAAOC,OAAP,GAAiB;AACbzF,4BADa;AAEbmB,wCAFa;AAGbW,gCAHa;AAIbO,oCAJa;AAKbE,kCALa;AAMbY,0BANa;AAOba,8BAPa;AAQbG,0CARa;AASbO,oDATa;AAUbK,wDAVa;AAWbO;AAXa,CAAjB","file":"utils.js","sourcesContent":["let types = require('./types/index.js');\r\n\r\nlet _bitXOR = (a, b) => {\r\n let maxLength = a.length > b.length ? a.length : b.length;\r\n\r\n let padString = '';\r\n for (let i = 0; i < maxLength; i++) {\r\n padString += '0';\r\n }\r\n\r\n a = String(padString + a).substr(-maxLength);\r\n b = String(padString + b).substr(-maxLength);\r\n\r\n let response = '';\r\n for (let i = 0; i < a.length; i++) {\r\n response += a[i] === b[i] ? 0 : 1;\r\n }\r\n return response;\r\n};\r\n\r\nlet generateRId = () => {\r\n let text = 'R';\r\n let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\r\n for (let i = 0; i < 16; i++) {\r\n text += possible.charAt(Math.floor(Math.random() * possible.length));\r\n }\r\n return text;\r\n};\r\n\r\nlet _rotateBinary = (bin) => {\r\n return bin.substr(1, bin.length - 1) + bin.substr(0, 1);\r\n};\r\n\r\nlet _getHashForChar = (char, hash) => { \r\n hash = hash ? hash : '0000';\r\n let charCode = char.charCodeAt(0);\r\n let hashBin = parseInt(hash, 16).toString(2);\r\n let charBin = parseInt(charCode, 10).toString(2);\r\n hashBin = String('000000000000000' + hashBin).substr(-15);\r\n charBin = String('000000000000000' + charBin).substr(-15);\r\n let nextHash = _bitXOR(hashBin, charBin);\r\n nextHash = _rotateBinary(nextHash);\r\n nextHash = parseInt(nextHash, 2).toString(16);\r\n\r\n return nextHash;\r\n};\r\n\r\n// http://www.openoffice.org/sc/excelfileformat.pdf section 4.18.4\r\nlet getHashOfPassword = (str) => {\r\n let curHash = '0000';\r\n for (let i = str.length - 1; i >= 0; i--) {\r\n curHash = _getHashForChar(str[i], curHash);\r\n }\r\n let curHashBin = parseInt(curHash, 16).toString(2);\r\n let charCountBin = parseInt(str.length, 10).toString(2);\r\n let saltBin = parseInt('CE4B', 16).toString(2);\r\n\r\n let firstXOR = _bitXOR(curHashBin, charCountBin);\r\n let finalHashBin = _bitXOR(firstXOR, saltBin);\r\n let finalHash = String('0000' + parseInt(finalHashBin, 2).toString(16).toUpperCase()).slice(-4);\r\n\r\n return finalHash;\r\n};\r\n\r\n/**\r\n * Translates a column number into the Alpha equivalent used by Excel\r\n * @function getExcelAlpha\r\n * @param {Number} colNum Column number that is to be transalated\r\n * @returns {String} The Excel alpha representation of the column number\r\n * @example\r\n * // returns B\r\n * getExcelAlpha(2);\r\n */\r\nlet getExcelAlpha = (colNum) => {\r\n let remaining = colNum;\r\n let aCharCode = 65;\r\n let columnName = '';\r\n while (remaining > 0) {\r\n let mod = (remaining - 1) % 26;\r\n columnName = String.fromCharCode(aCharCode + mod) + columnName;\r\n remaining = (remaining - 1 - mod) / 26;\r\n } \r\n return columnName;\r\n};\r\n\r\n/**\r\n * Translates a column number into the Alpha equivalent used by Excel\r\n * @function getExcelAlpha\r\n * @param {Number} rowNum Row number that is to be transalated\r\n * @param {Number} colNum Column number that is to be transalated\r\n * @returns {String} The Excel alpha representation of the column number\r\n * @example\r\n * // returns B1\r\n * getExcelCellRef(1, 2);\r\n */\r\nlet getExcelCellRef = (rowNum, colNum) => {\r\n let remaining = colNum;\r\n let aCharCode = 65;\r\n let columnName = '';\r\n while (remaining > 0) {\r\n let mod = (remaining - 1) % 26;\r\n columnName = String.fromCharCode(aCharCode + mod) + columnName;\r\n remaining = (remaining - 1 - mod) / 26;\r\n } \r\n return columnName + rowNum;\r\n};\r\n\r\n/**\r\n * Translates a Excel cell represenation into row and column numerical equivalents \r\n * @function getExcelRowCol\r\n * @param {String} str Excel cell representation\r\n * @returns {Object} Object keyed with row and col\r\n * @example\r\n * // returns {row: 2, col: 3}\r\n * getExcelRowCol('C2')\r\n */\r\nlet getExcelRowCol = (str) => {\r\n let numeric = str.split(/\\D/).filter(function (el) {\r\n return el !== '';\r\n })[0];\r\n let alpha = str.split(/\\d/).filter(function (el) {\r\n return el !== '';\r\n })[0];\r\n let row = parseInt(numeric, 10);\r\n let col = alpha.toUpperCase().split('').reduce(function (a, b, index, arr) {\r\n return a + (b.charCodeAt(0) - 64) * Math.pow(26, arr.length - index - 1);\r\n }, 0);\r\n return { row: row, col: col };\r\n};\r\n\r\n/**\r\n * Translates a date into Excel timestamp\r\n * @function getExcelTS\r\n * @param {Date} date Date to translate\r\n * @returns {Number} Excel timestamp\r\n * @example\r\n * // returns 29810.958333333332\r\n * getExcelTS(new Date('08/13/1981'));\r\n */\r\nlet getExcelTS = (date) => {\r\n\r\n let thisDt = new Date(date);\r\n thisDt.setDate(thisDt.getDate() + 1);\r\n\r\n let epoch = new Date('1900-01-01T00:00:00.0000Z');\r\n\r\n // Handle legacy leap year offset as described in §18.17.4.1\r\n const legacyLeapDate = new Date('1900-02-28T23:59:59.999Z');\r\n if (thisDt - legacyLeapDate > 0) {\r\n thisDt.setDate(thisDt.getDate() + 1);\r\n } \r\n\r\n // Get milliseconds between date sent to function and epoch \r\n let diff2 = thisDt.getTime() - epoch.getTime();\r\n\r\n let ts = diff2 / (1000 * 60 * 60 * 24);\r\n\r\n return parseFloat(ts.toFixed(7));\r\n};\r\n\r\nlet sortCellRefs = (a, b) => {\r\n let aAtt = getExcelRowCol(a);\r\n let bAtt = getExcelRowCol(b);\r\n if (aAtt.col === bAtt.col) {\r\n return aAtt.row - bAtt.row;\r\n } else {\r\n return aAtt.col - bAtt.col;\r\n }\r\n};\r\n\r\nlet arrayIntersectSafe = (a, b) => {\r\n\r\n if (a instanceof Array && b instanceof Array) {\r\n var ai = 0, bi = 0;\r\n var result = new Array();\r\n\r\n while (ai < a.length && bi < b.length) {\r\n if (a[ai] < b[bi]) {\r\n ai++;\r\n } else if (a[ai] > b[bi]) {\r\n bi++;\r\n } else {\r\n result.push(a[ai]);\r\n ai++;\r\n bi++;\r\n }\r\n }\r\n return result;\r\n } else {\r\n throw new TypeError('Both variables sent to arrayIntersectSafe must be arrays');\r\n }\r\n};\r\n\r\nlet getAllCellsInExcelRange = (range) => {\r\n var cells = range.split(':');\r\n var cell1props = getExcelRowCol(cells[0]);\r\n var cell2props = getExcelRowCol(cells[1]);\r\n return getAllCellsInNumericRange(cell1props.row, cell1props.col, cell2props.row, cell2props.col);\r\n};\r\n\r\nlet getAllCellsInNumericRange = (row1, col1, row2, col2) => {\r\n var response = [];\r\n row2 = row2 ? row2 : row1;\r\n col2 = col2 ? col2 : col1;\r\n for (var i = row1; i <= row2; i++) {\r\n for (var j = col1; j <= col2; j++) {\r\n response.push(getExcelAlpha(j) + i);\r\n }\r\n }\r\n return response.sort(sortCellRefs);\r\n};\r\n\r\nlet boolToInt = (bool) => {\r\n if (bool === true) {\r\n return 1;\r\n }\r\n if (bool === false) {\r\n return 0;\r\n }\r\n if (parseInt(bool) === 1) {\r\n return 1;\r\n }\r\n if (parseInt(bool) === 0) {\r\n return 0;\r\n }\r\n throw new TypeError('Value sent to boolToInt must be true, false, 1 or 0');\r\n};\r\n\r\n/*\r\n * Helper Functions\r\n */\r\n\r\nmodule.exports = {\r\n generateRId,\r\n getHashOfPassword,\r\n getExcelAlpha,\r\n getExcelCellRef,\r\n getExcelRowCol,\r\n getExcelTS,\r\n sortCellRefs,\r\n arrayIntersectSafe,\r\n getAllCellsInExcelRange,\r\n getAllCellsInNumericRange,\r\n boolToInt\r\n};"]} \ No newline at end of file diff --git a/distribution/lib/workbook/builder.js b/distribution/lib/workbook/builder.js new file mode 100644 index 00000000..7a77de95 --- /dev/null +++ b/distribution/lib/workbook/builder.js @@ -0,0 +1,620 @@ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var xmlbuilder = require('xmlbuilder'); +var JSZip = require('jszip'); +var fs = require('fs'); +var CTColor = require('../style/classes/ctColor.js'); +var utils = require('../utils'); + +var addRootContentTypesXML = function addRootContentTypesXML(promiseObj) { + // Required as stated in §12.2 + return new Promise(function (resolve, reject) { + var xml = xmlbuilder.create('Types', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); + + var contentTypesAdded = []; + var extensionsAdded = []; + promiseObj.wb.sheets.forEach(function (s, i) { + if (s.drawingCollection.length > 0) { + s.drawingCollection.drawings.forEach(function (d) { + if (extensionsAdded.indexOf(d.extension) < 0) { + var typeRef = d.contentType + '.' + d.extension; + if (contentTypesAdded.indexOf(typeRef) < 0) { + xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension); + } + extensionsAdded.push(d.extension); + } + }); + } + if (Object.keys(s.comments).length > 0) { + if (extensionsAdded.indexOf('vml') < 0) { + xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing'); + extensionsAdded.push('vml'); + } + } + + if (s.legacyDrawingHeaderFooter.length > 0) { + if (extensionsAdded.indexOf('vml') < 0) { + xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing'); + extensionsAdded.push('vml'); + } + if (extensionsAdded.indexOf('png') < 0) { + xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png'); + extensionsAdded.push('png'); + } + } + }); + xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml'); + xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml'); + xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml'); + promiseObj.wb.sheets.forEach(function (s, i) { + xml.ele('Override').att('PartName', '/xl/worksheets/sheet' + (i + 1) + '.xml').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'); + + if (s.drawingCollection.length > 0) { + xml.ele('Override').att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml').att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml'); + } + if (Object.keys(s.comments).length > 0) { + xml.ele('Override').att('PartName', '/xl/comments' + s.sheetId + '.xml').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'); + } + }); + xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml'); + xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml'); + xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml'); + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.file('[Content_Types].xml', xmlString); + resolve(promiseObj); + }); +}; + +var addRootRelsXML = function addRootRelsXML(promiseObj) { + // Required as stated in §12.2 + return new Promise(function (resolve, reject) { + var xml = xmlbuilder.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + xml.ele('Relationship').att('Id', 'rId1').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument').att('Target', 'xl/workbook.xml'); + + xml.ele('Relationship').att('Id', 'rId2').att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties').att('Target', 'docProps/core.xml'); + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('_rels').file('.rels', xmlString); + resolve(promiseObj); + }); +}; + +var addWorkbookXML = function addWorkbookXML(promiseObj) { + // Required as stated in §12.2 + return new Promise(function (resolve, reject) { + + var xml = xmlbuilder.create('workbook', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }); + xml.att('mc:Ignorable', 'x15'); + xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); + xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); + xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'); + + var booksViewEle = xml.ele('bookViews'); + var workbookViewEle = booksViewEle.ele('workbookView'); + // bookViews (§18.2.1) + if (promiseObj.wb.opts.workbookView) { + var viewOpts = promiseObj.wb.opts.workbookView; + if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) { + workbookViewEle.att('activeTab', viewOpts.activeTab); + } else { + var firstVisibleTab = 0; + for (var i = 0; i < promiseObj.wb.sheets.length; i++) { + var sheet = promiseObj.wb.sheets[i]; + if (!sheet.opts.hidden) { + firstVisibleTab = i; + break; + } + } + workbookViewEle.att('activeTab', firstVisibleTab); + } + if (viewOpts.autoFilterDateGrouping) { + workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping)); + } + if (viewOpts.firstSheet) { + workbookViewEle.att('firstSheet', viewOpts.firstSheet); + } + if (viewOpts.minimized) { + workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized)); + } + if (viewOpts.showHorizontalScroll) { + workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll)); + } + if (viewOpts.showSheetTabs) { + workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs)); + } + if (viewOpts.showVerticalScroll) { + workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll)); + } + if (viewOpts.tabRatio) { + workbookViewEle.att('tabRatio', viewOpts.tabRatio); + } + if (viewOpts.visibility) { + workbookViewEle.att('visibility', viewOpts.visibility); + } + if (viewOpts.windowWidth) { + workbookViewEle.att('windowWidth', viewOpts.windowWidth); + } + if (viewOpts.windowHeight) { + workbookViewEle.att('windowHeight', viewOpts.windowHeight); + } + if (viewOpts.xWindow) { + workbookViewEle.att('xWindow', viewOpts.xWindow); + } + if (viewOpts.yWindow) { + workbookViewEle.att('yWindow', viewOpts.yWindow); + } + if (viewOpts.showComments) { + workbookViewEle.att('showComments', viewOpts.showComments); + } + } + + var sheetsEle = xml.ele('sheets'); + promiseObj.wb.sheets.forEach(function (s, i) { + var sheet = sheetsEle.ele('sheet').att('name', s.name).att('sheetId', i + 1).att('r:id', 'rId' + (i + 1)); + + if (s.opts.hidden) { + sheet.att('state', 'hidden'); + } + + if (s.printArea) { + var name = s.name; + var startCellRef = '$' + utils.getExcelAlpha(s.printArea.startCol) + '$' + s.printArea.startRow; + var endCellRef = '$' + utils.getExcelAlpha(s.printArea.endCol) + '$' + s.printArea.endRow; + s.wb.definedNameCollection.addDefinedName({ + name: '_xlnm.Print_Area', + localSheetId: s.localSheetId, + refFormula: '\'' + name + '\'!' + startCellRef + ':' + endCellRef + }); + } + }); + + if (!promiseObj.wb.definedNameCollection.isEmpty) { + promiseObj.wb.definedNameCollection.addToXMLele(xml); + } + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString); + resolve(promiseObj); + }); +}; + +var addWorkbookRelsXML = function addWorkbookRelsXML(promiseObj) { + // Required as stated in §12.2 + return new Promise(function (resolve, reject) { + + var xml = xmlbuilder.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + xml.ele('Relationship').att('Id', 'rId' + (promiseObj.wb.sheets.length + 1)).att('Target', 'sharedStrings.xml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'); + + xml.ele('Relationship').att('Id', 'rId' + (promiseObj.wb.sheets.length + 2)).att('Target', 'styles.xml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles'); + + promiseObj.wb.sheets.forEach(function (s, i) { + xml.ele('Relationship').att('Id', 'rId' + (i + 1)).att('Target', 'worksheets/sheet' + (i + 1) + '.xml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet'); + }); + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString); + resolve(promiseObj); + }); +}; + +var addCorePropertiesXML = function addCorePropertiesXML(promiseObj) { + var xml = xmlbuilder.create('cp:coreProperties', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true + }).att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties').att('xmlns:dc', 'http://purl.org/dc/elements/1.1/').att('xmlns:dcterms', 'http://purl.org/dc/terms/').att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/').att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + + xml.ele('dc:creator').text(promiseObj.wb.author); + xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author); + var dtStr = new Date().toISOString(); + xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr); + xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr); + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('docProps').file('core.xml', xmlString); + return promiseObj; +}; + +var addWorksheetsXML = function addWorksheetsXML(promiseObj) { + // Required as stated in §12.2 + return new Promise(function (resolve, reject) { + + var curSheet = 0; + + var processNextSheet = function processNextSheet() { + var thisSheet = promiseObj.wb.sheets[curSheet]; + if (thisSheet) { + curSheet++; + thisSheet.generateXML().then(function (xml) { + return new Promise(function (resolve) { + // Add worksheet to zip + promiseObj.xlsx.folder('xl').folder('worksheets').file('sheet' + curSheet + '.xml', xml); + + resolve(); + }); + }).then(function () { + return thisSheet.generateRelsXML(); + }).then(function (xml) { + return new Promise(function (resolve) { + if (xml) { + promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file('sheet' + curSheet + '.xml.rels', xml); + } + resolve(); + }); + }).then(function () { + return thisSheet.generateCommentsXML(); + }).then(function (xml) { + return new Promise(function (resolve) { + if (xml) { + promiseObj.xlsx.folder('xl').file('comments' + curSheet + '.xml', xml); + } + resolve(); + }); + }).then(function () { + return thisSheet.generateCommentsVmlXML(); + }).then(function (xml) { + return new Promise(function (resolve) { + if (xml) { + promiseObj.xlsx.folder('xl').folder('drawings').file('commentsVml' + curSheet + '.vml', xml); + } + resolve(); + }); + }).then(processNextSheet).catch(function (e) { + promiseObj.wb.logger.error(e.stack); + }); + } else { + resolve(promiseObj); + } + }; + processNextSheet(); + }); +}; + +/** + * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer() + * @private + * @memberof Workbook + * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars + * @return {Promise} Resolves with promiseObj + */ +var addSharedStringsXML = function addSharedStringsXML(promiseObj) { + // §12.3.15 Shared String Table Part + return new Promise(function (resolve, reject) { + + var xml = xmlbuilder.create('sst', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('count', promiseObj.wb.sharedStrings.length).att('uniqueCount', promiseObj.wb.sharedStrings.length).att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + + promiseObj.wb.sharedStrings.forEach(function (s) { + if (typeof s === 'string') { + xml.ele('si').ele('t').txt(s); + } else if (s instanceof Array) { + (function () { + + var thisSI = xml.ele('si'); + var theseRuns = []; // §18.4.4 r (Rich Text Run) + var currProps = {}; + var curRun = void 0; + var i = 0; + while (i < s.length) { + if (typeof s[i] === 'string') { + if (curRun === undefined) { + theseRuns.push({ + props: {}, + text: '' + }); + curRun = theseRuns[theseRuns.length - 1]; + } + curRun.text = curRun.text + s[i]; + } else if (_typeof(s[i]) === 'object') { + theseRuns.push({ + props: {}, + text: '' + }); + curRun = theseRuns[theseRuns.length - 1]; + Object.keys(s[i]).forEach(function (k) { + currProps[k] = s[i][k]; + }); + Object.keys(currProps).forEach(function (k) { + curRun.props[k] = currProps[k]; + }); + if (s[i].value !== undefined) { + curRun.text = s[i].value; + } + } + i++; + } + + theseRuns.forEach(function (run) { + if (Object.keys(run).length < 1) { + thisSI.ele('t', run.text).att('xml:space', 'preserve'); + } else { + var thisRun = thisSI.ele('r'); + var thisRunProps = thisRun.ele('rPr'); + typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null; + run.props.bold === true ? thisRunProps.ele('b') : null; + run.props.italics === true ? thisRunProps.ele('i') : null; + run.props.strike === true ? thisRunProps.ele('strike') : null; + run.props.outline === true ? thisRunProps.ele('outline') : null; + run.props.shadow === true ? thisRunProps.ele('shadow') : null; + run.props.condense === true ? thisRunProps.ele('condense') : null; + run.props.extend === true ? thisRunProps.ele('extend') : null; + if (typeof run.props.color === 'string') { + var thisColor = new CTColor(run.props.color); + thisColor.addToXMLele(thisRunProps); + } + typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null; + run.props.underline === true ? thisRunProps.ele('u') : null; + typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null; + thisRun.ele('t', run.text).att('xml:space', 'preserve'); + } + }); + })(); + } + }); + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString); + + resolve(promiseObj); + }); +}; + +var addStylesXML = function addStylesXML(promiseObj) { + // §12.3.20 Styles Part + return new Promise(function (resolve, reject) { + + var xml = xmlbuilder.create('styleSheet', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('mc:Ignorable', 'x14ac').att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main').att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006').att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'); + + if (promiseObj.wb.styleData.numFmts.length > 0) { + var nfXML = xml.ele('numFmts').att('count', promiseObj.wb.styleData.numFmts.length); + promiseObj.wb.styleData.numFmts.forEach(function (nf) { + nf.addToXMLele(nfXML); + }); + } + + var fontXML = xml.ele('fonts').att('count', promiseObj.wb.styleData.fonts.length); + promiseObj.wb.styleData.fonts.forEach(function (f) { + f.addToXMLele(fontXML); + }); + + var fillXML = xml.ele('fills').att('count', promiseObj.wb.styleData.fills.length); + promiseObj.wb.styleData.fills.forEach(function (f) { + var fXML = fillXML.ele('fill'); + f.addToXMLele(fXML); + }); + + var borderXML = xml.ele('borders').att('count', promiseObj.wb.styleData.borders.length); + promiseObj.wb.styleData.borders.forEach(function (b) { + b.addToXMLele(borderXML); + }); + + var cellXfsXML = xml.ele('cellXfs').att('count', promiseObj.wb.styles.length); + promiseObj.wb.styles.forEach(function (s) { + s.addXFtoXMLele(cellXfsXML); + }); + + if (promiseObj.wb.dxfCollection.length > 0) { + promiseObj.wb.dxfCollection.addToXMLele(xml); + } + + var xmlString = xml.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').file('styles.xml', xmlString); + + resolve(promiseObj); + }); +}; + +var addDrawingsXML = function addDrawingsXML(promiseObj) { + return new Promise(function (resolve) { + if (!promiseObj.wb.mediaCollection.isEmpty) { + + promiseObj.wb.sheets.forEach(function (ws) { + if (!ws.drawingCollection.isEmpty) { + + var drawingRelXML = xmlbuilder.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + var drawingsXML = xmlbuilder.create('xdr:wsDr', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }); + drawingsXML.att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main').att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); + + ws.drawingCollection.drawings.forEach(function (d) { + + if (d.kind === 'image') { + var target = 'image' + d.id + '.' + d.extension; + + var image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image; + promiseObj.xlsx.folder('xl').folder('media').file(target, image); + + drawingRelXML.ele('Relationship').att('Id', d.rId).att('Target', '../media/' + target).att('Type', d.type); + } + + d.addToXMLele(drawingsXML); + }); + + var drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars); + var drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr); + promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr); + } + }); + } + resolve(promiseObj); + }); +}; + +var addLegacyHeaderFooterDrawingsXML = function addLegacyHeaderFooterDrawingsXML(promiseObj) { + return new Promise(function (resolve) { + console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML'); + if (!promiseObj.wb.mediaCollection.isEmpty) { + + promiseObj.wb.sheets.forEach(function (ws) { + + if (!ws.legacyDrawingHeaderFooter.isEmpty) { + + var drawingRelXML = xmlbuilder.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }).att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + var drawingsVML = xmlbuilder.begin().ele('xml'); + drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml'); + drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); + + var sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit'); + sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); + + var st = drawingsVML.ele('v:shapetype').att('id', '_x0000_t75').att('coordsize', '21600,21600').att('o:spt', '75').att('o:preferrelative', 't').att('path', 'm@4@5l@4@11@9@11@9@5xe').att('filled', 'f').att('stroked', 'f'); + + st.ele('v:stroke').att('joinstyle', 'miter'); + var vf = st.ele('v:formulas'); + vf.ele('v:f').att('eqn', "if lineDrawn pixelLineWidth 0"); + vf.ele('v:f').att('eqn', "sum @0 1 0"); + vf.ele('v:f').att('eqn', "sum 0 0 @1"); + vf.ele('v:f').att('eqn', "prod @2 1 2"); + vf.ele('v:f').att('eqn', "prod @3 21600 pixelWidth"); + vf.ele('v:f').att('eqn', "prod @3 21600 pixelHeight"); + vf.ele('v:f').att('eqn', "sum @0 0 1"); + vf.ele('v:f').att('eqn', "prod @6 1 2"); + vf.ele('v:f').att('eqn', "prod @7 21600 pixelWidth"); + vf.ele('v:f').att('eqn', "sum @8 21600 0"); + vf.ele('v:f').att('eqn', "prod @7 21600 pixelHeight"); + vf.ele('v:f').att('eqn', "sum @10 21600 0"); + + st.ele('v:path').att('o:extrusionok', 'f').att('gradientshapeok', 't').att('o:connecttype', 'rect'); + + st.ele('o:lock').att('v:ext', 'edit').att('aspectratio', 't'); + + // const sh = drawingsVML.ele('v:shape'); + // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75') + // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`); + // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1') + // sh.ele('o:lock').att('v:ext','edit').att('rotation','t'); + + // const textB = sh.ele('v:textbox').text('VML TextBox') + + ws.legacyDrawingHeaderFooter.drawings.forEach(function (d) { + + if (d.kind === 'image') { + var target = 'image' + d.id + '.' + d.extension; + + var image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image; + promiseObj.xlsx.folder('xl').folder('media').file(target, image); + + drawingRelXML.ele('Relationship').att('Id', d.rId).att('Target', '../media/' + target).att('Type', d.type); + } + + d.addToXMLele(drawingsVML); + }); + + var drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars); + var drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars); + console.log('Genenrating VML Drawing File for ', ws.sheetId); + promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr); + promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr); + } + }); + } + resolve(promiseObj); + }); +}; + +/** + * Use JSZip to generate file to a node buffer + * @private + * @memberof Workbook + * @param {Workbook} wb Workbook instance + * @return {Promise} resolves with Buffer + */ +var writeToBuffer = function writeToBuffer(wb) { + return new Promise(function (resolve, reject) { + var promiseObj = { + wb: wb, + xlsx: new JSZip(), + xmlOutVars: {} + }; + + if (promiseObj.wb.sheets.length === 0) { + promiseObj.wb.Worksheet(); + } + + addRootContentTypesXML(promiseObj).then(addWorksheetsXML).then(addRootRelsXML).then(addWorkbookXML).then(addWorkbookRelsXML).then(addCorePropertiesXML).then(addSharedStringsXML).then(addStylesXML).then(addDrawingsXML).then(addLegacyHeaderFooterDrawingsXML).then(function () { + wb.opts.jszip.type = 'nodebuffer'; + promiseObj.xlsx.generateAsync(wb.opts.jszip).then(function (buf) { + resolve(buf); + }).catch(function (e) { + reject(e); + }); + }).catch(function (e) { + reject(e); + }); + }); +}; + +/** + * @desc Currently only used for testing the XML generated for a Workbook. + * @param {*} wb Workbook instance + * @return {Promise} resolves with Workbook XML + */ +var workbookXML = function workbookXML(wb) { + var promiseObj = { + wb: wb, + xlsx: new JSZip(), + xmlOutVars: {} + }; + + return addWorkbookXML(promiseObj).then(function (result) { + return result.xlsx.files['xl/workbook.xml']._data; + }); +}; + +module.exports = { + writeToBuffer: writeToBuffer, + workbookXML: workbookXML +}; +//# sourceMappingURL=builder.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/builder.js.map b/distribution/lib/workbook/builder.js.map new file mode 100644 index 00000000..1769304a --- /dev/null +++ b/distribution/lib/workbook/builder.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/builder.js"],"names":["xmlbuilder","require","JSZip","fs","CTColor","utils","addRootContentTypesXML","promiseObj","Promise","resolve","reject","xml","create","att","contentTypesAdded","extensionsAdded","wb","sheets","forEach","s","i","drawingCollection","length","drawings","d","indexOf","extension","typeRef","contentType","ele","push","Object","keys","comments","legacyDrawingHeaderFooter","sheetId","xmlString","doc","end","xmlOutVars","xlsx","file","addRootRelsXML","folder","addWorkbookXML","booksViewEle","workbookViewEle","opts","workbookView","viewOpts","activeTab","undefined","firstVisibleTab","sheet","hidden","autoFilterDateGrouping","boolToInt","firstSheet","minimized","showHorizontalScroll","showSheetTabs","showVerticalScroll","tabRatio","visibility","windowWidth","windowHeight","xWindow","yWindow","showComments","sheetsEle","name","printArea","startCellRef","getExcelAlpha","startCol","startRow","endCellRef","endCol","endRow","definedNameCollection","addDefinedName","localSheetId","refFormula","isEmpty","addToXMLele","addWorkbookRelsXML","addCorePropertiesXML","text","author","dtStr","Date","toISOString","addWorksheetsXML","curSheet","processNextSheet","thisSheet","generateXML","then","generateRelsXML","generateCommentsXML","generateCommentsVmlXML","catch","e","logger","error","stack","addSharedStringsXML","sharedStrings","txt","Array","thisSI","theseRuns","currProps","curRun","props","k","value","run","thisRun","thisRunProps","bold","italics","strike","outline","shadow","condense","extend","color","thisColor","size","underline","vertAlign","addStylesXML","styleData","numFmts","nfXML","nf","fontXML","fonts","f","fillXML","fills","fXML","borderXML","borders","b","cellXfsXML","styles","addXFtoXMLele","dxfCollection","addDrawingsXML","mediaCollection","ws","drawingRelXML","drawingsXML","kind","target","id","image","imagePath","readFileSync","rId","type","drawingsXMLStr","drawingRelXMLStr","addLegacyHeaderFooterDrawingsXML","console","log","drawingsVML","begin","sl","st","vf","writeToBuffer","Worksheet","jszip","generateAsync","buf","workbookXML","result","files","_data","module","exports"],"mappings":";;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ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const fs = require('fs');\r\nconst CTColor = require('../style/classes/ctColor.js');\r\nconst utils = require('../utils');\r\n\r\nlet addRootContentTypesXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Types', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');\r\n\r\n let contentTypesAdded = [];\r\n let extensionsAdded = [];\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n if (s.drawingCollection.length > 0) {\r\n s.drawingCollection.drawings.forEach((d) => {\r\n if (extensionsAdded.indexOf(d.extension) < 0) {\r\n let typeRef = d.contentType + '.' + d.extension;\r\n if (contentTypesAdded.indexOf(typeRef) < 0) {\r\n xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension);\r\n }\r\n extensionsAdded.push(d.extension);\r\n }\r\n });\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n }\r\n \r\n if(s.legacyDrawingHeaderFooter.length > 0){\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n if (extensionsAdded.indexOf('png') < 0){\r\n xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png');\r\n extensionsAdded.push('png');\r\n }\r\n }\r\n });\r\n xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml');\r\n xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml')\r\n \r\n\r\n if (s.drawingCollection.length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml')\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/comments' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml')\r\n }\r\n });\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.file('[Content_Types].xml', xmlString);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addRootRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId1')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument')\r\n .att('Target', 'xl/workbook.xml');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId2')\r\n .att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties')\r\n .att('Target', 'docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('_rels').file('.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'workbook', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n xml.att('mc:Ignorable', 'x15');\r\n xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');\r\n xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');\r\n\r\n let booksViewEle = xml.ele('bookViews');\r\n let workbookViewEle = booksViewEle.ele('workbookView');\r\n // bookViews (§18.2.1)\r\n if (promiseObj.wb.opts.workbookView) {\r\n const viewOpts = promiseObj.wb.opts.workbookView;\r\n if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) {\r\n workbookViewEle.att('activeTab', viewOpts.activeTab);\r\n } else {\r\n let firstVisibleTab = 0;\r\n for (let i = 0; i < promiseObj.wb.sheets.length; i++) {\r\n const sheet = promiseObj.wb.sheets[i];\r\n if (!sheet.opts.hidden) {\r\n firstVisibleTab = i;\r\n break;\r\n }\r\n }\r\n workbookViewEle.att('activeTab', firstVisibleTab);\r\n }\r\n if (viewOpts.autoFilterDateGrouping) {\r\n workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping));\r\n }\r\n if (viewOpts.firstSheet) {\r\n workbookViewEle.att('firstSheet', viewOpts.firstSheet);\r\n }\r\n if (viewOpts.minimized) {\r\n workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized));\r\n }\r\n if (viewOpts.showHorizontalScroll) {\r\n workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll));\r\n }\r\n if (viewOpts.showSheetTabs) {\r\n workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs));\r\n }\r\n if (viewOpts.showVerticalScroll) {\r\n workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll));\r\n }\r\n if (viewOpts.tabRatio) {\r\n workbookViewEle.att('tabRatio', viewOpts.tabRatio);\r\n }\r\n if (viewOpts.visibility) {\r\n workbookViewEle.att('visibility', viewOpts.visibility);\r\n }\r\n if (viewOpts.windowWidth) {\r\n workbookViewEle.att('windowWidth', viewOpts.windowWidth);\r\n }\r\n if (viewOpts.windowHeight) {\r\n workbookViewEle.att('windowHeight', viewOpts.windowHeight);\r\n }\r\n if (viewOpts.xWindow) {\r\n workbookViewEle.att('xWindow', viewOpts.xWindow);\r\n }\r\n if (viewOpts.yWindow) {\r\n workbookViewEle.att('yWindow', viewOpts.yWindow);\r\n }\r\n if (viewOpts.showComments) {\r\n workbookViewEle.att('showComments', viewOpts.showComments);\r\n }\r\n }\r\n\r\n let sheetsEle = xml.ele('sheets');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n const sheet = sheetsEle.ele('sheet')\r\n .att('name', s.name)\r\n .att('sheetId', i + 1)\r\n .att('r:id', `rId${i + 1}`);\r\n\r\n if (s.opts.hidden) {\r\n sheet.att('state', 'hidden');\r\n }\r\n\r\n if (s.printArea) {\r\n const name = s.name;\r\n const startCellRef = `$${utils.getExcelAlpha(s.printArea.startCol)}$${s.printArea.startRow}`;\r\n const endCellRef = `$${utils.getExcelAlpha(s.printArea.endCol)}$${s.printArea.endRow}`;\r\n s.wb.definedNameCollection.addDefinedName({\r\n name: '_xlnm.Print_Area',\r\n localSheetId: s.localSheetId,\r\n refFormula: `'${name}'!${startCellRef}:${endCellRef}`,\r\n });\r\n }\r\n });\r\n\r\n if (!promiseObj.wb.definedNameCollection.isEmpty) {\r\n promiseObj.wb.definedNameCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 1}`)\r\n .att('Target', 'sharedStrings.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 2}`)\r\n .att('Target', 'styles.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles');\r\n\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${i + 1}`)\r\n .att('Target', `worksheets/sheet${i + 1}.xml`)\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet');\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addCorePropertiesXML = (promiseObj) => {\r\n let xml = xmlbuilder.create(\r\n 'cp:coreProperties', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true\r\n }\r\n )\r\n .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties')\r\n .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/')\r\n .att('xmlns:dcterms', 'http://purl.org/dc/terms/')\r\n .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/')\r\n .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');\r\n\r\n xml.ele('dc:creator').text(promiseObj.wb.author);\r\n xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author);\r\n let dtStr = new Date().toISOString();\r\n xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('docProps').file('core.xml', xmlString);\r\n return promiseObj;\r\n};\r\n\r\nlet addWorksheetsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let curSheet = 0;\r\n\r\n let processNextSheet = () => {\r\n let thisSheet = promiseObj.wb.sheets[curSheet];\r\n if (thisSheet) {\r\n curSheet++;\r\n thisSheet.generateXML()\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n // Add worksheet to zip\r\n promiseObj.xlsx.folder('xl').folder('worksheets').file(`sheet${curSheet}.xml`, xml);\r\n\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateRelsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file(`sheet${curSheet}.xml.rels`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').file(`comments${curSheet}.xml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsVmlXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('drawings').file(`commentsVml${curSheet}.vml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(processNextSheet)\r\n .catch((e) => {\r\n promiseObj.wb.logger.error(e.stack);\r\n });\r\n } else {\r\n resolve(promiseObj);\r\n }\r\n };\r\n processNextSheet();\r\n\r\n });\r\n};\r\n\r\n/**\r\n * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer()\r\n * @private\r\n * @memberof Workbook\r\n * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars\r\n * @return {Promise} Resolves with promiseObj\r\n */\r\nlet addSharedStringsXML = (promiseObj) => {\r\n // §12.3.15 Shared String Table Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'sst', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('count', promiseObj.wb.sharedStrings.length)\r\n .att('uniqueCount', promiseObj.wb.sharedStrings.length)\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n promiseObj.wb.sharedStrings.forEach((s) => {\r\n if (typeof s === 'string') {\r\n xml.ele('si').ele('t').txt(s);\r\n } else if (s instanceof Array) {\r\n\r\n let thisSI = xml.ele('si');\r\n let theseRuns = []; // §18.4.4 r (Rich Text Run)\r\n let currProps = {};\r\n let curRun;\r\n let i = 0;\r\n while (i < s.length) {\r\n if (typeof s[i] === 'string') {\r\n if (curRun === undefined) {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n }\r\n curRun.text = curRun.text + s[i];\r\n } else if (typeof s[i] === 'object') {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n Object.keys(s[i]).forEach((k) => {\r\n currProps[k] = s[i][k];\r\n });\r\n Object.keys(currProps).forEach((k) => {\r\n curRun.props[k] = currProps[k];\r\n });\r\n if (s[i].value !== undefined) {\r\n curRun.text = s[i].value;\r\n }\r\n }\r\n i++;\r\n }\r\n\r\n theseRuns.forEach((run) => {\r\n if (Object.keys(run).length < 1) {\r\n thisSI.ele('t', run.text).att('xml:space', 'preserve');\r\n } else {\r\n let thisRun = thisSI.ele('r');\r\n let thisRunProps = thisRun.ele('rPr');\r\n typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null;\r\n run.props.bold === true ? thisRunProps.ele('b') : null;\r\n run.props.italics === true ? thisRunProps.ele('i') : null;\r\n run.props.strike === true ? thisRunProps.ele('strike') : null;\r\n run.props.outline === true ? thisRunProps.ele('outline') : null;\r\n run.props.shadow === true ? thisRunProps.ele('shadow') : null;\r\n run.props.condense === true ? thisRunProps.ele('condense') : null;\r\n run.props.extend === true ? thisRunProps.ele('extend') : null;\r\n if (typeof run.props.color === 'string') {\r\n let thisColor = new CTColor(run.props.color);\r\n thisColor.addToXMLele(thisRunProps);\r\n }\r\n typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null;\r\n run.props.underline === true ? thisRunProps.ele('u') : null;\r\n typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null;\r\n thisRun.ele('t', run.text).att('xml:space', 'preserve');\r\n }\r\n });\r\n\r\n }\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addStylesXML = (promiseObj) => {\r\n // §12.3.20 Styles Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'styleSheet', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n if (promiseObj.wb.styleData.numFmts.length > 0) {\r\n let nfXML = xml\r\n .ele('numFmts')\r\n .att('count', promiseObj.wb.styleData.numFmts.length);\r\n promiseObj.wb.styleData.numFmts.forEach((nf) => {\r\n nf.addToXMLele(nfXML);\r\n });\r\n }\r\n\r\n let fontXML = xml\r\n .ele('fonts')\r\n .att('count', promiseObj.wb.styleData.fonts.length);\r\n promiseObj.wb.styleData.fonts.forEach((f) => {\r\n f.addToXMLele(fontXML);\r\n });\r\n\r\n let fillXML = xml\r\n .ele('fills')\r\n .att('count', promiseObj.wb.styleData.fills.length);\r\n promiseObj.wb.styleData.fills.forEach((f) => {\r\n let fXML = fillXML.ele('fill');\r\n f.addToXMLele(fXML);\r\n });\r\n\r\n let borderXML = xml\r\n .ele('borders')\r\n .att('count', promiseObj.wb.styleData.borders.length);\r\n promiseObj.wb.styleData.borders.forEach((b) => {\r\n b.addToXMLele(borderXML);\r\n });\r\n\r\n\r\n let cellXfsXML = xml\r\n .ele('cellXfs')\r\n .att('count', promiseObj.wb.styles.length);\r\n promiseObj.wb.styles.forEach((s) => {\r\n s.addXFtoXMLele(cellXfsXML);\r\n });\r\n\r\n if (promiseObj.wb.dxfCollection.length > 0) {\r\n promiseObj.wb.dxfCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('styles.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n if (!ws.drawingCollection.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsXML = xmlbuilder.create(\r\n 'xdr:wsDr', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n drawingsXML\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');\r\n\r\n ws.drawingCollection.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n\r\n\r\n d.addToXMLele(drawingsXML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addLegacyHeaderFooterDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML')\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n \r\n if (!ws.legacyDrawingHeaderFooter.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsVML = xmlbuilder.begin().ele('xml');\r\n drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = drawingsVML.ele('v:shapetype')\r\n .att('id', '_x0000_t75')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '75')\r\n .att('o:preferrelative', 't')\r\n .att('path', 'm@4@5l@4@11@9@11@9@5xe')\r\n .att('filled', 'f').att('stroked', 'f');\r\n\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n var vf = st.ele('v:formulas');\r\n vf.ele('v:f').att('eqn', \"if lineDrawn pixelLineWidth 0\")\r\n vf.ele('v:f').att('eqn', \"sum @0 1 0\");\r\n vf.ele('v:f').att('eqn', \"sum 0 0 @1\");\r\n vf.ele('v:f').att('eqn', \"prod @2 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @0 0 1\");\r\n vf.ele('v:f').att('eqn', \"prod @6 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"sum @8 21600 0\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @10 21600 0\");\r\n\r\n st.ele('v:path')\r\n .att('o:extrusionok','f')\r\n .att('gradientshapeok','t')\r\n .att('o:connecttype','rect')\r\n\r\n st.ele('o:lock').att('v:ext','edit').att('aspectratio','t');\r\n\r\n // const sh = drawingsVML.ele('v:shape');\r\n // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75')\r\n // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`);\r\n // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1')\r\n // sh.ele('o:lock').att('v:ext','edit').att('rotation','t');\r\n\r\n // const textB = sh.ele('v:textbox').text('VML TextBox')\r\n\r\n ws.legacyDrawingHeaderFooter.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n d.addToXMLele(drawingsVML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n console.log('Genenrating VML Drawing File for ', ws.sheetId);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\n\r\n/**\r\n * Use JSZip to generate file to a node buffer\r\n * @private\r\n * @memberof Workbook\r\n * @param {Workbook} wb Workbook instance\r\n * @return {Promise} resolves with Buffer\r\n */\r\nlet writeToBuffer = (wb) => {\r\n return new Promise((resolve, reject) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n if (promiseObj.wb.sheets.length === 0) {\r\n promiseObj.wb.Worksheet();\r\n }\r\n\r\n addRootContentTypesXML(promiseObj)\r\n .then(addWorksheetsXML)\r\n .then(addRootRelsXML)\r\n .then(addWorkbookXML)\r\n .then(addWorkbookRelsXML)\r\n .then(addCorePropertiesXML)\r\n .then(addSharedStringsXML)\r\n .then(addStylesXML)\r\n .then(addDrawingsXML)\r\n .then(addLegacyHeaderFooterDrawingsXML)\r\n .then(() => {\r\n wb.opts.jszip.type = 'nodebuffer';\r\n promiseObj.xlsx.generateAsync(wb.opts.jszip)\r\n .then((buf) => {\r\n resolve(buf);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n\r\n });\r\n};\r\n\r\n/**\r\n * @desc Currently only used for testing the XML generated for a Workbook.\r\n * @param {*} wb Workbook instance\r\n * @return {Promise} resolves with Workbook XML\r\n */\r\nlet workbookXML = (wb) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n return addWorkbookXML(promiseObj).then((result) => {\r\n return result.xlsx.files['xl/workbook.xml']._data;\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n writeToBuffer,\r\n workbookXML\r\n};"]} \ No newline at end of file diff --git a/distribution/lib/workbook/dxfCollection.js b/distribution/lib/workbook/dxfCollection.js new file mode 100644 index 00000000..85d3e891 --- /dev/null +++ b/distribution/lib/workbook/dxfCollection.js @@ -0,0 +1,85 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _isEqual = require('lodash.isequal'); +var Style = require('../style'); +var util = require('util'); + +var DXFItem = function () { + // §18.8.14 dxf (Formatting) + function DXFItem(style, wb) { + _classCallCheck(this, DXFItem); + + this.wb = wb; + this.style = style; + this.id; + } + + _createClass(DXFItem, [{ + key: 'addToXMLele', + value: function addToXMLele(ele) { + this.style.addDXFtoXMLele(ele); + } + }, { + key: 'dxfId', + get: function get() { + return this.id; + } + }]); + + return DXFItem; +}(); + +var DXFCollection = function () { + // §18.8.15 dxfs (Formats) + function DXFCollection(wb) { + _classCallCheck(this, DXFCollection); + + this.wb = wb; + this.items = []; + } + + _createClass(DXFCollection, [{ + key: 'add', + value: function add(style) { + if (!(style instanceof Style)) { + style = this.wb.Style(style); + } + + var thisItem = void 0; + this.items.forEach(function (item) { + if (_isEqual(item.style.toObject(), style.toObject())) { + return thisItem = item; + } + }); + if (!thisItem) { + thisItem = new DXFItem(style, this.wb); + this.items.push(thisItem); + thisItem.id = this.items.length - 1; + } + return thisItem; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var dxfXML = ele.ele('dxfs').att('count', this.length); + + this.items.forEach(function (item) { + item.addToXMLele(dxfXML); + }); + } + }, { + key: 'length', + get: function get() { + return this.items.length; + } + }]); + + return DXFCollection; +}(); + +module.exports = DXFCollection; +//# sourceMappingURL=dxfCollection.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/dxfCollection.js.map b/distribution/lib/workbook/dxfCollection.js.map new file mode 100644 index 00000000..dea0015c --- /dev/null +++ b/distribution/lib/workbook/dxfCollection.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/dxfCollection.js"],"names":["_isEqual","require","Style","util","DXFItem","style","wb","id","ele","addDXFtoXMLele","DXFCollection","items","thisItem","forEach","item","toObject","push","length","dxfXML","att","addToXMLele","module","exports"],"mappings":";;;;;;AAAA,IAAMA,WAAWC,QAAQ,gBAAR,CAAjB;AACA,IAAMC,QAAQD,QAAQ,UAAR,CAAd;AACA,IAAME,OAAOF,QAAQ,MAAR,CAAb;;IAEMG,O;AAAU;AACZ,qBAAYC,KAAZ,EAAmBC,EAAnB,EAAuB;AAAA;;AACnB,aAAKA,EAAL,GAAUA,EAAV;AACA,aAAKD,KAAL,GAAaA,KAAb;AACA,aAAKE,EAAL;AACH;;;;oCAKWC,G,EAAK;AACb,iBAAKH,KAAL,CAAWI,cAAX,CAA0BD,GAA1B;AACH;;;4BANW;AACR,mBAAO,KAAKD,EAAZ;AACH;;;;;;IAOCG,a;AAAgB;AAClB,2BAAYJ,EAAZ,EAAgB;AAAA;;AACZ,aAAKA,EAAL,GAAUA,EAAV;AACA,aAAKK,KAAL,GAAa,EAAb;AACH;;;;4BAEGN,K,EAAO;AACP,gBAAI,EAAEA,iBAAiBH,KAAnB,CAAJ,EAA+B;AAC3BG,wBAAQ,KAAKC,EAAL,CAAQJ,KAAR,CAAcG,KAAd,CAAR;AACH;;AAED,gBAAIO,iBAAJ;AACA,iBAAKD,KAAL,CAAWE,OAAX,CAAmB,UAACC,IAAD,EAAU;AACzB,oBAAId,SAASc,KAAKT,KAAL,CAAWU,QAAX,EAAT,EAAgCV,MAAMU,QAAN,EAAhC,CAAJ,EAAuD;AACnD,2BAAOH,WAAWE,IAAlB;AACH;AACJ,aAJD;AAKA,gBAAI,CAACF,QAAL,EAAe;AACXA,2BAAW,IAAIR,OAAJ,CAAYC,KAAZ,EAAmB,KAAKC,EAAxB,CAAX;AACA,qBAAKK,KAAL,CAAWK,IAAX,CAAgBJ,QAAhB;AACAA,yBAASL,EAAT,GAAc,KAAKI,KAAL,CAAWM,MAAX,GAAoB,CAAlC;AACH;AACD,mBAAOL,QAAP;AACH;;;oCAMWJ,G,EAAK;AACb,gBAAIU,SAASV,IACRA,GADQ,CACJ,MADI,EAERW,GAFQ,CAEJ,OAFI,EAEK,KAAKF,MAFV,CAAb;;AAIA,iBAAKN,KAAL,CAAWE,OAAX,CAAmB,UAACC,IAAD,EAAU;AACzBA,qBAAKM,WAAL,CAAiBF,MAAjB;AACH,aAFD;AAGH;;;4BAZY;AACT,mBAAO,KAAKP,KAAL,CAAWM,MAAlB;AACH;;;;;;AAaLI,OAAOC,OAAP,GAAiBZ,aAAjB","file":"dxfCollection.js","sourcesContent":["const _isEqual = require('lodash.isequal');\r\nconst Style = require('../style');\r\nconst util = require('util');\r\n\r\nclass DXFItem { // §18.8.14 dxf (Formatting)\r\n constructor(style, wb) {\r\n this.wb = wb;\r\n this.style = style;\r\n this.id;\r\n }\r\n get dxfId() {\r\n return this.id;\r\n }\r\n\r\n addToXMLele(ele) {\r\n this.style.addDXFtoXMLele(ele);\r\n }\r\n}\r\n\r\nclass DXFCollection { // §18.8.15 dxfs (Formats)\r\n constructor(wb) {\r\n this.wb = wb;\r\n this.items = [];\r\n }\r\n\r\n add(style) {\r\n if (!(style instanceof Style)) {\r\n style = this.wb.Style(style);\r\n }\r\n\r\n let thisItem;\r\n this.items.forEach((item) => {\r\n if (_isEqual(item.style.toObject(), style.toObject())) {\r\n return thisItem = item;\r\n }\r\n });\r\n if (!thisItem) {\r\n thisItem = new DXFItem(style, this.wb);\r\n this.items.push(thisItem);\r\n thisItem.id = this.items.length - 1;\r\n }\r\n return thisItem;\r\n }\r\n\r\n get length() {\r\n return this.items.length;\r\n }\r\n\r\n addToXMLele(ele) {\r\n let dxfXML = ele\r\n .ele('dxfs')\r\n .att('count', this.length);\r\n\r\n this.items.forEach((item) => {\r\n item.addToXMLele(dxfXML);\r\n });\r\n }\r\n}\r\n\r\nmodule.exports = DXFCollection;"]} \ No newline at end of file diff --git a/distribution/lib/workbook/index.js b/distribution/lib/workbook/index.js new file mode 100644 index 00000000..e2af29e8 --- /dev/null +++ b/distribution/lib/workbook/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./workbook.js'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/index.js.map b/distribution/lib/workbook/index.js.map new file mode 100644 index 00000000..29e44a32 --- /dev/null +++ b/distribution/lib/workbook/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/index.js"],"names":["module","exports","require"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiBC,QAAQ,eAAR,CAAjB","file":"index.js","sourcesContent":["module.exports = require('./workbook.js');"]} \ No newline at end of file diff --git a/distribution/lib/workbook/mediaCollection.js b/distribution/lib/workbook/mediaCollection.js new file mode 100644 index 00000000..3e467d90 --- /dev/null +++ b/distribution/lib/workbook/mediaCollection.js @@ -0,0 +1,41 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var fs = require('fs'); + +var MediaCollection = function () { + function MediaCollection() { + _classCallCheck(this, MediaCollection); + + this.items = []; + } + + _createClass(MediaCollection, [{ + key: 'add', + value: function add(item) { + if (typeof item === 'string') { + fs.accessSync(item, fs.R_OK); + } + + this.items.push(item); + return this.items.length; + } + }, { + key: 'isEmpty', + get: function get() { + if (this.items.length === 0) { + return true; + } else { + return false; + } + } + }]); + + return MediaCollection; +}(); + +module.exports = MediaCollection; +//# sourceMappingURL=mediaCollection.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/mediaCollection.js.map b/distribution/lib/workbook/mediaCollection.js.map new file mode 100644 index 00000000..7940e614 --- /dev/null +++ b/distribution/lib/workbook/mediaCollection.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/mediaCollection.js"],"names":["fs","require","MediaCollection","items","item","accessSync","R_OK","push","length","module","exports"],"mappings":";;;;;;AAAA,IAAMA,KAAKC,QAAQ,IAAR,CAAX;;IAEMC,e;AACF,+BAAc;AAAA;;AACV,aAAKC,KAAL,GAAa,EAAb;AACH;;;;4BAEGC,I,EAAM;AACN,gBAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC1BJ,mBAAGK,UAAH,CAAcD,IAAd,EAAoBJ,GAAGM,IAAvB;AACH;;AAED,iBAAKH,KAAL,CAAWI,IAAX,CAAgBH,IAAhB;AACA,mBAAO,KAAKD,KAAL,CAAWK,MAAlB;AACH;;;4BAEa;AACV,gBAAI,KAAKL,KAAL,CAAWK,MAAX,KAAsB,CAA1B,EAA6B;AACzB,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAGLC,OAAOC,OAAP,GAAiBR,eAAjB","file":"mediaCollection.js","sourcesContent":["const fs = require('fs');\r\n\r\nclass MediaCollection {\r\n constructor() {\r\n this.items = [];\r\n }\r\n\r\n add(item) {\r\n if (typeof item === 'string') {\r\n fs.accessSync(item, fs.R_OK);\r\n }\r\n\r\n this.items.push(item);\r\n return this.items.length;\r\n }\r\n\r\n get isEmpty() {\r\n if (this.items.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = MediaCollection;"]} \ No newline at end of file diff --git a/distribution/lib/workbook/workbook.js b/distribution/lib/workbook/workbook.js new file mode 100644 index 00000000..6ae06da6 --- /dev/null +++ b/distribution/lib/workbook/workbook.js @@ -0,0 +1,317 @@ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _isUndefined = require('lodash.isundefined'); +var deepmerge = require('deepmerge'); +var fs = require('fs'); +var utils = require('../utils.js'); +var Worksheet = require('../worksheet'); +var Style = require('../style'); +var Border = require('../style/classes/border.js'); +var Fill = require('../style/classes/fill.js'); +var Font = require('../style/classes/font'); +var DXFCollection = require('./dxfCollection.js'); +var MediaCollection = require('./mediaCollection.js'); +var DefinedNameCollection = require('../classes/definedNameCollection.js'); +var types = require('../types/index.js'); +var builder = require('./builder.js'); +var http = require('http'); +var SimpleLogger = require('../logger'); + +/* Available options for Workbook +{ + jszip : { + compression : 'DEFLATE' + }, + defaultFont : { + size : 12, + family : 'Calibri', + color : 'FFFFFFFF' + } +} +*/ +// Default Options for Workbook +var workbookDefaultOpts = { + jszip: { + compression: 'DEFLATE' + }, + defaultFont: { + 'color': 'FF000000', + 'name': 'Calibri', + 'size': 12, + 'family': 'roman' + }, + dateFormat: 'm/d/yy' +}; + +var Workbook = function () { + + /** + * @class Workbook + * @param {Object} opts Workbook settings + * @param {Object} opts.jszip + * @param {String} opts.jszip.compression JSZip compression type. defaults to 'DEFLATE' + * @param {Object} opts.defaultFont + * @param {String} opts.defaultFont.color HEX value of default font color. defaults to #000000 + * @param {String} opts.defaultFont.name Font name. defaults to Calibri + * @param {Number} opts.defaultFont.size Font size. defaults to 12 + * @param {String} opts.defaultFont.family Font family. defaults to roman + * @param {String} opts.dataFormat Specifies the format for dates in the Workbook. defaults to 'm/d/yy' + * @param {Number} opts.workbookView.activeTab Specifies an unsignedInt that contains the index to the active sheet in this book view. + * @param {Boolean} opts.workbookView.autoFilterDateGrouping Specifies a boolean value that indicates whether to group dates when presenting the user with filtering options in the user interface. + * @param {Number} opts.workbookView.firstSheet Specifies the index to the first sheet in this book view. + * @param {Boolean} opts.workbookView.minimized Specifies a boolean value that indicates whether the workbook window is minimized. + * @param {Boolean} opts.workbookView.showHorizontalScroll Specifies a boolean value that indicates whether to display the horizontal scroll bar in the user interface. + * @param {Boolean} opts.workbookView.showSheetTabs Specifies a boolean value that indicates whether to display the sheet tabs in the user interface. + * @param {Boolean} opts.workbookView.showVerticalScroll Specifies a boolean value that indicates whether to display the vertical scroll bar. + * @param {Number} opts.workbookView.tabRatio Specifies ratio between the workbook tabs bar and the horizontal scroll bar. + * @param {String} opts.workbookView.visibility Specifies visible state of the workbook window. ('hidden', 'veryHidden', 'visible') (§18.18.89) + * @param {Number} opts.workbookView.windowHeight Specifies the height of the workbook window. The unit of measurement for this value is twips. + * @param {Number} opts.workbookView.windowWidth Specifies the width of the workbook window. The unit of measurement for this value is twips.. + * @param {Number} opts.workbookView.xWindow Specifies the X coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips. + * @param {Number} opts.workbookView.yWindow Specifies the Y coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips. + * @param {Boolean} opts.workbookView + * @param {Object} opts.logger Logger that supports warn and error method, defaults to console + * @param {String} opts.author Name displayed as document's author + * @returns {Workbook} + */ + function Workbook() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, Workbook); + + var hasCustomLogger = opts.logger !== undefined; + var hasValidCustomLogger = hasCustomLogger && typeof opts.logger.warn === 'function' && typeof opts.logger.error === 'function'; + + this.logger = hasValidCustomLogger ? opts.logger : new SimpleLogger({ + logLevel: Number.isNaN(parseInt(opts.logLevel)) ? 0 : parseInt(opts.logLevel) + }); + if (hasCustomLogger && !hasValidCustomLogger) { + this.logger.log('opts.logger is not a valid logger'); + } + + this.opts = deepmerge(workbookDefaultOpts, opts); + this.author = this.opts.author || 'Microsoft Office User'; + + this.sheets = []; + this.sharedStrings = []; + this.sharedStringLookup = new Map(); + this.styles = []; + this.stylesLookup = new Map(); + this.dxfCollection = new DXFCollection(this); + this.mediaCollection = new MediaCollection(); + this.definedNameCollection = new DefinedNameCollection(); + this.styleData = { + 'numFmts': [], + 'fonts': [], + 'fills': [new Fill({ + type: 'pattern', + patternType: 'none' + }), new Fill({ + type: 'pattern', + patternType: 'gray125' + })], + 'borders': [new Border()], + 'cellXfs': [{ + 'borderId': null, + 'fillId': null, + 'fontId': 0, + 'numFmtId': null + }] + }; + + // Lookups for style components to quickly find existing entries + // - Lookup keys are stringified JSON of a style's toObject result + // - Lookup values are the indexes for the actual entry in the styleData arrays + this.styleDataLookup = { + 'fonts': {}, + 'fills': this.styleData.fills.reduce(function (ret, fill, index) { + ret[JSON.stringify(fill.toObject())] = index; + return ret; + }, {}), + 'borders': this.styleData.borders.reduce(function (ret, border, index) { + ret[JSON.stringify(border.toObject())] = index; + return ret; + }, {}) + }; + + // Set Default Font and Style + this.createStyle({ + font: this.opts.defaultFont + }); + } + + /** + * setSelectedTab + * @param {Number} tab number of sheet that should be displayed when workbook opens. tabs are indexed starting with 1 + **/ + + + _createClass(Workbook, [{ + key: 'setSelectedTab', + value: function setSelectedTab(id) { + this.sheets.forEach(function (s) { + if (s.sheetId === id) { + s.opts.sheetView.tabSelected = 1; + } else { + s.opts.sheetView.tabSelected = 0; + } + }); + } + + /** + * writeToBuffer + * Writes Excel data to a node Buffer. + */ + + }, { + key: 'writeToBuffer', + value: function writeToBuffer() { + return builder.writeToBuffer(this); + } + + /** + * Generate .xlsx file. + * @param {String} fileName Name of Excel workbook with .xslx extension + * @param {http.response | callback} http response object or callback function (optional). + * If http response object is given, file is written to http response. Useful for web applications. + * If callback is given, callback called with (err, fs.Stats) passed + */ + + }, { + key: 'write', + value: function write(fileName, handler) { + var _this = this; + + builder.writeToBuffer(this).then(function (buffer) { + switch (typeof handler === 'undefined' ? 'undefined' : _typeof(handler)) { + // handler passed as http response object. + + case 'object': + if (handler instanceof http.ServerResponse) { + handler.writeHead(200, { + 'Content-Length': buffer.length, + 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'Content-Disposition': 'attachment; filename="' + encodeURIComponent(fileName) + '"; filename*=utf-8\'\'' + encodeURIComponent(fileName) + ';' + }); + handler.end(buffer); + } else { + throw new TypeError('Unknown object sent to write function.'); + } + break; + + // handler passed as callback function + case 'function': + fs.writeFile(fileName, buffer, function (err) { + if (err) { + handler(err); + } else { + fs.stat(fileName, handler); + } + }); + break; + + // no handler passed, write file to FS. + default: + + fs.writeFile(fileName, buffer, function (err) { + if (err) { + throw err; + } + }); + break; + } + }).catch(function (e) { + if (handler instanceof http.ServerResponse) { + _this.logger.error(e.stack); + handler.status = 500; + handler.setHeader('Content-Type', 'text/plain'); + handler.end('500 Server Error'); + } else if (typeof handler === 'function') { + handler(e.stack); + } else { + _this.logger.error(e.stack); + } + }); + } + + /** + * Add a worksheet to the Workbook + * @param {String} name Name of the Worksheet + * @param {Object} opts Options for Worksheet. See Worksheet class definition + * @returns {Worksheet} + */ + + }, { + key: 'addWorksheet', + value: function addWorksheet(name, opts) { + var newLength = this.sheets.push(new Worksheet(this, name, opts)); + return this.sheets[newLength - 1]; + } + + /** + * Add a Style to the Workbook + * @param {Object} opts Options for the style. See Style class definition + * @returns {Style} + */ + + }, { + key: 'createStyle', + value: function createStyle(opts) { + var thisStyle = new Style(this, opts); + var lookupKey = JSON.stringify(thisStyle.toObject()); + + // Use existing style if one exists + if (this.stylesLookup.get(lookupKey)) { + return this.stylesLookup.get(lookupKey); + } + + this.stylesLookup.set(lookupKey, thisStyle); + var index = this.styles.push(thisStyle) - 1; + this.styles[index].ids.cellXfs = index; + return this.styles[index]; + } + + /** + * Gets the index of a string from the shared string array if exists and adds the string if it does not and returns the new index + * @param {String} val Text of string + * @returns {Number} index of the string in the shared strings array + */ + + }, { + key: 'getStringIndex', + value: function getStringIndex(val) { + var lookupKey = typeof val === "string" ? val : JSON.stringify(val); + var target = this.sharedStringLookup.get(lookupKey); + if (_isUndefined(target)) { + var index = this.sharedStrings.push(val) - 1; + this.sharedStringLookup.set(lookupKey, index); + return index; + } else { + return target; + } + } + + /** + * @func Workbook._generateXML + * @desc used for testing the Workbook XML generated by the builder + * @return {Promise} resolves with Workbook XML + */ + + }, { + key: '_generateXML', + value: function _generateXML() { + return builder.workbookXML(this); + } + }]); + + return Workbook; +}(); + +module.exports = Workbook; +//# sourceMappingURL=workbook.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/workbook.js.map b/distribution/lib/workbook/workbook.js.map new file mode 100644 index 00000000..34860990 --- /dev/null +++ b/distribution/lib/workbook/workbook.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/workbook.js"],"names":["_isUndefined","require","deepmerge","fs","utils","Worksheet","Style","Border","Fill","Font","DXFCollection","MediaCollection","DefinedNameCollection","types","builder","http","SimpleLogger","workbookDefaultOpts","jszip","compression","defaultFont","dateFormat","Workbook","opts","hasCustomLogger","logger","undefined","hasValidCustomLogger","warn","error","logLevel","Number","isNaN","parseInt","log","author","sheets","sharedStrings","sharedStringLookup","Map","styles","stylesLookup","dxfCollection","mediaCollection","definedNameCollection","styleData","type","patternType","styleDataLookup","fills","reduce","ret","fill","index","JSON","stringify","toObject","borders","border","createStyle","font","id","forEach","s","sheetId","sheetView","tabSelected","writeToBuffer","fileName","handler","then","buffer","ServerResponse","writeHead","length","encodeURIComponent","end","TypeError","writeFile","err","stat","catch","e","stack","status","setHeader","name","newLength","push","thisStyle","lookupKey","get","set","ids","cellXfs","val","target","workbookXML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AQmF,WAAR,CAAoB,IAApB,CAAP;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiB7E,QAAjB","file":"workbook.js","sourcesContent":["const _isUndefined = require('lodash.isundefined');\r\nconst deepmerge = require('deepmerge');\r\nconst fs = require('fs');\r\nconst utils = require('../utils.js');\r\nconst Worksheet = require('../worksheet');\r\nconst Style = require('../style');\r\nconst Border = require('../style/classes/border.js');\r\nconst Fill = require('../style/classes/fill.js');\r\nconst Font = require('../style/classes/font');\r\nconst DXFCollection = require('./dxfCollection.js');\r\nconst MediaCollection = require('./mediaCollection.js');\r\nconst DefinedNameCollection = require('../classes/definedNameCollection.js');\r\nconst types = require('../types/index.js');\r\nconst builder = require('./builder.js');\r\nconst http = require('http');\r\nconst SimpleLogger = require('../logger');\r\n\r\n/* Available options for Workbook\r\n{\r\n jszip : {\r\n compression : 'DEFLATE'\r\n },\r\n defaultFont : {\r\n size : 12,\r\n family : 'Calibri',\r\n color : 'FFFFFFFF'\r\n }\r\n}\r\n*/\r\n// Default Options for Workbook\r\nlet workbookDefaultOpts = {\r\n jszip: {\r\n compression: 'DEFLATE'\r\n },\r\n defaultFont: {\r\n 'color': 'FF000000',\r\n 'name': 'Calibri',\r\n 'size': 12,\r\n 'family': 'roman'\r\n },\r\n dateFormat: 'm/d/yy'\r\n};\r\n\r\n\r\nclass Workbook {\r\n\r\n /**\r\n * @class Workbook\r\n * @param {Object} opts Workbook settings\r\n * @param {Object} opts.jszip\r\n * @param {String} opts.jszip.compression JSZip compression type. defaults to 'DEFLATE'\r\n * @param {Object} opts.defaultFont\r\n * @param {String} opts.defaultFont.color HEX value of default font color. defaults to #000000\r\n * @param {String} opts.defaultFont.name Font name. defaults to Calibri\r\n * @param {Number} opts.defaultFont.size Font size. defaults to 12\r\n * @param {String} opts.defaultFont.family Font family. defaults to roman\r\n * @param {String} opts.dataFormat Specifies the format for dates in the Workbook. defaults to 'm/d/yy'\r\n * @param {Number} opts.workbookView.activeTab Specifies an unsignedInt that contains the index to the active sheet in this book view.\r\n * @param {Boolean} opts.workbookView.autoFilterDateGrouping Specifies a boolean value that indicates whether to group dates when presenting the user with filtering options in the user interface.\r\n * @param {Number} opts.workbookView.firstSheet Specifies the index to the first sheet in this book view.\r\n * @param {Boolean} opts.workbookView.minimized Specifies a boolean value that indicates whether the workbook window is minimized.\r\n * @param {Boolean} opts.workbookView.showHorizontalScroll Specifies a boolean value that indicates whether to display the horizontal scroll bar in the user interface.\r\n * @param {Boolean} opts.workbookView.showSheetTabs Specifies a boolean value that indicates whether to display the sheet tabs in the user interface.\r\n * @param {Boolean} opts.workbookView.showVerticalScroll Specifies a boolean value that indicates whether to display the vertical scroll bar.\r\n * @param {Number} opts.workbookView.tabRatio Specifies ratio between the workbook tabs bar and the horizontal scroll bar.\r\n * @param {String} opts.workbookView.visibility Specifies visible state of the workbook window. ('hidden', 'veryHidden', 'visible') (§18.18.89)\r\n * @param {Number} opts.workbookView.windowHeight Specifies the height of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.windowWidth Specifies the width of the workbook window. The unit of measurement for this value is twips..\r\n * @param {Number} opts.workbookView.xWindow Specifies the X coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.yWindow Specifies the Y coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Boolean} opts.workbookView\r\n * @param {Object} opts.logger Logger that supports warn and error method, defaults to console\r\n * @param {String} opts.author Name displayed as document's author\r\n * @returns {Workbook}\r\n */\r\n constructor(opts = {}) {\r\n\r\n const hasCustomLogger = opts.logger !== undefined;\r\n const hasValidCustomLogger = hasCustomLogger && typeof opts.logger.warn === 'function' && typeof opts.logger.error === 'function';\r\n\r\n this.logger = hasValidCustomLogger ? opts.logger : new SimpleLogger({\r\n logLevel: Number.isNaN(parseInt(opts.logLevel)) ? 0 : parseInt(opts.logLevel)\r\n });\r\n if (hasCustomLogger && !hasValidCustomLogger) {\r\n this.logger.log('opts.logger is not a valid logger');\r\n }\r\n\r\n this.opts = deepmerge(workbookDefaultOpts, opts);\r\n this.author = this.opts.author || 'Microsoft Office User';\r\n\r\n this.sheets = [];\r\n this.sharedStrings = [];\r\n this.sharedStringLookup = new Map();\r\n this.styles = [];\r\n this.stylesLookup = new Map();\r\n this.dxfCollection = new DXFCollection(this);\r\n this.mediaCollection = new MediaCollection();\r\n this.definedNameCollection = new DefinedNameCollection();\r\n this.styleData = {\r\n 'numFmts': [],\r\n 'fonts': [],\r\n 'fills': [new Fill({\r\n type: 'pattern',\r\n patternType: 'none'\r\n }), new Fill({\r\n type: 'pattern',\r\n patternType: 'gray125'\r\n })],\r\n 'borders': [new Border()],\r\n 'cellXfs': [{\r\n 'borderId': null,\r\n 'fillId': null,\r\n 'fontId': 0,\r\n 'numFmtId': null\r\n }]\r\n };\r\n\r\n // Lookups for style components to quickly find existing entries\r\n // - Lookup keys are stringified JSON of a style's toObject result\r\n // - Lookup values are the indexes for the actual entry in the styleData arrays\r\n this.styleDataLookup = {\r\n 'fonts': {},\r\n 'fills': this.styleData.fills.reduce((ret, fill, index) => {\r\n ret[JSON.stringify(fill.toObject())] = index;\r\n return ret;\r\n }, {}),\r\n 'borders': this.styleData.borders.reduce((ret, border, index) => {\r\n ret[JSON.stringify(border.toObject())] = index;\r\n return ret;\r\n }, {})\r\n };\r\n\r\n // Set Default Font and Style\r\n this.createStyle({\r\n font: this.opts.defaultFont\r\n });\r\n }\r\n\r\n /**\r\n * setSelectedTab\r\n * @param {Number} tab number of sheet that should be displayed when workbook opens. tabs are indexed starting with 1\r\n **/\r\n setSelectedTab(id) {\r\n this.sheets.forEach((s) => {\r\n if (s.sheetId === id) {\r\n s.opts.sheetView.tabSelected = 1;\r\n } else {\r\n s.opts.sheetView.tabSelected = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * writeToBuffer\r\n * Writes Excel data to a node Buffer.\r\n */\r\n writeToBuffer() {\r\n return builder.writeToBuffer(this);\r\n }\r\n\r\n /**\r\n * Generate .xlsx file.\r\n * @param {String} fileName Name of Excel workbook with .xslx extension\r\n * @param {http.response | callback} http response object or callback function (optional).\r\n * If http response object is given, file is written to http response. Useful for web applications.\r\n * If callback is given, callback called with (err, fs.Stats) passed\r\n */\r\n write(fileName, handler) {\r\n\r\n builder.writeToBuffer(this)\r\n .then((buffer) => {\r\n switch (typeof handler) {\r\n // handler passed as http response object.\r\n\r\n case 'object':\r\n if (handler instanceof http.ServerResponse) {\r\n handler.writeHead(200, {\r\n 'Content-Length': buffer.length,\r\n 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\r\n 'Content-Disposition': `attachment; filename=\"${encodeURIComponent(fileName)}\"; filename*=utf-8''${encodeURIComponent(fileName)};`,\r\n });\r\n handler.end(buffer);\r\n } else {\r\n throw new TypeError('Unknown object sent to write function.');\r\n }\r\n break;\r\n\r\n // handler passed as callback function\r\n case 'function':\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n handler(err);\r\n } else {\r\n fs.stat(fileName, handler);\r\n }\r\n });\r\n break;\r\n\r\n // no handler passed, write file to FS.\r\n default:\r\n\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n throw err;\r\n }\r\n });\r\n break;\r\n }\r\n })\r\n .catch((e) => {\r\n if (handler instanceof http.ServerResponse) {\r\n this.logger.error(e.stack);\r\n handler.status = 500;\r\n handler.setHeader('Content-Type', 'text/plain');\r\n handler.end('500 Server Error');\r\n } else if (typeof handler === 'function') {\r\n handler(e.stack);\r\n } else {\r\n this.logger.error(e.stack);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Add a worksheet to the Workbook\r\n * @param {String} name Name of the Worksheet\r\n * @param {Object} opts Options for Worksheet. See Worksheet class definition\r\n * @returns {Worksheet}\r\n */\r\n addWorksheet(name, opts) {\r\n let newLength = this.sheets.push(new Worksheet(this, name, opts));\r\n return this.sheets[newLength - 1];\r\n }\r\n\r\n /**\r\n * Add a Style to the Workbook\r\n * @param {Object} opts Options for the style. See Style class definition\r\n * @returns {Style}\r\n */\r\n createStyle(opts) {\r\n const thisStyle = new Style(this, opts);\r\n const lookupKey = JSON.stringify(thisStyle.toObject());\r\n\r\n // Use existing style if one exists\r\n if (this.stylesLookup.get(lookupKey)) {\r\n return this.stylesLookup.get(lookupKey);\r\n }\r\n\r\n this.stylesLookup.set(lookupKey, thisStyle);\r\n const index = this.styles.push(thisStyle) - 1;\r\n this.styles[index].ids.cellXfs = index;\r\n return this.styles[index];\r\n }\r\n\r\n /**\r\n * Gets the index of a string from the shared string array if exists and adds the string if it does not and returns the new index\r\n * @param {String} val Text of string\r\n * @returns {Number} index of the string in the shared strings array\r\n */\r\n getStringIndex(val) {\r\n const lookupKey = typeof val === \"string\" ? val : JSON.stringify(val);\r\n const target = this.sharedStringLookup.get(lookupKey);\r\n if (_isUndefined(target)) {\r\n const index = this.sharedStrings.push(val) - 1;\r\n this.sharedStringLookup.set(lookupKey, index);\r\n return index;\r\n } else {\r\n return target;\r\n }\r\n }\r\n\r\n /**\r\n * @func Workbook._generateXML\r\n * @desc used for testing the Workbook XML generated by the builder\r\n * @return {Promise} resolves with Workbook XML \r\n */\r\n _generateXML() {\r\n return builder.workbookXML(this);\r\n }\r\n}\r\n\r\nmodule.exports = Workbook;"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/builder.js b/distribution/lib/worksheet/builder.js new file mode 100644 index 00000000..578de2dc --- /dev/null +++ b/distribution/lib/worksheet/builder.js @@ -0,0 +1,622 @@ +'use strict'; + +var xml = require('xmlbuilder'); +var utils = require('../utils.js'); +var types = require('../types/index.js'); +var hyperlinks = require('./classes/hyperlink'); +var Picture = require('../drawing/picture.js'); + +var _addSheetPr = function _addSheetPr(promiseObj) { + // §18.3.1.82 sheetPr (Sheet Properties) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts; + + // Check if any option that would require the sheetPr element to be added exists + if (o.pageSetup.fitToHeight !== null || o.pageSetup.fitToWidth !== null || o.outline.summaryBelow !== null || o.outline.summaryRight !== null || o.autoFilter.ref !== null) { + var ele = promiseObj.xml.ele('sheetPr'); + + if (o.autoFilter.ref) { + ele.att('enableFormatConditionsCalculation', 1); + ele.att('filterMode', 1); + } + + if (o.outline.summaryBelow !== null || o.outline.summaryRight !== null) { + var outlineEle = ele.ele('outlinePr'); + outlineEle.att('applyStyles', 1); + outlineEle.att('summaryBelow', o.outline.summaryBelow === true ? 1 : 0); + outlineEle.att('summaryRight', o.outline.summaryRight === true ? 1 : 0); + outlineEle.up(); + } + + // §18.3.1.65 pageSetUpPr (Page Setup Properties) + if (o.pageSetup.fitToHeight !== null || o.pageSetup.fitToWidth !== null) { + ele.ele('pageSetUpPr').att('fitToPage', 1).up(); + } + ele.up(); + } + + resolve(promiseObj); + }); +}; + +var _addDimension = function _addDimension(promiseObj) { + // §18.3.1.35 dimension (Worksheet Dimensions) + return new Promise(function (resolve, reject) { + var firstCell = 'A1'; + var lastCell = '' + utils.getExcelAlpha(promiseObj.ws.lastUsedCol) + promiseObj.ws.lastUsedRow; + var ele = promiseObj.xml.ele('dimension'); + ele.att('ref', firstCell + ':' + lastCell); + ele.up(); + + resolve(promiseObj); + }); +}; + +var _addSheetViews = function _addSheetViews(promiseObj) { + // §18.3.1.88 sheetViews (Sheet Views) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts.sheetView; + var ele = promiseObj.xml.ele('sheetViews'); + var sv = ele.ele('sheetView').att('showGridLines', o.showGridLines).att('workbookViewId', o.workbookViewId).att('rightToLeft', o.rightToLeft).att('zoomScale', o.zoomScale).att('zoomScaleNormal', o.zoomScaleNormal).att('zoomScalePageLayoutView', o.zoomScalePageLayoutView); + + var modifiedPaneParams = []; + Object.keys(o.pane).forEach(function (k) { + if (o.pane[k] !== null) { + modifiedPaneParams.push(k); + } + }); + if (modifiedPaneParams.length > 0) { + var pEle = sv.ele('pane'); + o.pane.xSplit !== null ? pEle.att('xSplit', o.pane.xSplit) : null; + o.pane.ySplit !== null ? pEle.att('ySplit', o.pane.ySplit) : null; + o.pane.topLeftCell !== null ? pEle.att('topLeftCell', o.pane.topLeftCell) : null; + o.pane.activePane !== null ? pEle.att('activePane', o.pane.activePane) : null; + o.pane.state !== null ? pEle.att('state', o.pane.state) : null; + pEle.up(); + } + sv.up(); + ele.up(); + resolve(promiseObj); + }); +}; + +var _addSheetFormatPr = function _addSheetFormatPr(promiseObj) { + // §18.3.1.81 sheetFormatPr (Sheet Format Properties) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts.sheetFormat; + var ele = promiseObj.xml.ele('sheetFormatPr'); + + o.baseColWidth !== null ? ele.att('baseColWidth', o.baseColWidth) : null; + o.defaultColWidth !== null ? ele.att('defaultColWidth', o.defaultColWidth) : null; + o.defaultRowHeight !== null ? ele.att('defaultRowHeight', o.defaultRowHeight) : ele.att('defaultRowHeight', 16); + o.thickBottom !== null ? ele.att('thickBottom', utils.boolToInt(o.thickBottom)) : null; + o.thickTop !== null ? ele.att('thickTop', utils.boolToInt(o.thickTop)) : null; + + if (typeof o.defaultRowHeight === 'number') { + ele.att('customHeight', '1'); + } + ele.up(); + resolve(promiseObj); + }); +}; + +var _addCols = function _addCols(promiseObj) { + // §18.3.1.17 cols (Column Information) + return new Promise(function (resolve, reject) { + + if (promiseObj.ws.columnCount > 0) { + var colsEle = promiseObj.xml.ele('cols'); + + for (var colId in promiseObj.ws.cols) { + var col = promiseObj.ws.cols[colId]; + var colEle = colsEle.ele('col'); + + col.min !== null ? colEle.att('min', col.min) : null; + col.max !== null ? colEle.att('max', col.max) : null; + col.width !== null ? colEle.att('width', col.width) : null; + col.style !== null ? colEle.att('style', col.style) : null; + col.hidden !== null ? colEle.att('hidden', utils.boolToInt(col.hidden)) : null; + col.customWidth !== null ? colEle.att('customWidth', utils.boolToInt(col.customWidth)) : null; + col.outlineLevel !== null ? colEle.att('outlineLevel', col.outlineLevel) : null; + col.collapsed !== null ? colEle.att('collapsed', utils.boolToInt(col.collapsed)) : null; + colEle.up(); + } + colsEle.up(); + } + + resolve(promiseObj); + }); +}; + +var _addSheetData = function _addSheetData(promiseObj) { + // §18.3.1.80 sheetData (Sheet Data) + return new Promise(function (resolve, reject) { + + var ele = promiseObj.xml.ele('sheetData'); + var rows = Object.keys(promiseObj.ws.rows); + + var processRows = function processRows(theseRows) { + for (var r = 0; r < theseRows.length; r++) { + var thisRow = promiseObj.ws.rows[theseRows[r]]; + thisRow.cellRefs.sort(utils.sortCellRefs); + + var rEle = ele.ele('row'); + + rEle.att('r', thisRow.r); + if (promiseObj.ws.opts.disableRowSpansOptimization !== true && thisRow.spans) { + rEle.att('spans', thisRow.spans); + } + thisRow.s !== null ? rEle.att('s', thisRow.s) : null; + thisRow.customFormat !== null ? rEle.att('customFormat', thisRow.customFormat) : null; + thisRow.ht !== null ? rEle.att('ht', thisRow.ht) : null; + thisRow.hidden !== null ? rEle.att('hidden', thisRow.hidden) : null; + thisRow.customHeight === true || typeof promiseObj.ws.opts.sheetFormat.defaultRowHeight === 'number' ? rEle.att('customHeight', 1) : null; + thisRow.outlineLevel !== null ? rEle.att('outlineLevel', thisRow.outlineLevel) : null; + thisRow.collapsed !== null ? rEle.att('collapsed', thisRow.collapsed) : null; + thisRow.thickTop !== null ? rEle.att('thickTop', thisRow.thickTop) : null; + thisRow.thickBot !== null ? rEle.att('thickBot', thisRow.thickBot) : null; + + for (var i = 0; i < thisRow.cellRefs.length; i++) { + promiseObj.ws.cells[thisRow.cellRefs[i]].addToXMLele(rEle); + } + + rEle.up(); + } + + processNextRows(); + }; + + var processNextRows = function processNextRows() { + var theseRows = rows.splice(0, 500); + if (theseRows.length === 0) { + ele.up(); + return resolve(promiseObj); + } + processRows(theseRows); + }; + + processNextRows(); + }); +}; + +var _addSheetProtection = function _addSheetProtection(promiseObj) { + // §18.3.1.85 sheetProtection (Sheet Protection Options) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts.sheetProtection; + var includeSheetProtection = false; + Object.keys(o).forEach(function (k) { + if (o[k] !== null) { + includeSheetProtection = true; + } + }); + + if (includeSheetProtection) { + // Set required fields with defaults if not specified + o.sheet = o.sheet !== null ? o.sheet : true; + o.objects = o.objects !== null ? o.objects : true; + o.scenarios = o.scenarios !== null ? o.scenarios : true; + + var ele = promiseObj.xml.ele('sheetProtection'); + Object.keys(o).forEach(function (k) { + if (o[k] !== null) { + if (k === 'password') { + ele.att('password', utils.getHashOfPassword(o[k])); + } else { + ele.att(k, utils.boolToInt(o[k])); + } + } + }); + ele.up(); + } + resolve(promiseObj); + }); +}; + +var _addAutoFilter = function _addAutoFilter(promiseObj) { + // §18.3.1.2 autoFilter (AutoFilter Settings) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts.autoFilter; + + if (typeof o.startRow === 'number') { + var ele = promiseObj.xml.ele('autoFilter'); + var filterRow = promiseObj.ws.rows[o.startRow]; + + o.startCol = typeof o.startCol === 'number' ? o.startCol : null; + o.endCol = typeof o.endCol === 'number' ? o.endCol : null; + + if (typeof o.endRow !== 'number') { + var firstEmptyRow = undefined; + var curRow = o.startRow; + while (firstEmptyRow === undefined) { + if (!promiseObj.ws.rows[curRow]) { + firstEmptyRow = curRow; + } else { + curRow++; + } + } + + o.endRow = firstEmptyRow - 1; + } + + // Columns to sort not manually set. filter all columns in this row containing data. + if (typeof o.startCol !== 'number' || typeof o.endCol !== 'number') { + o.startCol = filterRow.firstColumn; + o.endCol = filterRow.lastColumn; + } + + var startCell = utils.getExcelAlpha(o.startCol) + o.startRow; + var endCell = utils.getExcelAlpha(o.endCol) + o.endRow; + + ele.att('ref', startCell + ':' + endCell); + promiseObj.ws.wb.definedNameCollection.addDefinedName({ + hidden: 1, + localSheetId: promiseObj.ws.localSheetId, + name: '_xlnm._FilterDatabase', + refFormula: '\'' + promiseObj.ws.name + '\'!' + '$' + utils.getExcelAlpha(o.startCol) + '$' + o.startRow + ':' + '$' + utils.getExcelAlpha(o.endCol) + '$' + o.endRow + }); + ele.up(); + } + resolve(promiseObj); + }); +}; + +var _addMergeCells = function _addMergeCells(promiseObj) { + // §18.3.1.55 mergeCells (Merge Cells) + return new Promise(function (resolve, reject) { + + if (promiseObj.ws.mergedCells instanceof Array && promiseObj.ws.mergedCells.length > 0) { + var ele = promiseObj.xml.ele('mergeCells').att('count', promiseObj.ws.mergedCells.length); + promiseObj.ws.mergedCells.forEach(function (cr) { + ele.ele('mergeCell').att('ref', cr).up(); + }); + ele.up(); + } + + resolve(promiseObj); + }); +}; + +var _addConditionalFormatting = function _addConditionalFormatting(promiseObj) { + // §18.3.1.18 conditionalFormatting (Conditional Formatting) + return new Promise(function (resolve, reject) { + promiseObj.ws.cfRulesCollection.addToXMLele(promiseObj.xml); + resolve(promiseObj); + }); +}; + +var _addHyperlinks = function _addHyperlinks(promiseObj) { + // §18.3.1.48 hyperlinks (Hyperlinks) + return new Promise(function (resolve, reject) { + promiseObj.ws.hyperlinkCollection.addToXMLele(promiseObj.xml); + resolve(promiseObj); + }); +}; + +var _addDataValidations = function _addDataValidations(promiseObj) { + // §18.3.1.33 dataValidations (Data Validations) + return new Promise(function (resolve, reject) { + if (promiseObj.ws.dataValidationCollection.length > 0) { + promiseObj.ws.dataValidationCollection.addToXMLele(promiseObj.xml); + } + resolve(promiseObj); + }); +}; + +var _addPrintOptions = function _addPrintOptions(promiseObj) { + // §18.3.1.70 printOptions (Print Options) + return new Promise(function (resolve, reject) { + + var addPrintOptions = false; + var o = promiseObj.ws.opts.printOptions; + Object.keys(o).forEach(function (k) { + if (o[k] !== null) { + addPrintOptions = true; + } + }); + + if (addPrintOptions) { + var poEle = promiseObj.xml.ele('printOptions'); + o.centerHorizontal === true ? poEle.att('horizontalCentered', 1) : null; + o.centerVertical === true ? poEle.att('verticalCentered', 1) : null; + o.printHeadings === true ? poEle.att('headings', 1) : null; + if (o.printGridLines === true) { + poEle.att('gridLines', 1); + poEle.att('gridLinesSet', 1); + } + poEle.up(); + } + + resolve(promiseObj); + }); +}; + +var _addPageMargins = function _addPageMargins(promiseObj) { + // §18.3.1.62 pageMargins (Page Margins) + return new Promise(function (resolve, reject) { + var o = promiseObj.ws.opts.margins; + + promiseObj.xml.ele('pageMargins').att('left', o.left).att('right', o.right).att('top', o.top).att('bottom', o.bottom).att('header', o.header).att('footer', o.footer).up(); + + resolve(promiseObj); + }); +}; + +var _addLegacyDrawing = function _addLegacyDrawing(promiseObj) { + return new Promise(function (resolve, reject) { + + var rId = promiseObj.ws.relationships.indexOf('commentsVml') + 1; + if (rId === 0) { + resolve(promiseObj); + } else { + promiseObj.xml.ele('legacyDrawing').att('r:id', 'rId' + rId).up(); + + resolve(promiseObj); + } + }); +}; + +var _addPageSetup = function _addPageSetup(promiseObj) { + // §18.3.1.63 pageSetup (Page Setup Settings) + return new Promise(function (resolve, reject) { + + var addPageSetup = false; + var o = promiseObj.ws.opts.pageSetup; + Object.keys(o).forEach(function (k) { + if (o[k] !== null) { + addPageSetup = true; + } + }); + + if (addPageSetup === true) { + var psEle = promiseObj.xml.ele('pageSetup'); + o.paperSize !== null ? psEle.att('paperSize', types.paperSize[o.paperSize]) : null; + o.paperHeight !== null ? psEle.att('paperHeight', o.paperHeight) : null; + o.paperWidth !== null ? psEle.att('paperWidth', o.paperWidth) : null; + o.scale !== null ? psEle.att('scale', o.scale) : null; + o.firstPageNumber !== null ? psEle.att('firstPageNumber', o.firstPageNumber) : null; + o.fitToWidth !== null ? psEle.att('fitToWidth', o.fitToWidth) : null; + o.fitToHeight !== null ? psEle.att('fitToHeight', o.fitToHeight) : null; + o.pageOrder !== null ? psEle.att('pageOrder', o.pageOrder) : null; + o.orientation !== null ? psEle.att('orientation', o.orientation) : null; + o.usePrinterDefaults !== null ? psEle.att('usePrinterDefaults', utils.boolToInt(o.usePrinterDefaults)) : null; + o.blackAndWhite !== null ? psEle.att('blackAndWhite', utils.boolToInt(o.blackAndWhite)) : null; + o.draft !== null ? psEle.att('draft', utils.boolToInt(o.draft)) : null; + o.cellComments !== null ? psEle.att('cellComments', o.cellComments) : null; + o.useFirstPageNumber !== null ? psEle.att('useFirstPageNumber', utils.boolToInt(o.useFirstPageNumber)) : null; + o.errors !== null ? psEle.att('errors', o.errors) : null; + o.horizontalDpi !== null ? psEle.att('horizontalDpi', o.horizontalDpi) : null; + o.verticalDpi !== null ? psEle.att('verticalDpi', o.verticalDpi) : null; + o.copies !== null ? psEle.att('copies', o.copies) : null; + psEle.up(); + } + + resolve(promiseObj); + }); +}; + +var _addPageBreaks = function _addPageBreaks(promiseObj) { + // colBreaks (§18.3.1.14); rowBreaks (§18.3.1.74) + var rowBreaks = promiseObj.ws.pageBreaks.row; + if (rowBreaks.length > 0) { + var rbEle = promiseObj.xml.ele('rowBreaks'); + rbEle.att('count', rowBreaks.length); + rbEle.att('manualBreakCount', rowBreaks.length); + rowBreaks.forEach(function (pos) { + var bEle = rbEle.ele('brk'); + bEle.att('id', pos); + bEle.att('man', 1); + bEle.up(); + }); + rbEle.up(); + } + var colBreaks = promiseObj.ws.pageBreaks.column; + if (colBreaks.length > 0) { + var cbEle = promiseObj.xml.ele('colBreaks'); + cbEle.att('count', colBreaks.length); + cbEle.att('manualBreakCount', colBreaks.length); + colBreaks.forEach(function (pos) { + var bEle = cbEle.ele('brk'); + bEle.att('id', pos); + bEle.att('man', 1); + bEle.up(); + }); + cbEle.up(); + } + return promiseObj; +}; + +var _addHeaderFooter = function _addHeaderFooter(promiseObj) { + // §18.3.1.46 headerFooter (Header Footer Settings) + return new Promise(function (resolve, reject) { + + var addHeaderFooter = false; + var o = promiseObj.ws.opts.headerFooter; + Object.keys(o).forEach(function (k) { + if (o[k] !== null) { + addHeaderFooter = true; + } + }); + + if (addHeaderFooter === true) { + var hfEle = promiseObj.xml.ele('headerFooter'); + + o.alignWithMargins !== null ? hfEle.att('alignWithMargins', utils.boolToInt(o.alignWithMargins)) : null; + o.differentFirst !== null ? hfEle.att('differentFirst', utils.boolToInt(o.differentFirst)) : null; + o.differentOddEven !== null ? hfEle.att('differentOddEven', utils.boolToInt(o.differentOddEven)) : null; + o.scaleWithDoc !== null ? hfEle.att('scaleWithDoc', utils.boolToInt(o.scaleWithDoc)) : null; + + o.oddHeader !== null ? hfEle.ele('oddHeader').text(o.oddHeader).up() : null; + o.oddFooter !== null ? hfEle.ele('oddFooter').text(o.oddFooter).up() : null; + o.evenHeader !== null ? hfEle.ele('evenHeader').text(o.evenHeader).up() : null; + o.evenFooter !== null ? hfEle.ele('evenFooter').text(o.evenFooter).up() : null; + o.firstHeader !== null ? hfEle.ele('firstHeader').text(o.firstHeader).up() : null; + o.firstFooter !== null ? hfEle.ele('firstFooter').text(o.firstFooter).up() : null; + hfEle.up(); + } + + resolve(promiseObj); + }); +}; + +var _addlegacyDrawingHeaderFooter = function _addlegacyDrawingHeaderFooter(promiseObj) { + return new Promise(function (resolve, reject) { + if (!promiseObj.ws.legacyDrawingHeaderFooter.isEmpty) { + var dId = promiseObj.ws.relationships.indexOf('legacyDrawingHeaderFooter') + 1; + promiseObj.xml.ele('legacyDrawingHF').att('r:id', 'rId' + dId).up(); + } + resolve(promiseObj); + }); +}; + +var _addDrawing = function _addDrawing(promiseObj) { + // §18.3.1.36 drawing (Drawing) + return new Promise(function (resolve, reject) { + if (!promiseObj.ws.drawingCollection.isEmpty) { + var dId = promiseObj.ws.relationships.indexOf('drawing') + 1; + promiseObj.xml.ele('drawing').att('r:id', 'rId' + dId).up(); + } + resolve(promiseObj); + }); +}; + +var sheetXML = function sheetXML(ws) { + return new Promise(function (resolve, reject) { + + var xmlProlog = ''; + var xmlString = ''; + var wsXML = xml.begin({ + 'allowSurrogateChars': true + }, function (chunk) { + xmlString += chunk; + }).ele('worksheet').att('mc:Ignorable', 'x14ac').att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main').att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006').att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships').att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac'); + + // Excel complains if specific elements on not in the correct order in the XML doc as defined in §M.2.2 + var promiseObj = { xml: wsXML, ws: ws }; + + _addSheetPr(promiseObj).then(_addDimension).then(_addSheetViews).then(_addSheetFormatPr).then(_addCols).then(_addSheetData).then(_addSheetProtection).then(_addAutoFilter).then(_addMergeCells).then(_addConditionalFormatting).then(_addDataValidations).then(_addHyperlinks).then(_addPrintOptions).then(_addPageMargins).then(_addLegacyDrawing).then(_addPageSetup).then(_addPageBreaks).then(_addHeaderFooter).then(_addlegacyDrawingHeaderFooter).then(_addDrawing).then(function (promiseObj) { + return new Promise(function (resolve, reject) { + wsXML.end(); + resolve(xmlString); + }); + }).then(function (xml) { + resolve(xml); + }).catch(function (e) { + throw new Error(e.stack); + }); + }); +}; + +var relsXML = function relsXML(ws) { + return new Promise(function (resolve, reject) { + var sheetRelRequired = false; + if (ws.relationships.length > 0) { + sheetRelRequired = true; + } + + if (sheetRelRequired === false) { + resolve(); + } + + var relXML = xml.create('Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }); + relXML.att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + + ws.relationships.forEach(function (r, i) { + var rId = 'rId' + (i + 1); + if (r instanceof hyperlinks.Hyperlink) { + relXML.ele('Relationship').att('Id', rId).att('Target', r.location).att('TargetMode', 'External').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink'); + } else if (r === 'drawing') { + relXML.ele('Relationship').att('Id', rId).att('Target', '../drawings/drawing' + ws.sheetId + '.xml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing'); + } else if (r === 'comments') { + relXML.ele('Relationship').att('Id', rId).att('Target', '../comments' + ws.sheetId + '.xml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments'); + } else if (r === 'commentsVml') { + relXML.ele('Relationship').att('Id', rId).att('Target', '../drawings/commentsVml' + ws.sheetId + '.vml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'); + } else if (r === 'legacyDrawingHeaderFooter') { + relXML.ele('Relationship').att('Id', rId).att('Target', '../drawings/vmlDrawing' + ws.sheetId + '.vml').att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'); + } + }); + var xmlString = relXML.doc().end(); + resolve(xmlString); + }); +}; + +var commentsXML = function commentsXML(ws) { + return new Promise(function (resolve, reject) { + var commentsXml = xml.create('comments', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }); + commentsXml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); + + commentsXml.ele('authors').ele('author').text(ws.wb.author); + + var commentList = commentsXml.ele('commentList'); + Object.keys(ws.comments).forEach(function (ref) { + commentList.ele('comment').att('ref', ref).att('authorId', '0').att('guid', ws.comments[ref].uuid).ele('text').ele('t').text(ws.comments[ref].comment); + }); + var xmlString = commentsXml.doc().end(); + resolve(xmlString); + }); +}; + +var commentsVmlXML = function commentsVmlXML(ws) { + return new Promise(function (resolve, reject) { + // do not add XML prolog to document + var vmlXml = xml.begin().ele('xml'); + vmlXml.att('xmlns:v', 'urn:schemas-microsoft-com:vml'); + vmlXml.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + vmlXml.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); + + var sl = vmlXml.ele('o:shapelayout').att('v:ext', 'edit'); + sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); + + var st = vmlXml.ele('v:shapetype').att('id', '_x0000_t202').att('coordsize', '21600,21600').att('o:spt', '202').att('path', 'm,l,21600r21600,l21600,xe'); + st.ele('v:stroke').att('joinstyle', 'miter'); + st.ele('v:path').att('gradientshapeok', 't').att('o:connecttype', 'rect'); + + Object.keys(ws.comments).forEach(function (ref) { + var _ws$comments$ref = ws.comments[ref], + row = _ws$comments$ref.row, + col = _ws$comments$ref.col, + position = _ws$comments$ref.position, + marginLeft = _ws$comments$ref.marginLeft, + marginTop = _ws$comments$ref.marginTop, + width = _ws$comments$ref.width, + height = _ws$comments$ref.height, + zIndex = _ws$comments$ref.zIndex, + visibility = _ws$comments$ref.visibility, + fillColor = _ws$comments$ref.fillColor; + + var shape = vmlXml.ele('v:shape'); + shape.att('id', '_' + ws.sheetId + '_' + row + '_' + col); + shape.att('type', "#_x0000_t202"); + shape.att('style', 'position:' + position + ';margin-left:' + marginLeft + ';margin-top:' + marginTop + ';width:' + width + ';height:' + height + ';z-index:' + zIndex + ';visibility:' + visibility); + shape.att('fillcolor', fillColor); + shape.att('o:insetmode', 'auto'); + + shape.ele('v:path').att('o:connecttype', 'none'); + + var tb = shape.ele('v:textbox').att('style', 'mso-direction-alt:auto'); + tb.ele('div').att('style', 'text-align:left'); + + var cd = shape.ele('x:ClientData').att('ObjectType', 'Note'); + cd.ele('x:MoveWithCells'); + cd.ele('x:SizeWithCells'); + cd.ele('x:AutoFill').text('False'); + cd.ele('x:Row').text(row - 1); + cd.ele('x:Column').text(col - 1); + }); + + var xmlString = vmlXml.doc().end(); + resolve(xmlString); + }); +}; + +module.exports = { sheetXML: sheetXML, relsXML: relsXML, commentsXML: commentsXML, commentsVmlXML: commentsVmlXML }; +//# sourceMappingURL=builder.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/builder.js.map b/distribution/lib/worksheet/builder.js.map new file mode 100644 index 00000000..2d51aec5 --- /dev/null +++ b/distribution/lib/worksheet/builder.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/worksheet/builder.js"],"names":["xml","require","utils","types","hyperlinks","Picture","_addSheetPr","promiseObj","Promise","resolve","reject","o","ws","opts","pageSetup","fitToHeight","fitToWidth","outline","summaryBelow","summaryRight","autoFilter","ref","ele","att","outlineEle","up","_addDimension","firstCell","lastCell","getExcelAlpha","lastUsedCol","lastUsedRow","_addSheetViews","sheetView","sv","showGridLines","workbookViewId","rightToLeft","zoomScale","zoomScaleNormal","zoomScalePageLayoutView","modifiedPaneParams","Object","keys","pane","forEach","k","push","length","pEle","xSplit","ySplit","topLeftCell","activePane","state","_addSheetFormatPr","sheetFormat","baseColWidth","defaultColWidth","defaultRowHeight","thickBottom","boolToInt","thickTop","_addCols","columnCount","colsEle","colId","cols","col","colEle","min","max","width","style","hidden","customWidth","outlineLevel","collapsed","_addSheetData","rows","processRows","theseRows","r","thisRow","cellRefs","sort","sortCellRefs","rEle","disableRowSpansOptimization","spans","s","customFormat","ht","customHeight","thickBot","i","cells","addToXMLele","processNextRows","splice","_addSheetProtection","sheetProtection","includeSheetProtection","sheet","objects","scenarios","getHashOfPassword","_addAutoFilter","startRow","filterRow","startCol","endCol","endRow","firstEmptyRow","undefined","curRow","firstColumn","lastColumn","startCell","endCell","wb","definedNameCollection","addDefinedName","localSheetId","name","refFormula","_addMergeCells","mergedCells","Array","cr","_addConditionalFormatting","cfRulesCollection","_addHyperlinks","hyperlinkCollection","_addDataValidations","dataValidationCollection","_addPrintOptions","addPrintOptions","printOptions","poEle","centerHorizontal","centerVertical","printHeadings","printGridLines","_addPageMargins","margins","left","right","top","bottom","header","footer","_addLegacyDrawing","rId","relationships","indexOf","_addPageSetup","addPageSetup","psEle","paperSize","paperHeight","paperWidth","scale","firstPageNumber","pageOrder","orientation","usePrinterDefaults","blackAndWhite","draft","cellComments","useFirstPageNumber","errors","horizontalDpi","verticalDpi","copies","_addPageBreaks","rowBreaks","pageBreaks","row","rbEle","bEle","pos","colBreaks","column","cbEle","_addHeaderFooter","addHeaderFooter","headerFooter","hfEle","alignWithMargins","differentFirst","differentOddEven","scaleWithDoc","oddHeader","text","oddFooter","evenHeader","evenFooter","firstHeader","firstFooter","_addlegacyDrawingHeaderFooter","legacyDrawingHeaderFooter","isEmpty","dId","_addDrawing","drawingCollection","sheetXML","xmlProlog","xmlString","wsXML","begin","chunk","then","end","catch","e","Error","stack","relsXML","sheetRelRequired","relXML","create","Hyperlink","location","sheetId","doc","commentsXML","commentsXml","author","commentList","comments","uuid","comment","commentsVmlXML","vmlXml","sl","st","position","marginLeft","marginT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N,CAAU,WAAV,EAAuB4N,SAAvB;AACAC,kBAAM7N,GAAN,CAAU,aAAV,EAAyB,MAAzB;;AAEA6N,kBAAM9N,GAAN,CAAU,QAAV,EAAoBC,GAApB,CAAwB,eAAxB,EAAyC,MAAzC;;AAEA,gBAAM8N,KAAKD,MAAM9N,GAAN,CAAU,WAAV,EAAuBC,GAAvB,CAA2B,OAA3B,EAAoC,wBAApC,CAAX;AACA8N,eAAG/N,GAAH,CAAO,KAAP,EAAcC,GAAd,CAAkB,OAAlB,EAA2B,iBAA3B;;AAEA,gBAAM+N,KAAKF,MAAM9N,GAAN,CAAU,cAAV,EAA0BC,GAA1B,CAA8B,YAA9B,EAA4C,MAA5C,CAAX;AACA+N,eAAGhO,GAAH,CAAO,iBAAP;AACAgO,eAAGhO,GAAH,CAAO,iBAAP;AACAgO,eAAGhO,GAAH,CAAO,YAAP,EAAqB4K,IAArB,CAA0B,OAA1B;AACAoD,eAAGhO,GAAH,CAAO,OAAP,EAAgB4K,IAAhB,CAAqBhB,MAAM,CAA3B;AACAoE,eAAGhO,GAAH,CAAO,UAAP,EAAmB4K,IAAnB,CAAwB9H,MAAM,CAA9B;AACH,SApBD;;AAuBA,YAAI4I,YAAY0B,OAAOT,GAAP,GAAaZ,GAAb,EAAhB;AACA5M,gBAAQuM,SAAR;AACH,KA3CM,CAAP;AA4CH,CA7CD;;AA+CAuC,OAAOC,OAAP,GAAiB,EAAE1C,kBAAF,EAAYY,gBAAZ,EAAqBQ,wBAArB,EAAkCO,8BAAlC,EAAjB","file":"builder.js","sourcesContent":["const xml = require('xmlbuilder');\r\nconst utils = require('../utils.js');\r\nconst types = require('../types/index.js');\r\nconst hyperlinks = require('./classes/hyperlink');\r\nconst Picture = require('../drawing/picture.js');\r\n\r\nlet _addSheetPr = (promiseObj) => {\r\n // §18.3.1.82 sheetPr (Sheet Properties)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts;\r\n\r\n // Check if any option that would require the sheetPr element to be added exists\r\n if (\r\n o.pageSetup.fitToHeight !== null ||\r\n o.pageSetup.fitToWidth !== null ||\r\n o.outline.summaryBelow !== null ||\r\n o.outline.summaryRight !== null ||\r\n o.autoFilter.ref !== null\r\n ) {\r\n let ele = promiseObj.xml.ele('sheetPr');\r\n\r\n if (o.autoFilter.ref) {\r\n ele.att('enableFormatConditionsCalculation', 1);\r\n ele.att('filterMode', 1);\r\n }\r\n\r\n if (o.outline.summaryBelow !== null || o.outline.summaryRight !== null) {\r\n let outlineEle = ele.ele('outlinePr');\r\n outlineEle.att('applyStyles', 1);\r\n outlineEle.att('summaryBelow', o.outline.summaryBelow === true ? 1 : 0);\r\n outlineEle.att('summaryRight', o.outline.summaryRight === true ? 1 : 0);\r\n outlineEle.up();\r\n }\r\n\r\n // §18.3.1.65 pageSetUpPr (Page Setup Properties)\r\n if (o.pageSetup.fitToHeight !== null || o.pageSetup.fitToWidth !== null) {\r\n ele.ele('pageSetUpPr').att('fitToPage', 1).up();\r\n }\r\n ele.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addDimension = (promiseObj) => {\r\n // §18.3.1.35 dimension (Worksheet Dimensions)\r\n return new Promise((resolve, reject) => {\r\n let firstCell = 'A1';\r\n let lastCell = `${utils.getExcelAlpha(promiseObj.ws.lastUsedCol)}${promiseObj.ws.lastUsedRow}`;\r\n let ele = promiseObj.xml.ele('dimension');\r\n ele.att('ref', `${firstCell}:${lastCell}`);\r\n ele.up();\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addSheetViews = (promiseObj) => {\r\n // §18.3.1.88 sheetViews (Sheet Views)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts.sheetView;\r\n let ele = promiseObj.xml.ele('sheetViews');\r\n let sv = ele.ele('sheetView')\r\n .att('showGridLines', o.showGridLines)\r\n .att('workbookViewId', o.workbookViewId)\r\n .att('rightToLeft', o.rightToLeft)\r\n .att('zoomScale', o.zoomScale)\r\n .att('zoomScaleNormal', o.zoomScaleNormal)\r\n .att('zoomScalePageLayoutView', o.zoomScalePageLayoutView);\r\n\r\n let modifiedPaneParams = [];\r\n Object.keys(o.pane).forEach((k) => {\r\n if (o.pane[k] !== null) {\r\n modifiedPaneParams.push(k);\r\n }\r\n });\r\n if (modifiedPaneParams.length > 0) {\r\n let pEle = sv.ele('pane');\r\n o.pane.xSplit !== null ? pEle.att('xSplit', o.pane.xSplit) : null;\r\n o.pane.ySplit !== null ? pEle.att('ySplit', o.pane.ySplit) : null;\r\n o.pane.topLeftCell !== null ? pEle.att('topLeftCell', o.pane.topLeftCell) : null;\r\n o.pane.activePane !== null ? pEle.att('activePane', o.pane.activePane) : null;\r\n o.pane.state !== null ? pEle.att('state', o.pane.state) : null;\r\n pEle.up();\r\n }\r\n sv.up();\r\n ele.up();\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addSheetFormatPr = (promiseObj) => {\r\n // §18.3.1.81 sheetFormatPr (Sheet Format Properties)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts.sheetFormat;\r\n let ele = promiseObj.xml.ele('sheetFormatPr');\r\n\r\n o.baseColWidth !== null ? ele.att('baseColWidth', o.baseColWidth) : null;\r\n o.defaultColWidth !== null ? ele.att('defaultColWidth', o.defaultColWidth) : null;\r\n o.defaultRowHeight !== null ? ele.att('defaultRowHeight', o.defaultRowHeight) : ele.att('defaultRowHeight', 16);\r\n o.thickBottom !== null ? ele.att('thickBottom', utils.boolToInt(o.thickBottom)) : null;\r\n o.thickTop !== null ? ele.att('thickTop', utils.boolToInt(o.thickTop)) : null;\r\n\r\n\r\n if (typeof o.defaultRowHeight === 'number') {\r\n ele.att('customHeight', '1');\r\n }\r\n ele.up();\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addCols = (promiseObj) => {\r\n // §18.3.1.17 cols (Column Information)\r\n return new Promise((resolve, reject) => {\r\n\r\n if (promiseObj.ws.columnCount > 0) {\r\n let colsEle = promiseObj.xml.ele('cols');\r\n\r\n for (let colId in promiseObj.ws.cols) {\r\n let col = promiseObj.ws.cols[colId];\r\n let colEle = colsEle.ele('col');\r\n\r\n col.min !== null ? colEle.att('min', col.min) : null;\r\n col.max !== null ? colEle.att('max', col.max) : null;\r\n col.width !== null ? colEle.att('width', col.width) : null;\r\n col.style !== null ? colEle.att('style', col.style) : null;\r\n col.hidden !== null ? colEle.att('hidden', utils.boolToInt(col.hidden)) : null;\r\n col.customWidth !== null ? colEle.att('customWidth', utils.boolToInt(col.customWidth)) : null;\r\n col.outlineLevel !== null ? colEle.att('outlineLevel', col.outlineLevel) : null;\r\n col.collapsed !== null ? colEle.att('collapsed', utils.boolToInt(col.collapsed)) : null;\r\n colEle.up();\r\n }\r\n colsEle.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addSheetData = (promiseObj) => {\r\n // §18.3.1.80 sheetData (Sheet Data)\r\n return new Promise((resolve, reject) => {\r\n\r\n let ele = promiseObj.xml.ele('sheetData');\r\n let rows = Object.keys(promiseObj.ws.rows);\r\n\r\n let processRows = (theseRows) => {\r\n for (var r = 0; r < theseRows.length; r++) {\r\n let thisRow = promiseObj.ws.rows[theseRows[r]];\r\n thisRow.cellRefs.sort(utils.sortCellRefs);\r\n\r\n let rEle = ele.ele('row');\r\n\r\n rEle.att('r', thisRow.r);\r\n if (promiseObj.ws.opts.disableRowSpansOptimization !== true && thisRow.spans) {\r\n rEle.att('spans', thisRow.spans);\r\n }\r\n thisRow.s !== null ? rEle.att('s', thisRow.s) : null;\r\n thisRow.customFormat !== null ? rEle.att('customFormat', thisRow.customFormat) : null;\r\n thisRow.ht !== null ? rEle.att('ht', thisRow.ht) : null;\r\n thisRow.hidden !== null ? rEle.att('hidden', thisRow.hidden) : null;\r\n thisRow.customHeight === true || typeof promiseObj.ws.opts.sheetFormat.defaultRowHeight === 'number' ? rEle.att('customHeight', 1) : null;\r\n thisRow.outlineLevel !== null ? rEle.att('outlineLevel', thisRow.outlineLevel) : null;\r\n thisRow.collapsed !== null ? rEle.att('collapsed', thisRow.collapsed) : null;\r\n thisRow.thickTop !== null ? rEle.att('thickTop', thisRow.thickTop) : null;\r\n thisRow.thickBot !== null ? rEle.att('thickBot', thisRow.thickBot) : null;\r\n\r\n for (var i = 0; i < thisRow.cellRefs.length; i++) {\r\n promiseObj.ws.cells[thisRow.cellRefs[i]].addToXMLele(rEle);\r\n }\r\n\r\n rEle.up();\r\n }\r\n\r\n processNextRows();\r\n };\r\n\r\n let processNextRows = () => {\r\n let theseRows = rows.splice(0, 500);\r\n if (theseRows.length === 0) {\r\n ele.up();\r\n return resolve(promiseObj);\r\n }\r\n processRows(theseRows);\r\n };\r\n\r\n processNextRows();\r\n\r\n });\r\n};\r\n\r\nlet _addSheetProtection = (promiseObj) => {\r\n // §18.3.1.85 sheetProtection (Sheet Protection Options)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts.sheetProtection;\r\n let includeSheetProtection = false;\r\n Object.keys(o).forEach((k) => {\r\n if (o[k] !== null) {\r\n includeSheetProtection = true;\r\n }\r\n });\r\n\r\n if (includeSheetProtection) {\r\n // Set required fields with defaults if not specified\r\n o.sheet = o.sheet !== null ? o.sheet : true;\r\n o.objects = o.objects !== null ? o.objects : true;\r\n o.scenarios = o.scenarios !== null ? o.scenarios : true;\r\n\r\n let ele = promiseObj.xml.ele('sheetProtection');\r\n Object.keys(o).forEach((k) => {\r\n if (o[k] !== null) {\r\n if (k === 'password') {\r\n ele.att('password', utils.getHashOfPassword(o[k]));\r\n } else {\r\n ele.att(k, utils.boolToInt(o[k]));\r\n }\r\n }\r\n });\r\n ele.up();\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addAutoFilter = (promiseObj) => {\r\n // §18.3.1.2 autoFilter (AutoFilter Settings)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts.autoFilter;\r\n\r\n if (typeof o.startRow === 'number') {\r\n let ele = promiseObj.xml.ele('autoFilter');\r\n let filterRow = promiseObj.ws.rows[o.startRow];\r\n\r\n o.startCol = typeof o.startCol === 'number' ? o.startCol : null;\r\n o.endCol = typeof o.endCol === 'number' ? o.endCol : null;\r\n\r\n if (typeof o.endRow !== 'number') {\r\n let firstEmptyRow = undefined;\r\n let curRow = o.startRow;\r\n while (firstEmptyRow === undefined) {\r\n if (!promiseObj.ws.rows[curRow]) {\r\n firstEmptyRow = curRow;\r\n } else {\r\n curRow++;\r\n }\r\n }\r\n\r\n o.endRow = firstEmptyRow - 1;\r\n }\r\n\r\n // Columns to sort not manually set. filter all columns in this row containing data.\r\n if (typeof o.startCol !== 'number' || typeof o.endCol !== 'number') {\r\n o.startCol = filterRow.firstColumn;\r\n o.endCol = filterRow.lastColumn;\r\n }\r\n\r\n let startCell = utils.getExcelAlpha(o.startCol) + o.startRow;\r\n let endCell = utils.getExcelAlpha(o.endCol) + o.endRow;\r\n\r\n ele.att('ref', `${startCell}:${endCell}`);\r\n promiseObj.ws.wb.definedNameCollection.addDefinedName({\r\n hidden: 1,\r\n localSheetId: promiseObj.ws.localSheetId,\r\n name: '_xlnm._FilterDatabase',\r\n refFormula: '\\'' + promiseObj.ws.name + '\\'!' +\r\n '$' + utils.getExcelAlpha(o.startCol) +\r\n '$' + o.startRow +\r\n ':' +\r\n '$' + utils.getExcelAlpha(o.endCol) +\r\n '$' + o.endRow\r\n });\r\n ele.up();\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addMergeCells = (promiseObj) => {\r\n // §18.3.1.55 mergeCells (Merge Cells)\r\n return new Promise((resolve, reject) => {\r\n\r\n if (promiseObj.ws.mergedCells instanceof Array && promiseObj.ws.mergedCells.length > 0) {\r\n let ele = promiseObj.xml.ele('mergeCells').att('count', promiseObj.ws.mergedCells.length);\r\n promiseObj.ws.mergedCells.forEach((cr) => {\r\n ele.ele('mergeCell').att('ref', cr).up();\r\n });\r\n ele.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addConditionalFormatting = (promiseObj) => {\r\n // §18.3.1.18 conditionalFormatting (Conditional Formatting)\r\n return new Promise((resolve, reject) => {\r\n promiseObj.ws.cfRulesCollection.addToXMLele(promiseObj.xml);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addHyperlinks = (promiseObj) => {\r\n // §18.3.1.48 hyperlinks (Hyperlinks)\r\n return new Promise((resolve, reject) => {\r\n promiseObj.ws.hyperlinkCollection.addToXMLele(promiseObj.xml);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addDataValidations = (promiseObj) => {\r\n // §18.3.1.33 dataValidations (Data Validations)\r\n return new Promise((resolve, reject) => {\r\n if (promiseObj.ws.dataValidationCollection.length > 0) {\r\n promiseObj.ws.dataValidationCollection.addToXMLele(promiseObj.xml);\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addPrintOptions = (promiseObj) => {\r\n // §18.3.1.70 printOptions (Print Options)\r\n return new Promise((resolve, reject) => {\r\n\r\n let addPrintOptions = false;\r\n let o = promiseObj.ws.opts.printOptions;\r\n Object.keys(o).forEach((k) => {\r\n if (o[k] !== null) {\r\n addPrintOptions = true;\r\n }\r\n });\r\n\r\n if (addPrintOptions) {\r\n let poEle = promiseObj.xml.ele('printOptions');\r\n o.centerHorizontal === true ? poEle.att('horizontalCentered', 1) : null;\r\n o.centerVertical === true ? poEle.att('verticalCentered', 1) : null;\r\n o.printHeadings === true ? poEle.att('headings', 1) : null;\r\n if (o.printGridLines === true) {\r\n poEle.att('gridLines', 1);\r\n poEle.att('gridLinesSet', 1);\r\n }\r\n poEle.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addPageMargins = (promiseObj) => {\r\n // §18.3.1.62 pageMargins (Page Margins)\r\n return new Promise((resolve, reject) => {\r\n let o = promiseObj.ws.opts.margins;\r\n\r\n promiseObj.xml.ele('pageMargins')\r\n .att('left', o.left)\r\n .att('right', o.right)\r\n .att('top', o.top)\r\n .att('bottom', o.bottom)\r\n .att('header', o.header)\r\n .att('footer', o.footer)\r\n .up();\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addLegacyDrawing = (promiseObj) => {\r\n return new Promise((resolve, reject) => {\r\n\r\n const rId = promiseObj.ws.relationships.indexOf('commentsVml') + 1;\r\n if(rId === 0) {\r\n resolve(promiseObj);\r\n } else {\r\n promiseObj.xml.ele('legacyDrawing')\r\n .att('r:id', 'rId' + rId)\r\n .up();\r\n\r\n resolve(promiseObj);\r\n }\r\n })\r\n}\r\n\r\nlet _addPageSetup = (promiseObj) => {\r\n // §18.3.1.63 pageSetup (Page Setup Settings)\r\n return new Promise((resolve, reject) => {\r\n\r\n let addPageSetup = false;\r\n let o = promiseObj.ws.opts.pageSetup;\r\n Object.keys(o).forEach((k) => {\r\n if (o[k] !== null) {\r\n addPageSetup = true;\r\n }\r\n });\r\n\r\n if (addPageSetup === true) {\r\n let psEle = promiseObj.xml.ele('pageSetup');\r\n o.paperSize !== null ? psEle.att('paperSize', types.paperSize[o.paperSize]) : null;\r\n o.paperHeight !== null ? psEle.att('paperHeight', o.paperHeight) : null;\r\n o.paperWidth !== null ? psEle.att('paperWidth', o.paperWidth) : null;\r\n o.scale !== null ? psEle.att('scale', o.scale) : null;\r\n o.firstPageNumber !== null ? psEle.att('firstPageNumber', o.firstPageNumber) : null;\r\n o.fitToWidth !== null ? psEle.att('fitToWidth', o.fitToWidth) : null;\r\n o.fitToHeight !== null ? psEle.att('fitToHeight', o.fitToHeight) : null;\r\n o.pageOrder !== null ? psEle.att('pageOrder', o.pageOrder) : null;\r\n o.orientation !== null ? psEle.att('orientation', o.orientation) : null;\r\n o.usePrinterDefaults !== null ? psEle.att('usePrinterDefaults', utils.boolToInt(o.usePrinterDefaults)) : null;\r\n o.blackAndWhite !== null ? psEle.att('blackAndWhite', utils.boolToInt(o.blackAndWhite)) : null;\r\n o.draft !== null ? psEle.att('draft', utils.boolToInt(o.draft)) : null;\r\n o.cellComments !== null ? psEle.att('cellComments', o.cellComments) : null;\r\n o.useFirstPageNumber !== null ? psEle.att('useFirstPageNumber', utils.boolToInt(o.useFirstPageNumber)) : null;\r\n o.errors !== null ? psEle.att('errors', o.errors) : null;\r\n o.horizontalDpi !== null ? psEle.att('horizontalDpi', o.horizontalDpi) : null;\r\n o.verticalDpi !== null ? psEle.att('verticalDpi', o.verticalDpi) : null;\r\n o.copies !== null ? psEle.att('copies', o.copies) : null;\r\n psEle.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addPageBreaks = (promiseObj) => {\r\n // colBreaks (§18.3.1.14); rowBreaks (§18.3.1.74)\r\n const rowBreaks = promiseObj.ws.pageBreaks.row;\r\n if (rowBreaks.length > 0) {\r\n const rbEle = promiseObj.xml.ele('rowBreaks');\r\n rbEle.att('count', rowBreaks.length);\r\n rbEle.att('manualBreakCount', rowBreaks.length);\r\n rowBreaks.forEach(pos => {\r\n const bEle = rbEle.ele('brk');\r\n bEle.att('id', pos);\r\n bEle.att('man', 1);\r\n bEle.up();\r\n });\r\n rbEle.up();\r\n }\r\n const colBreaks = promiseObj.ws.pageBreaks.column;\r\n if (colBreaks.length > 0) {\r\n const cbEle = promiseObj.xml.ele('colBreaks');\r\n cbEle.att('count', colBreaks.length);\r\n cbEle.att('manualBreakCount', colBreaks.length);\r\n colBreaks.forEach(pos => {\r\n const bEle = cbEle.ele('brk');\r\n bEle.att('id', pos);\r\n bEle.att('man', 1);\r\n bEle.up();\r\n });\r\n cbEle.up();\r\n }\r\n return promiseObj;\r\n}\r\n\r\nlet _addHeaderFooter = (promiseObj) => {\r\n // §18.3.1.46 headerFooter (Header Footer Settings)\r\n return new Promise((resolve, reject) => {\r\n\r\n let addHeaderFooter = false;\r\n let o = promiseObj.ws.opts.headerFooter;\r\n Object.keys(o).forEach((k) => {\r\n if (o[k] !== null) {\r\n addHeaderFooter = true;\r\n }\r\n });\r\n\r\n if (addHeaderFooter === true) {\r\n let hfEle = promiseObj.xml.ele('headerFooter');\r\n\r\n o.alignWithMargins !== null ? hfEle.att('alignWithMargins', utils.boolToInt(o.alignWithMargins)) : null;\r\n o.differentFirst !== null ? hfEle.att('differentFirst', utils.boolToInt(o.differentFirst)) : null;\r\n o.differentOddEven !== null ? hfEle.att('differentOddEven', utils.boolToInt(o.differentOddEven)) : null;\r\n o.scaleWithDoc !== null ? hfEle.att('scaleWithDoc', utils.boolToInt(o.scaleWithDoc)) : null;\r\n\r\n o.oddHeader !== null ? hfEle.ele('oddHeader').text(o.oddHeader).up() : null;\r\n o.oddFooter !== null ? hfEle.ele('oddFooter').text(o.oddFooter).up() : null;\r\n o.evenHeader !== null ? hfEle.ele('evenHeader').text(o.evenHeader).up() : null;\r\n o.evenFooter !== null ? hfEle.ele('evenFooter').text(o.evenFooter).up() : null;\r\n o.firstHeader !== null ? hfEle.ele('firstHeader').text(o.firstHeader).up() : null;\r\n o.firstFooter !== null ? hfEle.ele('firstFooter').text(o.firstFooter).up() : null;\r\n hfEle.up();\r\n }\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addlegacyDrawingHeaderFooter = (promiseObj) => {\r\n return new Promise((resolve, reject) => {\r\n if (!promiseObj.ws.legacyDrawingHeaderFooter.isEmpty) {\r\n let dId = promiseObj.ws.relationships.indexOf('legacyDrawingHeaderFooter') + 1;\r\n promiseObj.xml.ele('legacyDrawingHF').att('r:id', 'rId' + dId).up();\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet _addDrawing = (promiseObj) => {\r\n // §18.3.1.36 drawing (Drawing)\r\n return new Promise((resolve, reject) => {\r\n if (!promiseObj.ws.drawingCollection.isEmpty) {\r\n let dId = promiseObj.ws.relationships.indexOf('drawing') + 1;\r\n promiseObj.xml.ele('drawing').att('r:id', 'rId' + dId).up();\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet sheetXML = (ws) => {\r\n return new Promise((resolve, reject) => {\r\n\r\n let xmlProlog = '';\r\n let xmlString = '';\r\n let wsXML = xml.begin({\r\n 'allowSurrogateChars': true,\r\n }, (chunk) => {\r\n xmlString += chunk;\r\n })\r\n\r\n .ele('worksheet')\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n // Excel complains if specific elements on not in the correct order in the XML doc as defined in §M.2.2\r\n let promiseObj = { xml: wsXML, ws: ws };\r\n\r\n _addSheetPr(promiseObj)\r\n .then(_addDimension)\r\n .then(_addSheetViews)\r\n .then(_addSheetFormatPr)\r\n .then(_addCols)\r\n .then(_addSheetData)\r\n .then(_addSheetProtection)\r\n .then(_addAutoFilter)\r\n .then(_addMergeCells)\r\n .then(_addConditionalFormatting)\r\n .then(_addDataValidations)\r\n .then(_addHyperlinks)\r\n .then(_addPrintOptions)\r\n .then(_addPageMargins)\r\n .then(_addLegacyDrawing)\r\n .then(_addPageSetup)\r\n .then(_addPageBreaks)\r\n .then(_addHeaderFooter)\r\n .then(_addlegacyDrawingHeaderFooter)\r\n .then(_addDrawing)\r\n .then((promiseObj) => {\r\n return new Promise((resolve, reject) => {\r\n wsXML.end();\r\n resolve(xmlString);\r\n });\r\n })\r\n .then((xml) => {\r\n resolve(xml);\r\n })\r\n .catch((e) => {\r\n throw new Error(e.stack);\r\n });\r\n });\r\n};\r\n\r\nlet relsXML = (ws) => {\r\n return new Promise((resolve, reject) => {\r\n let sheetRelRequired = false;\r\n if (ws.relationships.length > 0) {\r\n sheetRelRequired = true;\r\n }\r\n\r\n if (sheetRelRequired === false) {\r\n resolve();\r\n }\r\n\r\n let relXML = xml.create(\r\n 'Relationships',\r\n {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n relXML.att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n ws.relationships.forEach((r, i) => {\r\n let rId = 'rId' + (i + 1);\r\n if (r instanceof hyperlinks.Hyperlink) {\r\n relXML.ele('Relationship')\r\n .att('Id', rId)\r\n .att('Target', r.location)\r\n .att('TargetMode', 'External')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink');\r\n } else if (r === 'drawing') {\r\n relXML.ele('Relationship')\r\n .att('Id', rId)\r\n .att('Target', '../drawings/drawing' + ws.sheetId + '.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing');\r\n } else if (r === 'comments') {\r\n relXML.ele('Relationship')\r\n .att('Id', rId)\r\n .att('Target', '../comments' + ws.sheetId + '.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments');\r\n } else if (r === 'commentsVml') {\r\n relXML.ele('Relationship')\r\n .att('Id', rId)\r\n .att('Target', '../drawings/commentsVml' + ws.sheetId + '.vml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing');\r\n } else if (r === 'legacyDrawingHeaderFooter') {\r\n relXML.ele('Relationship')\r\n .att('Id', rId)\r\n .att('Target', '../drawings/vmlDrawing' + ws.sheetId + '.vml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing');\r\n }\r\n });\r\n let xmlString = relXML.doc().end();\r\n resolve(xmlString);\r\n });\r\n};\r\n\r\nlet commentsXML = (ws) => {\r\n return new Promise((resolve, reject) => {\r\n const commentsXml = xml.create(\r\n 'comments',\r\n {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n commentsXml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n commentsXml.ele('authors').ele('author').text(ws.wb.author);\r\n\r\n const commentList = commentsXml.ele('commentList');\r\n Object.keys(ws.comments).forEach(ref => {\r\n commentList\r\n .ele('comment')\r\n .att('ref', ref)\r\n .att('authorId', '0')\r\n .att('guid', ws.comments[ref].uuid)\r\n .ele('text')\r\n .ele('t')\r\n .text(ws.comments[ref].comment);\r\n });\r\n let xmlString = commentsXml.doc().end();\r\n resolve(xmlString);\r\n });\r\n}\r\n\r\nlet commentsVmlXML = (ws) => {\r\n return new Promise((resolve, reject) => {\r\n // do not add XML prolog to document\r\n const vmlXml = xml.begin().ele('xml');\r\n vmlXml.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n vmlXml.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n vmlXml.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = vmlXml.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = vmlXml.ele('v:shapetype')\r\n .att('id', '_x0000_t202')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '202')\r\n .att('path', 'm,l,21600r21600,l21600,xe');\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n st.ele('v:path').att('gradientshapeok', 't').att('o:connecttype', 'rect');\r\n\r\n Object.keys(ws.comments).forEach((ref) => {\r\n const {row, col, position, marginLeft, marginTop, width, height, zIndex, visibility, fillColor} = ws.comments[ref];\r\n const shape = vmlXml.ele('v:shape');\r\n shape.att('id', `_${ws.sheetId}_${row}_${col}`);\r\n shape.att('type', \"#_x0000_t202\");\r\n shape.att('style', `position:${position};margin-left:${marginLeft};margin-top:${marginTop};width:${width};height:${height};z-index:${zIndex};visibility:${visibility}`);\r\n shape.att('fillcolor', fillColor);\r\n shape.att('o:insetmode', 'auto');\r\n\r\n shape.ele('v:path').att('o:connecttype', 'none');\r\n\r\n const tb = shape.ele('v:textbox').att('style', 'mso-direction-alt:auto');\r\n tb.ele('div').att('style', 'text-align:left');\r\n\r\n const cd = shape.ele('x:ClientData').att('ObjectType', 'Note');\r\n cd.ele('x:MoveWithCells');\r\n cd.ele('x:SizeWithCells');\r\n cd.ele('x:AutoFill').text('False');\r\n cd.ele('x:Row').text(row - 1);\r\n cd.ele('x:Column').text(col - 1);\r\n });\r\n\r\n\r\n let xmlString = vmlXml.doc().end();\r\n resolve(xmlString);\r\n });\r\n}\r\n\r\nmodule.exports = { sheetXML, relsXML, commentsXML, commentsVmlXML };\r\n"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rule.js b/distribution/lib/worksheet/cf/cf_rule.js new file mode 100644 index 00000000..c9e0d757 --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rule.js @@ -0,0 +1,71 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _reduce = require('lodash.reduce'); +var _get = require('lodash.get'); +var CF_RULE_TYPES = require('./cf_rule_types'); + +var CfRule = function () { + // §18.3.1.10 cfRule (Conditional Formatting Rule) + function CfRule(ruleConfig) { + var _this = this; + + _classCallCheck(this, CfRule); + + this.type = ruleConfig.type; + this.priority = ruleConfig.priority; + this.formula = ruleConfig.formula; + this.dxfId = ruleConfig.dxfId; + + var foundType = CF_RULE_TYPES[this.type]; + + if (!foundType) { + throw new TypeError('"' + this.type + '" is not a valid conditional formatting rule type'); + } + + if (!foundType.supported) { + throw new TypeError('Conditional formatting type "' + this.type + '" is not yet supported'); + } + + var missingProps = _reduce(foundType.requiredProps, function (list, prop) { + if (_get(_this, prop, null) === null) { + list.push(prop); + } + return list; + }, []); + + if (missingProps.length) { + throw new TypeError('Conditional formatting rule is missing required properties: ' + missingProps.join(', ')); + } + } + + _createClass(CfRule, [{ + key: 'addToXMLele', + value: function addToXMLele(ele) { + var thisRule = ele.ele('cfRule'); + if (this.type !== undefined) { + thisRule.att('type', this.type); + } + if (this.dxfId !== undefined) { + thisRule.att('dxfId', this.dxfId); + } + if (this.priority !== undefined) { + thisRule.att('priority', this.priority); + } + + if (this.formula !== undefined) { + thisRule.ele('formula').text(this.formula); + thisRule.up(); + } + thisRule.up(); + } + }]); + + return CfRule; +}(); + +module.exports = CfRule; +//# sourceMappingURL=cf_rule.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rule.js.map b/distribution/lib/worksheet/cf/cf_rule.js.map new file mode 100644 index 00000000..85b60342 --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rule.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/worksheet/cf/cf_rule.js"],"names":["_reduce","require","_get","CF_RULE_TYPES","CfRule","ruleConfig","type","priority","formula","dxfId","foundType","TypeError","supported","missingProps","requiredProps","list","prop","push","length","join","ele","thisRule","undefined","att","text","up","module","exports"],"mappings":";;;;;;AAAA,IAAMA,UAAUC,QAAQ,eAAR,CAAhB;AACA,IAAMC,OAAOD,QAAQ,YAAR,CAAb;AACA,IAAME,gBAAgBF,QAAQ,iBAAR,CAAtB;;IAEMG,M;AAAS;AACX,oBAAYC,UAAZ,EAAwB;AAAA;;AAAA;;AACpB,aAAKC,IAAL,GAAYD,WAAWC,IAAvB;AACA,aAAKC,QAAL,GAAgBF,WAAWE,QAA3B;AACA,aAAKC,OAAL,GAAeH,WAAWG,OAA1B;AACA,aAAKC,KAAL,GAAaJ,WAAWI,KAAxB;;AAEA,YAAIC,YAAYP,cAAc,KAAKG,IAAnB,CAAhB;;AAEA,YAAI,CAACI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require('lodash.reduce');\r\nconst _get = require('lodash.get');\r\nconst CF_RULE_TYPES = require('./cf_rule_types');\r\n\r\nclass CfRule { // §18.3.1.10 cfRule (Conditional Formatting Rule)\r\n constructor(ruleConfig) {\r\n this.type = ruleConfig.type;\r\n this.priority = ruleConfig.priority;\r\n this.formula = ruleConfig.formula;\r\n this.dxfId = ruleConfig.dxfId;\r\n\r\n let foundType = CF_RULE_TYPES[this.type];\r\n\r\n if (!foundType) {\r\n throw new TypeError('\"' + this.type + '\" is not a valid conditional formatting rule type');\r\n }\r\n\r\n if (!foundType.supported) {\r\n throw new TypeError('Conditional formatting type \"' + this.type + '\" is not yet supported');\r\n }\r\n\r\n let missingProps = _reduce(foundType.requiredProps, (list, prop) => {\r\n if (_get(this, prop, null) === null) {\r\n list.push(prop);\r\n }\r\n return list;\r\n }, []);\r\n\r\n if (missingProps.length) {\r\n throw new TypeError('Conditional formatting rule is missing required properties: ' + missingProps.join(', '));\r\n }\r\n }\r\n\r\n addToXMLele(ele) {\r\n let thisRule = ele.ele('cfRule');\r\n if (this.type !== undefined) {\r\n thisRule.att('type', this.type);\r\n }\r\n if (this.dxfId !== undefined) {\r\n thisRule.att('dxfId', this.dxfId);\r\n }\r\n if (this.priority !== undefined) {\r\n thisRule.att('priority', this.priority);\r\n }\r\n\r\n if (this.formula !== undefined) {\r\n thisRule.ele('formula').text(this.formula);\r\n thisRule.up();\r\n }\r\n thisRule.up();\r\n }\r\n}\r\n\r\n\r\nmodule.exports = CfRule;"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rule_types.js b/distribution/lib/worksheet/cf/cf_rule_types.js new file mode 100644 index 00000000..0b7f898b --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rule_types.js @@ -0,0 +1,48 @@ +'use strict'; + +// Types from xlsx spec: +// http://download.microsoft.com/download/D/3/3/D334A189-E51B-47FF-B0E8-C0479AFB0E3C/[MS-XLSX].pdf + +module.exports = { + cellIs: { + supported: false + }, + expression: { + supported: true, + requiredProps: ['dxfId', 'priority', 'formula'] + }, + colorScale: { + supported: false + }, + dataBar: { + supported: false + }, + iconSet: { + supported: false + }, + containsText: { + supported: false + }, + notContainsText: { + supported: false + }, + beginsWith: { + supported: false + }, + endsWith: { + supported: false + }, + containsBlanks: { + supported: false + }, + notContainsBlanks: { + supported: false + }, + containsErrors: { + supported: false + }, + notContainsErrors: { + supported: false + } +}; +//# sourceMappingURL=cf_rule_types.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rule_types.js.map b/distribution/lib/worksheet/cf/cf_rule_types.js.map new file mode 100644 index 00000000..e3fe3185 --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rule_types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/worksheet/cf/cf_rule_types.js"],"names":["module","exports","cellIs","supported","expression","requiredProps","colorScale","dataBar","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks","containsErrors","notContainsErrors"],"mappings":";;AAAA;AACA;;AAEAA,OAAOC,OAAP,GAAiB;AACbC,YAAQ;AACJC,mBAAW;AADP,KADK;AAIbC,gBAAY;AACRD,mBAAW,IADH;AAERE,uBAAe,CAAC,OAAD,EAAU,UAAV,EAAsB,SAAtB;AAFP,KAJC;AAQbC,gBAAY;AACRH,mBAAW;AADH,KARC;AAWbI,aAAS;AACLJ,mBAAW;AADN,KAXI;AAcbK,aAAS;AACLL,mBAAW;AADN,KAdI;AAiBbM,kBAAc;AACVN,mBAAW;AADD,KAjBD;AAoBbO,qBAAiB;AACbP,mBAAW;AADE,KApBJ;AAuBbQ,gBAAY;AACRR,mBAAW;AADH,KAvBC;AA0BbS,cAAU;AACNT,mBAAW;AADL,KA1BG;AA6BbU,oBAAgB;AACZV,mBAAW;AADC,KA7BH;AAgCbW,uBAAmB;AACfX,mBAAW;AADI,KAhCN;AAmCbY,oBAAgB;AACZZ,mBAAW;AADC,KAnCH;AAsCba,uBAAmB;AACfb,mBAAW;AADI;AAtCN,CAAjB","file":"cf_rule_types.js","sourcesContent":["// Types from xlsx spec:\r\n// http://download.microsoft.com/download/D/3/3/D334A189-E51B-47FF-B0E8-C0479AFB0E3C/[MS-XLSX].pdf\r\n\r\nmodule.exports = {\r\n cellIs: {\r\n supported: false\r\n },\r\n expression: {\r\n supported: true,\r\n requiredProps: ['dxfId', 'priority', 'formula']\r\n },\r\n colorScale: {\r\n supported: false\r\n },\r\n dataBar: {\r\n supported: false\r\n },\r\n iconSet: {\r\n supported: false\r\n },\r\n containsText: {\r\n supported: false\r\n },\r\n notContainsText: {\r\n supported: false\r\n },\r\n beginsWith: {\r\n supported: false\r\n },\r\n endsWith: {\r\n supported: false\r\n },\r\n containsBlanks: {\r\n supported: false\r\n },\r\n notContainsBlanks: {\r\n supported: false\r\n },\r\n containsErrors: {\r\n supported: false\r\n },\r\n notContainsErrors: {\r\n supported: false\r\n }\r\n};\r\n"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rules_collection.js b/distribution/lib/worksheet/cf/cf_rules_collection.js new file mode 100644 index 00000000..9c393163 --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rules_collection.js @@ -0,0 +1,53 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var CfRule = require('./cf_rule'); + +// ----------------------------------------------------------------------------- + +var CfRulesCollection = function () { + // §18.3.1.18 conditionalFormatting (Conditional Formatting) + function CfRulesCollection() { + _classCallCheck(this, CfRulesCollection); + + // rules are indexed by cell refs + this.rulesBySqref = {}; + } + + _createClass(CfRulesCollection, [{ + key: 'add', + value: function add(sqref, ruleConfig) { + var rules = this.rulesBySqref[sqref] || []; + var newRule = new CfRule(ruleConfig); + rules.push(newRule); + this.rulesBySqref[sqref] = rules; + return this; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var _this = this; + + Object.keys(this.rulesBySqref).forEach(function (sqref) { + var thisEle = ele.ele('conditionalFormatting').att('sqref', sqref); + _this.rulesBySqref[sqref].forEach(function (rule) { + rule.addToXMLele(thisEle); + }); + thisEle.up(); + }); + } + }, { + key: 'count', + get: function get() { + return Object.keys(this.rulesBySqref).length; + } + }]); + + return CfRulesCollection; +}(); + +module.exports = CfRulesCollection; +//# sourceMappingURL=cf_rules_collection.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/cf/cf_rules_collection.js.map b/distribution/lib/worksheet/cf/cf_rules_collection.js.map new file mode 100644 index 00000000..d510d701 --- /dev/null +++ b/distribution/lib/worksheet/cf/cf_rules_collection.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/worksheet/cf/cf_rules_collection.js"],"names":["CfRule","require","CfRulesCollection","rulesBySqref","sqref","ruleConfig","rules","newRule","push","ele","Object","keys","forEach","thisEle","att","rule","addToXMLele","up","length","module","exports"],"mappings":";;;;;;AAAA,IAAMA,SAASC,QAAQ,WAAR,CAAf;;AAEA;;IAEMC,iB;AAAoB;AACtB,iCAAc;AAAA;;AACV;AACA,aAAKC,YAAL,GAAoB,EAApB;AACH;;;;4BAMGC,K,EAAOC,U,EAAY;AACnB,gBAAIC,QAAQ,KAAKH,YAAL,CAAkBC,KAAlB,KAA4B,EAAxC;AACA,gBAAIG,UAAU,IAAIP,MAAJ,CAAWK,UAAX,CAAd;AACAC,kBAAME,IAAN,CAAWD,OAAX;AACA,iBAAKJ,YAAL,CAAkBC,KAAlB,IAA2BE,KAA3B;AACA,mBAAO,IAAP;AACH;;;oCAEWG,G,EAAK;AAAA;;AACbC,mBAAOC,IAAP,CAAY,KAAKR,YAAjB,EAA+BS,OAA/B,CAAuC,UAACR,KAAD,EAAW;AAC9C,oBAAIS,UAAUJ,IAAIA,GAAJ,CAAQ,uBAAR,EAAiCK,GAAjC,CAAqC,OAArC,EAA8CV,KAA9C,CAAd;AACA,sBAAKD,YAAL,CAAkBC,KAAlB,EAAyBQ,OAAzB,CAAiC,UAACG,IAAD,EAAU;AACvCA,yBAAKC,WAAL,CAAiBH,OAAjB;AACH,iBAFD;AAGAA,wBAAQI,EAAR;AACH,aAND;AAOH;;;4BApBW;AACR,mBAAOP,OAAOC,IAAP,CAAY,KAAKR,YAAjB,EAA+Be,MAAtC;AACH;;;;;;AAsBLC,OAAOC,OAAP,GAAiBlB,iBAAjB","file":"cf_rules_collection.js","sourcesContent":["const CfRule = require('./cf_rule');\r\n\r\n// -----------------------------------------------------------------------------\r\n\r\nclass CfRulesCollection { // §18.3.1.18 conditionalFormatting (Conditional Formatting)\r\n constructor() {\r\n // rules are indexed by cell refs\r\n this.rulesBySqref = {};\r\n }\r\n\r\n get count() {\r\n return Object.keys(this.rulesBySqref).length;\r\n }\r\n\r\n add(sqref, ruleConfig) {\r\n let rules = this.rulesBySqref[sqref] || [];\r\n let newRule = new CfRule(ruleConfig);\r\n rules.push(newRule);\r\n this.rulesBySqref[sqref] = rules;\r\n return this;\r\n }\r\n\r\n addToXMLele(ele) {\r\n Object.keys(this.rulesBySqref).forEach((sqref) => {\r\n let thisEle = ele.ele('conditionalFormatting').att('sqref', sqref);\r\n this.rulesBySqref[sqref].forEach((rule) => {\r\n rule.addToXMLele(thisEle);\r\n });\r\n thisEle.up();\r\n });\r\n }\r\n}\r\n\r\n\r\nmodule.exports = CfRulesCollection;"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/classes/dataValidation.js b/distribution/lib/worksheet/classes/dataValidation.js new file mode 100644 index 00000000..c3f06ad9 --- /dev/null +++ b/distribution/lib/worksheet/classes/dataValidation.js @@ -0,0 +1,217 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var myUtils = require('../../utils.js'); + +var cleanFormula = function cleanFormula(f) { + if (typeof f === 'number' || f.substr(0, 1) === '=') { + return f; + } else { + return '"' + f + '"'; + } +}; + +var DataValidation = function () { + // §18.3.1.32 dataValidation (Data Validation) + function DataValidation(opts) { + _classCallCheck(this, DataValidation); + + opts = opts ? opts : {}; + if (opts.sqref === undefined) { + throw new TypeError('sqref must be specified when creating a DataValidation instance.'); + } + this.sqref = opts.sqref; + if (opts.formulas instanceof Array) { + opts.formulas[0] !== undefined ? this.formula1 = opts.formulas[0] : null; + opts.formulas[1] !== undefined ? this.formula2 = opts.formulas[1] : null; + } + + if (opts.allowBlank !== undefined) { + if (parseInt(opts.allowBlank) === 1) { + opts.allowBlank = true; + } + if (parseInt(opts.allowBlank) === 0) { + opts.allowBlank = false; + } + if (typeof opts.allowBlank !== 'boolean') { + throw new TypeError('DataValidation allowBlank must be true, false, 1 or 0'); + } + this.allowBlank = opts.allowBlank; + } + + if (opts.errorStyle !== undefined) { + var enums = ['stop', 'warning', 'information']; + if (enums.indexOf(opts.errorStyle) < 0) { + throw new TypeError('DataValidation errorStyle must be one of ' + enums.join(', ')); + } + this.errorStyle = opts.errorStyle; + } + + if (opts.error !== undefined) { + if (typeof opts.error !== 'string') { + throw new TypeError('DataValidation error must be a string'); + } + this.error = opts.error; + this.showErrorMessage = opts.showErrorMessage = true; + } + + if (opts.errorTitle !== undefined) { + if (typeof opts.errorTitle !== 'string') { + throw new TypeError('DataValidation errorTitle must be a string'); + } + this.errorTitle = opts.errorTitle; + this.showErrorMessage = opts.showErrorMessage = true; + } + + if (opts.imeMode !== undefined) { + var _enums = ['noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul']; + if (_enums.indexOf(opts.imeMode) < 0) { + throw new TypeError('DataValidation imeMode must be one of ' + _enums.join(', ')); + } + this.imeMode = opts.imeMode; + } + + if (opts.operator !== undefined) { + var _enums2 = ['between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual']; + if (_enums2.indexOf(opts.operator) < 0) { + throw new TypeError('DataValidation operator must be one of ' + _enums2.join(', ')); + } + this.operator = opts.operator; + } + + if (opts.prompt !== undefined) { + if (typeof opts.prompt !== 'string') { + throw new TypeError('DataValidation prompt must be a string'); + } + this.prompt = opts.prompt; + this.showInputMessage = opts.showInputMessage = true; + } + + if (opts.promptTitle !== undefined) { + if (typeof opts.promptTitle !== 'string') { + throw new TypeError('DataValidation promptTitle must be a string'); + } + this.promptTitle = opts.promptTitle; + this.showInputMessage = opts.showInputMessage = true; + } + + if (opts.showDropDown !== undefined) { + if (parseInt(opts.showDropDown) === 1) { + opts.showDropDown = true; + } + if (parseInt(opts.showDropDown) === 0) { + opts.showDropDown = false; + } + if (typeof opts.showDropDown !== 'boolean') { + throw new TypeError('DataValidation showDropDown must be true, false, 1 or 0'); + } + this.showDropDown = opts.showDropDown; + } + + if (opts.showErrorMessage !== undefined) { + if (parseInt(opts.showErrorMessage) === 1) { + opts.showErrorMessage = true; + } + if (parseInt(opts.showErrorMessage) === 0) { + opts.showErrorMessage = false; + } + if (typeof opts.showErrorMessage !== 'boolean') { + throw new TypeError('DataValidation showErrorMessage must be true, false, 1 or 0'); + } + this.showErrorMessage = opts.showErrorMessage; + } + + if (opts.showInputMessage !== undefined) { + if (parseInt(opts.showInputMessage) === 1) { + opts.showInputMessage = true; + } + if (parseInt(opts.showInputMessage) === 0) { + opts.showInputMessage = false; + } + if (typeof opts.showInputMessage !== 'boolean') { + throw new TypeError('DataValidation showInputMessage must be true, false, 1 or 0'); + } + this.showInputMessage = opts.showInputMessage; + } + + if (opts.type !== undefined) { + var _enums3 = ['none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom']; + if (_enums3.indexOf(opts.type) < 0) { + throw new TypeError('DataValidation type must be one of ' + _enums3.join(', ')); + } + this.type = opts.type; + } + } + + _createClass(DataValidation, [{ + key: 'addToXMLele', + value: function addToXMLele(ele) { + var valEle = ele.ele('dataValidation'); + this.type !== undefined ? valEle.att('type', this.type) : null; + this.errorStyle !== undefined ? valEle.att('errorStyle', this.errorStyle) : null; + this.imeMode !== undefined ? valEle.att('imeMode', this.imeMode) : null; + this.operator !== undefined ? valEle.att('operator', this.operator) : null; + this.allowBlank !== undefined ? valEle.att('allowBlank', myUtils.boolToInt(this.allowBlank)) : null; + this.showDropDown === false ? valEle.att('showDropDown', 1) : null; // For some reason, the Excel app sets this property to true if the "In-cell dropdown" option is selected in the data validation screen. + this.showInputMessage !== undefined ? valEle.att('showInputMessage', myUtils.boolToInt(this.showInputMessage)) : null; + this.showErrorMessage !== undefined ? valEle.att('showErrorMessage', myUtils.boolToInt(this.showErrorMessage)) : null; + this.errorTitle !== undefined ? valEle.att('errorTitle', this.errorTitle) : null; + this.error !== undefined ? valEle.att('error', this.error) : null; + this.promptTitle !== undefined ? valEle.att('promptTitle', this.promptTitle) : null; + this.prompt !== undefined ? valEle.att('prompt', this.prompt) : null; + this.sqref !== undefined ? valEle.att('sqref', this.sqref) : null; + if (this.formula1 !== undefined) { + valEle.ele('formula1').text(cleanFormula(this.formula1)); + valEle.up(); + if (this.formula2 !== undefined) { + valEle.ele('formula2').text(cleanFormula(this.formula2)); + valEle.up(); + } + } + valEle.up(); + } + }]); + + return DataValidation; +}(); + +var DataValidationCollection = function () { + // §18.3.1.33 dataValidations (Data Validations) + function DataValidationCollection(opts) { + _classCallCheck(this, DataValidationCollection); + + opts = opts ? opts : {}; + this.items = []; + } + + _createClass(DataValidationCollection, [{ + key: 'add', + value: function add(opts) { + var thisValidation = new DataValidation(opts); + this.items.push(thisValidation); + return thisValidation; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + var valsEle = ele.ele('dataValidations').att('count', this.length); + this.items.forEach(function (val) { + val.addToXMLele(valsEle); + }); + valsEle.up(); + } + }, { + key: 'length', + get: function get() { + return this.items.length; + } + }]); + + return DataValidationCollection; +}(); + +module.exports = { DataValidationCollection: DataValidationCollection, DataValidation: DataValidation }; +//# sourceMappingURL=dataValidation.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/classes/dataValidation.js.map b/distribution/lib/worksheet/classes/dataValidation.js.map new file mode 100644 index 00000000..13ddb449 --- /dev/null +++ b/distribution/lib/worksheet/classes/dataValidation.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/worksheet/classes/dataValidation.js"],"names":["myUtils","require","cleanFormula","f","substr","DataValidation","opts","sqref","undefined","TypeError","formulas","Array","formula1","formula2","allowBlank","parseInt","errorStyle","enums","indexOf","join","error","showErrorMessage","errorTitle","imeMode","operator","prompt","showInputMessage","promptTitle","showDropDown","type","ele","valEle","att","boolToInt","text","up","DataValidationCollection","items","thisValidation","push","valsEle","length","forEach","val","addToXMLele","module","exports"],"mappings":";;;;;;AAAA,IAAMA,UAAUC,QAAQ,gBAAR,CAAhB;;AAEA,IAAIC,eAAe,SAAfA,YAAe,CAACC,CAAD,EAAO;AACtB,QAAI,OAAOA,CAAP,KAAa,QAAb,IAAyBA,EAAEC,MAAF,CAAS,CAAT,EAAY,CAAZ,MAAmB,GAAhD,EAAqD;AACjD,eAAOD,CAAP;AACH,KAFD,MAEO;AACH,eAAO,MAAMA,CAAN,GAAU,GAAjB;AACH;AACJ,CAND;;IAQME,c;AAAiB;AACnB,4BAAYC,IAAZ,EAAkB;AAAA;;AACdA,eAAOA,OAAOA,IAAP,GAAc,EA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EAA4B/B,8BAA5B,EAAjB","file":"dataValidation.js","sourcesContent":["const myUtils = require('../../utils.js');\r\n\r\nlet cleanFormula = (f) => {\r\n if (typeof f === 'number' || f.substr(0, 1) === '=') {\r\n return f;\r\n } else {\r\n return '\"' + f + '\"';\r\n }\r\n};\r\n\r\nclass DataValidation { // §18.3.1.32 dataValidation (Data Validation)\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n if (opts.sqref === undefined) {\r\n throw new TypeError('sqref must be specified when creating a DataValidation instance.');\r\n }\r\n this.sqref = opts.sqref;\r\n if (opts.formulas instanceof Array) {\r\n opts.formulas[0] !== undefined ? this.formula1 = opts.formulas[0] : null;\r\n opts.formulas[1] !== undefined ? this.formula2 = opts.formulas[1] : null;\r\n }\r\n\r\n if (opts.allowBlank !== undefined) {\r\n if (parseInt(opts.allowBlank) === 1) {\r\n opts.allowBlank = true;\r\n }\r\n if (parseInt(opts.allowBlank) === 0) {\r\n opts.allowBlank = false;\r\n }\r\n if (typeof opts.allowBlank !== 'boolean') {\r\n throw new TypeError('DataValidation allowBlank must be true, false, 1 or 0');\r\n }\r\n this.allowBlank = opts.allowBlank; \r\n }\r\n\r\n if (opts.errorStyle !== undefined) {\r\n let enums = ['stop', 'warning', 'information'];\r\n if (enums.indexOf(opts.errorStyle) < 0) {\r\n throw new TypeError('DataValidation errorStyle must be one of ' + enums.join(', '));\r\n }\r\n this.errorStyle = opts.errorStyle;\r\n }\r\n\r\n if (opts.error !== undefined) {\r\n if (typeof opts.error !== 'string') {\r\n throw new TypeError('DataValidation error must be a string');\r\n }\r\n this.error = opts.error;\r\n this.showErrorMessage = opts.showErrorMessage = true;\r\n }\r\n\r\n if (opts.errorTitle !== undefined) {\r\n if (typeof opts.errorTitle !== 'string') {\r\n throw new TypeError('DataValidation errorTitle must be a string');\r\n }\r\n this.errorTitle = opts.errorTitle;\r\n this.showErrorMessage = opts.showErrorMessage = true;\r\n }\r\n\r\n if (opts.imeMode !== undefined) {\r\n let enums = ['noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul'];\r\n if (enums.indexOf(opts.imeMode) < 0) {\r\n throw new TypeError('DataValidation imeMode must be one of ' + enums.join(', '));\r\n }\r\n this.imeMode = opts.imeMode;\r\n }\r\n \r\n if (opts.operator !== undefined) {\r\n let enums = ['between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual'];\r\n if (enums.indexOf(opts.operator) < 0) {\r\n throw new TypeError('DataValidation operator must be one of ' + enums.join(', '));\r\n }\r\n this.operator = opts.operator;\r\n }\r\n\r\n if (opts.prompt !== undefined) {\r\n if (typeof opts.prompt !== 'string') {\r\n throw new TypeError('DataValidation prompt must be a string');\r\n }\r\n this.prompt = opts.prompt;\r\n this.showInputMessage = opts.showInputMessage = true;\r\n }\r\n\r\n if (opts.promptTitle !== undefined) {\r\n if (typeof opts.promptTitle !== 'string') {\r\n throw new TypeError('DataValidation promptTitle must be a string');\r\n }\r\n this.promptTitle = opts.promptTitle;\r\n this.showInputMessage = opts.showInputMessage = true;\r\n }\r\n\r\n if (opts.showDropDown !== undefined) {\r\n if (parseInt(opts.showDropDown) === 1) {\r\n opts.showDropDown = true;\r\n }\r\n if (parseInt(opts.showDropDown) === 0) {\r\n opts.showDropDown = false;\r\n }\r\n if (typeof opts.showDropDown !== 'boolean') {\r\n throw new TypeError('DataValidation showDropDown must be true, false, 1 or 0');\r\n }\r\n this.showDropDown = opts.showDropDown;\r\n }\r\n\r\n if (opts.showErrorMessage !== undefined) {\r\n if (parseInt(opts.showErrorMessage) === 1) {\r\n opts.showErrorMessage = true;\r\n }\r\n if (parseInt(opts.showErrorMessage) === 0) {\r\n opts.showErrorMessage = false;\r\n }\r\n if (typeof opts.showErrorMessage !== 'boolean') {\r\n throw new TypeError('DataValidation showErrorMessage must be true, false, 1 or 0');\r\n }\r\n this.showErrorMessage = opts.showErrorMessage;\r\n }\r\n\r\n if (opts.showInputMessage !== undefined) {\r\n if (parseInt(opts.showInputMessage) === 1) {\r\n opts.showInputMessage = true;\r\n }\r\n if (parseInt(opts.showInputMessage) === 0) {\r\n opts.showInputMessage = false;\r\n }\r\n if (typeof opts.showInputMessage !== 'boolean') {\r\n throw new TypeError('DataValidation showInputMessage must be true, false, 1 or 0');\r\n }\r\n this.showInputMessage = opts.showInputMessage;\r\n }\r\n\r\n if (opts.type !== undefined) {\r\n let enums = ['none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom'];\r\n if (enums.indexOf(opts.type) < 0) {\r\n throw new TypeError('DataValidation type must be one of ' + enums.join(', '));\r\n }\r\n this.type = opts.type;\r\n }\r\n }\r\n\r\n addToXMLele(ele) {\r\n let valEle = ele.ele('dataValidation');\r\n this.type !== undefined ? valEle.att('type', this.type) : null;\r\n this.errorStyle !== undefined ? valEle.att('errorStyle', this.errorStyle) : null;\r\n this.imeMode !== undefined ? valEle.att('imeMode', this.imeMode) : null;\r\n this.operator !== undefined ? valEle.att('operator', this.operator) : null;\r\n this.allowBlank !== undefined ? valEle.att('allowBlank', myUtils.boolToInt(this.allowBlank)) : null;\r\n this.showDropDown === false ? valEle.att('showDropDown', 1) : null; // For some reason, the Excel app sets this property to true if the \"In-cell dropdown\" option is selected in the data validation screen.\r\n this.showInputMessage !== undefined ? valEle.att('showInputMessage', myUtils.boolToInt(this.showInputMessage)) : null;\r\n this.showErrorMessage !== undefined ? valEle.att('showErrorMessage', myUtils.boolToInt(this.showErrorMessage)) : null;\r\n this.errorTitle !== undefined ? valEle.att('errorTitle', this.errorTitle) : null;\r\n this.error !== undefined ? valEle.att('error', this.error) : null;\r\n this.promptTitle !== undefined ? valEle.att('promptTitle', this.promptTitle) : null;\r\n this.prompt !== undefined ? valEle.att('prompt', this.prompt) : null;\r\n this.sqref !== undefined ? valEle.att('sqref', this.sqref) : null;\r\n if (this.formula1 !== undefined) {\r\n valEle.ele('formula1').text(cleanFormula(this.formula1));\r\n valEle.up();\r\n if (this.formula2 !== undefined) {\r\n valEle.ele('formula2').text(cleanFormula(this.formula2));\r\n valEle.up();\r\n }\r\n }\r\n valEle.up();\r\n }\r\n}\r\n\r\nclass DataValidationCollection { // §18.3.1.33 dataValidations (Data Validations)\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n this.items = [];\r\n }\r\n\r\n get length() {\r\n return this.items.length;\r\n }\r\n\r\n add(opts) {\r\n let thisValidation = new DataValidation(opts);\r\n this.items.push(thisValidation);\r\n return thisValidation;\r\n }\r\n\r\n addToXMLele(ele) {\r\n let valsEle = ele.ele('dataValidations').att('count', this.length);\r\n this.items.forEach((val) => {\r\n val.addToXMLele(valsEle);\r\n });\r\n valsEle.up();\r\n }\r\n}\r\n\r\nmodule.exports = { DataValidationCollection, DataValidation };\r\n"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/classes/hyperlink.js b/distribution/lib/worksheet/classes/hyperlink.js new file mode 100644 index 00000000..dfb7cac8 --- /dev/null +++ b/distribution/lib/worksheet/classes/hyperlink.js @@ -0,0 +1,100 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Hyperlink = function () { + //§18.3.1.47 hyperlink (Hyperlink) + function Hyperlink(opts) { + _classCallCheck(this, Hyperlink); + + opts = opts ? opts : {}; + + if (opts.ref === undefined) { + throw new TypeError('ref is a required option when creating a hyperlink'); + } + this.ref = opts.ref; + + if (opts.display !== undefined) { + this.display = opts.display; + } else { + this.display = opts.location; + } + if (opts.location !== undefined) { + this.location = opts.location; + } + if (opts.tooltip !== undefined) { + this.tooltip = opts.tooltip; + } else { + this.tooltip = opts.location; + } + this.id; + } + + _createClass(Hyperlink, [{ + key: 'addToXMLEle', + value: function addToXMLEle(ele) { + var thisEle = ele.ele('hyperlink'); + thisEle.att('ref', this.ref); + thisEle.att('r:id', this.rId); + if (this.display !== undefined) { + thisEle.att('display', this.display); + } + if (this.location !== undefined) { + thisEle.att('address', this.location); + } + if (this.tooltip !== undefined) { + thisEle.att('tooltip', this.tooltip); + } + thisEle.up(); + } + }, { + key: 'rId', + get: function get() { + return 'rId' + this.id; + } + }]); + + return Hyperlink; +}(); + +var HyperlinkCollection = function () { + //§18.3.1.48 hyperlinks (Hyperlinks) + function HyperlinkCollection() { + _classCallCheck(this, HyperlinkCollection); + + this.links = []; + } + + _createClass(HyperlinkCollection, [{ + key: 'add', + value: function add(opts) { + var thisLink = new Hyperlink(opts); + thisLink.id = this.links.length + 1; + this.links.push(thisLink); + return thisLink; + } + }, { + key: 'addToXMLele', + value: function addToXMLele(ele) { + if (this.length > 0) { + var linksEle = ele.ele('hyperlinks'); + this.links.forEach(function (l) { + l.addToXMLEle(linksEle); + }); + linksEle.up(); + } + } + }, { + key: 'length', + get: function get() { + return this.links.length; + } + }]); + + return HyperlinkCollection; +}(); + +module.exports = { HyperlinkCollection: HyperlinkCollection, Hyperlink: Hyperlink }; +//# sourceMappingURL=hyperlink.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/classes/hyperlink.js.map b/distribution/lib/worksheet/classes/hyperlink.js.map new file mode 100644 index 00000000..bacd44d5 --- /dev/null +++ b/distribution/lib/worksheet/classes/hyperlink.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../../source/lib/worksheet/classes/hyperlink.js"],"names":["Hyperlink","opts","ref","undefined","TypeError","display","location","tooltip","id","ele","thisEle","att","rId","up","HyperlinkCollection","links","thisLink","length","push","linksEle","forEach","l","addToXMLEle","module","exports"],"mappings":";;;;;;I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,EAApB;AACH;;;;;;IAmBCM,mB;AAAsB;AACxB,mCAAc;AAAA;;AACV,aAAKC,KAAL,GAAa,EAAb;AACH;;;;4BAMGd,I,EAAM;AACN,gBAAIe,WAAW,IAAIhB,SAAJ,CAAcC,IAAd,CAAf;AACAe,qBAASR,EAAT,GAAc,KAAKO,KAAL,CAAWE,MAAX,GAAoB,CAAlC;AACA,iBAAKF,KAAL,CAAWG,IAAX,CAAgBF,QAAhB;AACA,mBAAOA,QAAP;AACH;;;oCAEWP,G,EAAK;AACb,gBAAI,KAAKQ,MAAL,GAAc,CAAlB,EAAqB;AACjB,oBAAIE,WAAWV,IAAIA,GAAJ,CAAQ,YAAR,CAAf;AACA,qBAAKM,KAAL,CAAWK,OAAX,CAAmB,UAACC,CAAD,EAAO;AACtBA,sBAAEC,WAAF,CAAcH,QAAd;AACH,iBAFD;AAGAA,yBAASN,EAAT;AACH;AACJ;;;4BAnBY;AACT,mBAAO,KAAKE,KAAL,CAAWE,MAAlB;AACH;;;;;;AAoBLM,OAAOC,OAAP,GAAiB,EAAEV,wCAAF,EAAuBd,oBAAvB,EAAjB","file":"hyperlink.js","sourcesContent":["\r\nclass Hyperlink { //§18.3.1.47 hyperlink (Hyperlink)\r\n constructor(opts) {\r\n opts = opts ? opts : {};\r\n \r\n if (opts.ref === undefined) {\r\n throw new TypeError('ref is a required option when creating a hyperlink');\r\n }\r\n this.ref = opts.ref;\r\n\r\n if (opts.display !== undefined) {\r\n this.display = opts.display;\r\n } else {\r\n this.display = opts.location;\r\n }\r\n if (opts.location !== undefined) {\r\n this.location = opts.location;\r\n }\r\n if (opts.tooltip !== undefined) {\r\n this.tooltip = opts.tooltip;\r\n } else {\r\n this.tooltip = opts.location;\r\n }\r\n this.id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this.id;\r\n }\r\n\r\n addToXMLEle(ele) {\r\n let thisEle = ele.ele('hyperlink');\r\n thisEle.att('ref', this.ref);\r\n thisEle.att('r:id', this.rId);\r\n if (this.display !== undefined) {\r\n thisEle.att('display', this.display);\r\n }\r\n if (this.location !== undefined) {\r\n thisEle.att('address', this.location);\r\n }\r\n if (this.tooltip !== undefined) {\r\n thisEle.att('tooltip', this.tooltip);\r\n }\r\n thisEle.up(); \r\n }\r\n}\r\n\r\nclass HyperlinkCollection { //§18.3.1.48 hyperlinks (Hyperlinks)\r\n constructor() {\r\n this.links = [];\r\n }\r\n\r\n get length() {\r\n return this.links.length;\r\n }\r\n\r\n add(opts) {\r\n let thisLink = new Hyperlink(opts);\r\n thisLink.id = this.links.length + 1;\r\n this.links.push(thisLink);\r\n return thisLink;\r\n }\r\n\r\n addToXMLele(ele) {\r\n if (this.length > 0) {\r\n let linksEle = ele.ele('hyperlinks');\r\n this.links.forEach((l) => {\r\n l.addToXMLEle(linksEle);\r\n });\r\n linksEle.up();\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = { HyperlinkCollection, Hyperlink };"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/index.js b/distribution/lib/worksheet/index.js new file mode 100644 index 00000000..c7e9e716 --- /dev/null +++ b/distribution/lib/worksheet/index.js @@ -0,0 +1,4 @@ +'use strict'; + +module.exports = require('./worksheet.js'); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/index.js.map b/distribution/lib/worksheet/index.js.map new file mode 100644 index 00000000..b2775c43 --- /dev/null +++ b/distribution/lib/worksheet/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/worksheet/index.js"],"names":["module","exports","require"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiBC,QAAQ,gBAAR,CAAjB","file":"index.js","sourcesContent":["module.exports = require('./worksheet.js');"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/optsValidator.js b/distribution/lib/worksheet/optsValidator.js new file mode 100644 index 00000000..bf2d3815 --- /dev/null +++ b/distribution/lib/worksheet/optsValidator.js @@ -0,0 +1,216 @@ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var types = require('../types/index.js'); + +var optsTypes = { + 'margins': { + 'bottom': 'Float', + 'footer': 'Float', + 'header': 'Float', + 'left': 'Float', + 'right': 'Float', + 'top': 'Float' + }, + 'printOptions': { + 'centerHorizontal': 'Boolean', + 'centerVertical': 'Boolean', + 'printGridLines': 'Boolean', + 'printHeadings': 'Boolean' + + }, + 'pageSetup': { + 'blackAndWhite': 'Boolean', + 'cellComments': 'CELL_COMMENTS', + 'copies': 'Integer', + 'draft': 'Boolean', + 'errors': 'PRINT_ERROR', + 'firstPageNumber': 'Boolean', + 'fitToHeight': 'Integer', + 'fitToWidth': 'Integer', + 'horizontalDpi': 'Integer', + 'orientation': 'ORIENTATION', + 'pageOrder': 'PAGE_ORDER', + 'paperHeight': 'POSITIVE_UNIVERSAL_MEASURE', + 'paperSize': 'PAPER_SIZE', + 'paperWidth': 'POSITIVE_UNIVERSAL_MEASURE', + 'scale': 'Integer', + 'useFirstPageNumber': 'Boolean', + 'usePrinterDefaults': 'Boolean', + 'verticalDpi': 'Integer' + }, + 'headerFooter': { + 'evenFooter': 'String', + 'evenHeader': 'String', + 'firstFooter': 'String', + 'firstHeader': 'String', + 'oddFooter': 'String', + 'oddHeader': 'String', + 'alignWithMargins': 'Boolean', + 'differentFirst': 'Boolean', + 'differentOddEven': 'Boolean', + 'scaleWithDoc': 'Boolean' + }, + 'sheetView': { + 'pane': { + 'activePane': 'PANE', + 'state': 'PANE_STATE', + 'topLeftCell': null, + 'xSplit': null, + 'ySplit': null + }, + 'tabSelected': null, + 'workbookViewId': null, + 'rightToLeft': null, + 'showGridLines': null, + 'zoomScale': null, + 'zoomScaleNormal': null, + 'zoomScalePageLayoutView': null + }, + 'sheetFormat': { + 'baseColWidth': null, + 'customHeight': null, + 'defaultColWidth': null, + 'defaultRowHeight': null, + 'outlineLevelCol': null, + 'outlineLevelRow': null, + 'thickBottom': null, + 'thickTop': null, + 'zeroHeight': null + }, + 'sheetProtection': { + 'autoFilter': null, + 'deleteColumns': null, + 'deleteRow': null, + 'formatCells': null, + 'formatColumns': null, + 'formatRows': null, + 'hashValue': null, + 'insertColumns': null, + 'insertHyperlinks': null, + 'insertRows': null, + 'objects': null, + 'password': null, + 'pivotTables': null, + 'scenarios': null, + 'selectLockedCells': null, + 'selectUnlockedCell': null, + 'sheet': null, + 'sort': null + }, + 'outline': { + 'summaryBelow': null + }, + 'autoFilter': { + 'startRow': null, + 'endRow': null, + 'startCol': null, + 'endCol': null, + 'filters': null + }, + 'hidden': 'Boolean' +}; + +var getObjItem = function getObjItem(obj, key) { + var returnObj = obj; + var levels = key.split('.'); + + while (levels.length > 0) { + var thisLevelKey = levels.shift(); + try { + returnObj = returnObj[thisLevelKey]; + } catch (e) { + //returnObj = undefined; + } + } + return returnObj; +}; + +var validator = function validator(key, val, type) { + switch (type) { + + case 'PAPER_SIZE': + var sizes = Object.keys(types.paperSize); + if (sizes.indexOf(val) < 0) { + throw new TypeError('Invalid value for ' + key + '. Value must be one of ' + sizes.join(', ')); + } + break; + + case 'PAGE_ORDER': + types.pageOrder.validate(val); + break; + + case 'ORIENTATION': + types.orientation.validate(val); + break; + + case 'POSITIVE_UNIVERSAL_MEASURE': + types.positiveUniversalMeasure.validate(val); + break; + + case 'CELL_COMMENTS': + types.cellComment.validate(val); + break; + + case 'PRINT_ERROR': + types.printError.validate(val); + break; + + case 'PANE': + types.pane.validate(val); + break; + + case 'PANE_STATE': + types.paneState.validate(val); + break; + + case 'Boolean': + if ([true, false, 1, 0].indexOf(val) < 0) { + throw new TypeError(key + ' expects value of true, false, 1 or 0'); + } + break; + + case 'Float': + if (parseFloat(val) !== val) { + throw new TypeError(key + ' expects value as a Float number'); + } + break; + + case 'Integer': + if (parseInt(val) !== val) { + throw new TypeError(key + ' expects value as an Integer'); + } + break; + + case 'String': + if (typeof val !== 'string') { + throw new TypeError(key + ' expects value as a String'); + } + break; + + default: + break; + } +}; + +var traverse = function traverse(o, keyParts, func) { + for (var i in o) { + var thisKeyParts = keyParts.concat(i); + var thisKey = thisKeyParts.join('.'); + var thisType = getObjItem(optsTypes, thisKey); + + if (typeof thisType === 'string') { + var thisItem = o[i]; + func(thisKey, thisItem, thisType); + } + if (o[i] !== null && _typeof(o[i]) === 'object') { + traverse(o[i], thisKeyParts, func); + } + } +}; + +module.exports = function (opts) { + traverse(opts, [], validator); +}; +//# sourceMappingURL=optsValidator.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/optsValidator.js.map b/distribution/lib/worksheet/optsValidator.js.map new file mode 100644 index 00000000..3295c43b --- /dev/null +++ b/distribution/lib/worksheet/optsValidator.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/worksheet/optsValidator.js"],"names":["types","require","optsTypes","getObjItem","obj","key","returnObj","levels","split","length","thisLevelKey","shift","e","validator","val","type","sizes","Object","keys","paperSize","indexOf","TypeError","join","pageOrder","validate","orientation","positiveUniversalMeasure","cellComment","printError","pane","paneState","parseFloat","parseInt","traverse","o","keyParts","func","i","thisKeyParts","concat","thisKey","thisType","thisItem","module","exports","opts"],"mappings":";;;;AAAA,IAAMA,QAAQC,QAAQ,mBAAR,CAAd;;AAEA,IAAMC,YAAY;AACd,eAAW;AACP,kBAAU,OADH;AAEP,kBAAU,OAFH;AAGP,kBAAU,OAHH;AAIP,gBAAQ,OAJD;AAKP,iBAAS,OALF;AAMP,eAAO;AANA,KADG;AASd,oBAAgB;AACZ,4BAAoB,SADR;AAEZ,0BAAkB,SAFN;AAGZ,0BAAkB,SAHN;AAIZ,yBAAiB;;AAJL,KATF;AAgBd,iBAAa;AACT,yBAAiB,SADR;AAET,wBAAgB,eAFP;AAGT,kBAAU,SAHD;AAIT,iBAAS,SAJA;AAKT,kBAAU,aALD;AAMT,2BAAmB,SANV;AAOT,uBAAe,SAPN;AAQT,sBAAc,SARL;AAST,yBAAiB,SATR;AA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9B,gBAAIC,WAAWR,EAAEG,CAAF,CAAf;AACAD,iBAAKI,OAAL,EAAcE,QAAd,EAAwBD,QAAxB;AACH;AACD,YAAIP,EAAEG,CAAF,MAAS,IAAT,IAAiB,QAAOH,EAAEG,CAAF,CAAP,MAAgB,QAArC,EAA+C;AAC3CJ,qBAASC,EAAEG,CAAF,CAAT,EAAeC,YAAf,EAA6BF,IAA7B;AACH;AACJ;AACJ,CAdD;;AAgBAO,OAAOC,OAAP,GAAiB,UAACC,IAAD,EAAU;AACvBZ,aAASY,IAAT,EAAe,EAAf,EAAmBhC,SAAnB;AACH,CAFD","file":"optsValidator.js","sourcesContent":["const types = require('../types/index.js');\r\n\r\nconst optsTypes = {\r\n 'margins': {\r\n 'bottom': 'Float',\r\n 'footer': 'Float',\r\n 'header': 'Float',\r\n 'left': 'Float',\r\n 'right': 'Float',\r\n 'top': 'Float'\r\n },\r\n 'printOptions': {\r\n 'centerHorizontal': 'Boolean',\r\n 'centerVertical': 'Boolean',\r\n 'printGridLines': 'Boolean',\r\n 'printHeadings': 'Boolean'\r\n \r\n },\r\n 'pageSetup': {\r\n 'blackAndWhite': 'Boolean',\r\n 'cellComments': 'CELL_COMMENTS',\r\n 'copies': 'Integer',\r\n 'draft': 'Boolean',\r\n 'errors': 'PRINT_ERROR',\r\n 'firstPageNumber': 'Boolean',\r\n 'fitToHeight': 'Integer',\r\n 'fitToWidth': 'Integer',\r\n 'horizontalDpi': 'Integer',\r\n 'orientation': 'ORIENTATION',\r\n 'pageOrder': 'PAGE_ORDER',\r\n 'paperHeight': 'POSITIVE_UNIVERSAL_MEASURE',\r\n 'paperSize': 'PAPER_SIZE',\r\n 'paperWidth': 'POSITIVE_UNIVERSAL_MEASURE',\r\n 'scale': 'Integer',\r\n 'useFirstPageNumber': 'Boolean',\r\n 'usePrinterDefaults': 'Boolean',\r\n 'verticalDpi': 'Integer'\r\n },\r\n 'headerFooter': {\r\n 'evenFooter': 'String',\r\n 'evenHeader': 'String',\r\n 'firstFooter': 'String',\r\n 'firstHeader': 'String',\r\n 'oddFooter': 'String',\r\n 'oddHeader': 'String',\r\n 'alignWithMargins': 'Boolean',\r\n 'differentFirst': 'Boolean',\r\n 'differentOddEven': 'Boolean',\r\n 'scaleWithDoc': 'Boolean'\r\n },\r\n 'sheetView': {\r\n 'pane': {\r\n 'activePane': 'PANE',\r\n 'state': 'PANE_STATE',\r\n 'topLeftCell': null,\r\n 'xSplit': null,\r\n 'ySplit': null\r\n },\r\n 'tabSelected': null,\r\n 'workbookViewId': null,\r\n 'rightToLeft': null,\r\n 'showGridLines': null,\r\n 'zoomScale': null,\r\n 'zoomScaleNormal': null,\r\n 'zoomScalePageLayoutView': null\r\n },\r\n 'sheetFormat': {\r\n 'baseColWidth': null,\r\n 'customHeight': null,\r\n 'defaultColWidth': null,\r\n 'defaultRowHeight': null,\r\n 'outlineLevelCol': null,\r\n 'outlineLevelRow': null,\r\n 'thickBottom': null,\r\n 'thickTop': null,\r\n 'zeroHeight': null\r\n },\r\n 'sheetProtection': {\r\n 'autoFilter': null,\r\n 'deleteColumns': null,\r\n 'deleteRow': null,\r\n 'formatCells': null,\r\n 'formatColumns': null,\r\n 'formatRows': null,\r\n 'hashValue': null,\r\n 'insertColumns': null,\r\n 'insertHyperlinks': null,\r\n 'insertRows': null,\r\n 'objects': null,\r\n 'password': null,\r\n 'pivotTables': null,\r\n 'scenarios': null,\r\n 'selectLockedCells': null,\r\n 'selectUnlockedCell': null,\r\n 'sheet': null,\r\n 'sort': null\r\n },\r\n 'outline': {\r\n 'summaryBelow': null\r\n },\r\n 'autoFilter': {\r\n 'startRow': null,\r\n 'endRow': null,\r\n 'startCol': null,\r\n 'endCol': null,\r\n 'filters': null\r\n },\r\n 'hidden': 'Boolean'\r\n};\r\n\r\nlet getObjItem = (obj, key) => {\r\n let returnObj = obj;\r\n let levels = key.split('.');\r\n\r\n while (levels.length > 0) {\r\n let thisLevelKey = levels.shift();\r\n try {\r\n returnObj = returnObj[thisLevelKey];\r\n } catch (e) {\r\n //returnObj = undefined;\r\n }\r\n }\r\n return returnObj;\r\n};\r\n\r\nlet validator = function (key, val, type) {\r\n switch (type) {\r\n\r\n case 'PAPER_SIZE': \r\n let sizes = Object.keys(types.paperSize);\r\n if (sizes.indexOf(val) < 0) {\r\n throw new TypeError('Invalid value for ' + key + '. Value must be one of ' + sizes.join(', '));\r\n }\r\n break;\r\n\r\n case 'PAGE_ORDER':\r\n types.pageOrder.validate(val);\r\n break;\r\n\r\n case 'ORIENTATION':\r\n types.orientation.validate(val);\r\n break;\r\n\r\n case 'POSITIVE_UNIVERSAL_MEASURE': \r\n types.positiveUniversalMeasure.validate(val);\r\n break;\r\n\r\n case 'CELL_COMMENTS':\r\n types.cellComment.validate(val);\r\n break;\r\n\r\n case 'PRINT_ERROR': \r\n types.printError.validate(val);\r\n break;\r\n\r\n case 'PANE':\r\n types.pane.validate(val);\r\n break;\r\n\r\n case 'PANE_STATE':\r\n types.paneState.validate(val);\r\n break;\r\n\r\n case 'Boolean':\r\n if ([true, false, 1, 0].indexOf(val) < 0) {\r\n throw new TypeError(key + ' expects value of true, false, 1 or 0');\r\n }\r\n break;\r\n\r\n case 'Float': \r\n if (parseFloat(val) !== val) {\r\n throw new TypeError(key + ' expects value as a Float number');\r\n }\r\n break;\r\n\r\n case 'Integer':\r\n if (parseInt(val) !== val) {\r\n throw new TypeError(key + ' expects value as an Integer');\r\n }\r\n break;\r\n\r\n case 'String': \r\n if (typeof val !== 'string') {\r\n throw new TypeError(key + ' expects value as a String');\r\n }\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n};\r\n\r\nlet traverse = function (o, keyParts, func) {\r\n for (let i in o) {\r\n let thisKeyParts = keyParts.concat(i);\r\n let thisKey = thisKeyParts.join('.');\r\n let thisType = getObjItem(optsTypes, thisKey);\r\n\r\n if (typeof thisType === 'string') {\r\n let thisItem = o[i];\r\n func(thisKey, thisItem, thisType); \r\n }\r\n if (o[i] !== null && typeof o[i] === 'object') {\r\n traverse(o[i], thisKeyParts, func);\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = (opts) => {\r\n traverse(opts, [], validator);\r\n};"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/sheet_default_params.js b/distribution/lib/worksheet/sheet_default_params.js new file mode 100644 index 00000000..da091def --- /dev/null +++ b/distribution/lib/worksheet/sheet_default_params.js @@ -0,0 +1,113 @@ +'use strict'; + +module.exports = { + 'margins': { + 'bottom': 0.75, + 'footer': 0.3, + 'header': 0.3, + 'left': 0.7, + 'right': 0.7, + 'top': 0.75 + }, + 'printOptions': { + 'centerHorizontal': null, + 'centerVertical': null, + 'printGridLines': null, + 'printHeadings': null + + }, + 'headerFooter': { + 'evenFooter': null, + 'evenHeader': null, + 'firstFooter': null, + 'firstHeader': null, + 'oddFooter': null, + 'oddHeader': null, + 'alignWithMargins': null, + 'differentFirst': null, + 'differentOddEven': null, + 'scaleWithDoc': null + }, + 'pageSetup': { + 'blackAndWhite': null, + 'cellComments': null, + 'copies': null, + 'draft': null, + 'errors': null, + 'firstPageNumber': null, + 'fitToHeight': null, + 'fitToWidth': null, + 'horizontalDpi': null, + 'orientation': null, + 'pageOrder': null, + 'paperHeight': null, + 'paperSize': null, + 'paperWidth': null, + 'scale': null, + 'useFirstPageNumber': null, + 'usePrinterDefaults': null, + 'verticalDpi': null + }, + 'sheetView': { + 'pane': { + 'activePane': null, + 'state': null, + 'topLeftCell': null, + 'xSplit': null, + 'ySplit': null + }, + 'tabSelected': 0, + 'workbookViewId': 0, + 'rightToLeft': 0, + 'showGridLines': 1, + 'zoomScale': 100, + 'zoomScaleNormal': 100, + 'zoomScalePageLayoutView': 100 + }, + 'sheetFormat': { + 'baseColWidth': 10, + 'customHeight': null, + 'defaultColWidth': null, + 'defaultRowHeight': null, + 'outlineLevelCol': null, + 'outlineLevelRow': null, + 'thickBottom': null, + 'thickTop': null, + 'zeroHeight': null + }, + 'sheetProtection': { // same as "Protect Sheet" in Review tab of Excel + 'autoFilter': null, + 'deleteColumns': null, + 'deleteRows': null, + 'formatCells': null, + 'formatColumns': null, + 'formatRows': null, + 'hashValue': null, + 'insertColumns': null, + 'insertHyperlinks': null, + 'insertRows': null, + 'objects': null, + 'password': null, + 'pivotTables': null, + 'scenarios': null, + 'selectLockedCells': null, + 'selectUnlockedCells': null, + 'sheet': null, + 'sort': null + }, + 'outline': { + 'summaryBelow': null, + 'summaryRight': null + }, + 'autoFilter': { + 'startRow': null, + 'endRow': null, + 'startCol': null, + 'endCol': null, + 'ref': null, + 'filters': [] + }, + 'disableRowSpansOptimization': false, + 'hidden': false +}; +//# sourceMappingURL=sheet_default_params.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/sheet_default_params.js.map b/distribution/lib/worksheet/sheet_default_params.js.map new file mode 100644 index 00000000..0bfa94ef --- /dev/null +++ b/distribution/lib/worksheet/sheet_default_params.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/worksheet/sheet_default_params.js"],"names":["module","exports"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB;AACb,eAAW;AACP,kBAAU,IADH;AAEP,kBAAU,GAFH;AAGP,kBAAU,GAHH;AAIP,gBAAQ,GAJD;AAKP,iBAAS,GALF;AAMP,eAAO;AANA,KADE;AASb,oBAAgB;AACZ,4BAAoB,IADR;AAEZ,0BAAkB,IAFN;AAGZ,0BAAkB,IAHN;AAIZ,yBAAiB;;AAJL,KATH;AAgBb,oBAAgB;AACZ,sBAAc,IADF;AAEZ,sBAAc,IAFF;AAGZ,uBAAe,IAHH;AAIZ,uBAAe,IAJH;AAKZ,qBAAa,IALD;AAMZ,qBAAa,IAND;AAOZ,4BAAoB,IAPR;AAQZ,0BAAkB,IARN;AASZ,4BAAoB,IATR;AAUZ,wBAAgB;AAVJ,KAhBH;AA4Bb,iBAAa;AACT,yBAAiB,IADR;AAET,wBAAgB,IAFP;AAGT,kBAAU,IAHD;AAIT,iBAAS,IAJA;AAKT,kBAAU,IALD;AAMT,2BAAmB,IANV;AAOT,u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,kBAAU,IAJA;AAKV,eAAO,IALG;AAMV,mBAAW;AAND,KAnGD;AA2Gb,mCAA+B,KA3GlB;AA4Gb,cAAU;AA5GG,CAAjB","file":"sheet_default_params.js","sourcesContent":["module.exports = {\r\n 'margins': {\r\n 'bottom': 0.75,\r\n 'footer': 0.3,\r\n 'header': 0.3,\r\n 'left': 0.7,\r\n 'right': 0.7,\r\n 'top': 0.75\r\n },\r\n 'printOptions': {\r\n 'centerHorizontal': null,\r\n 'centerVertical': null,\r\n 'printGridLines': null,\r\n 'printHeadings': null\r\n \r\n },\r\n 'headerFooter': {\r\n 'evenFooter': null,\r\n 'evenHeader': null,\r\n 'firstFooter': null,\r\n 'firstHeader': null,\r\n 'oddFooter': null,\r\n 'oddHeader': null,\r\n 'alignWithMargins': null,\r\n 'differentFirst': null,\r\n 'differentOddEven': null,\r\n 'scaleWithDoc': null\r\n },\r\n 'pageSetup': {\r\n 'blackAndWhite': null,\r\n 'cellComments': null,\r\n 'copies': null,\r\n 'draft': null,\r\n 'errors': null,\r\n 'firstPageNumber': null,\r\n 'fitToHeight': null,\r\n 'fitToWidth': null,\r\n 'horizontalDpi': null,\r\n 'orientation': null,\r\n 'pageOrder': null,\r\n 'paperHeight': null,\r\n 'paperSize': null,\r\n 'paperWidth': null,\r\n 'scale': null,\r\n 'useFirstPageNumber': null,\r\n 'usePrinterDefaults': null,\r\n 'verticalDpi': null\r\n },\r\n 'sheetView': {\r\n 'pane': {\r\n 'activePane': null,\r\n 'state': null,\r\n 'topLeftCell': null,\r\n 'xSplit': null,\r\n 'ySplit': null\r\n },\r\n 'tabSelected': 0,\r\n 'workbookViewId': 0,\r\n 'rightToLeft': 0,\r\n 'showGridLines': 1,\r\n 'zoomScale': 100,\r\n 'zoomScaleNormal': 100,\r\n 'zoomScalePageLayoutView': 100\r\n },\r\n 'sheetFormat': {\r\n 'baseColWidth': 10,\r\n 'customHeight': null,\r\n 'defaultColWidth': null,\r\n 'defaultRowHeight': null,\r\n 'outlineLevelCol': null,\r\n 'outlineLevelRow': null,\r\n 'thickBottom': null,\r\n 'thickTop': null,\r\n 'zeroHeight': null\r\n },\r\n 'sheetProtection': { // same as \"Protect Sheet\" in Review tab of Excel \r\n 'autoFilter': null,\r\n 'deleteColumns': null,\r\n 'deleteRows': null,\r\n 'formatCells': null,\r\n 'formatColumns': null,\r\n 'formatRows': null,\r\n 'hashValue': null,\r\n 'insertColumns': null,\r\n 'insertHyperlinks': null,\r\n 'insertRows': null,\r\n 'objects': null,\r\n 'password': null,\r\n 'pivotTables': null,\r\n 'scenarios': null,\r\n 'selectLockedCells': null,\r\n 'selectUnlockedCells': null,\r\n 'sheet': null,\r\n 'sort': null\r\n },\r\n 'outline': {\r\n 'summaryBelow': null,\r\n 'summaryRight': null\r\n },\r\n 'autoFilter': {\r\n 'startRow': null,\r\n 'endRow': null,\r\n 'startCol': null,\r\n 'endCol': null,\r\n 'ref': null,\r\n 'filters': []\r\n },\r\n 'disableRowSpansOptimization': false,\r\n 'hidden': false,\r\n};"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/worksheet.js b/distribution/lib/worksheet/worksheet.js new file mode 100644 index 00000000..9fe80bd0 --- /dev/null +++ b/distribution/lib/worksheet/worksheet.js @@ -0,0 +1,383 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var deepmerge = require('deepmerge'); +var CfRulesCollection = require('./cf/cf_rules_collection'); +var cellAccessor = require('../cell'); +var rowAccessor = require('../row'); +var colAccessor = require('../column'); +var wsDefaultParams = require('./sheet_default_params.js'); +var HyperlinkCollection = require('./classes/hyperlink.js').HyperlinkCollection; +var DataValidation = require('./classes/dataValidation.js'); +var wsDrawing = require('../drawing/index.js'); +var xmlBuilder = require('./builder.js'); +var optsValidator = require('./optsValidator.js'); + +var Worksheet = function () { + /** + * Create a Worksheet. + * @class Worksheet + * @param {Workbook} wb Workbook that the Worksheet will belong to + * @param {String} name Name of Worksheet + * @param {Object} opts Worksheet settings + * @param {Object} opts.margins + * @param {Number} opts.margins.bottom Bottom margin in inches + * @param {Number} opts.margins.footer Footer margin in inches + * @param {Number} opts.margins.header Header margin in inches + * @param {Number} opts.margins.left Left margin in inches + * @param {Number} opts.margins.right Right margin in inches + * @param {Number} opts.margins.top Top margin in inches + * @param {Object} opts.printOptions Print Options object + * @param {Boolean} opts.printOptions.centerHorizontal Should data be centered horizontally when printed + * @param {Boolean} opts.printOptions.centerVertical Should data be centered vertically when printed + * @param {Boolean} opts.printOptions.printGridLines Should gridlines by printed + * @param {Boolean} opts.printOptions.printHeadings Should Heading be printed + * @param {String} opts.headerFooter Set Header and Footer strings and options. + * @param {String} opts.headerFooter.evenFooter Even footer text + * @param {String} opts.headerFooter.evenHeader Even header text + * @param {String} opts.headerFooter.firstFooter First footer text + * @param {String} opts.headerFooter.firstHeader First header text + * @param {String} opts.headerFooter.oddFooter Odd footer text + * @param {String} opts.headerFooter.oddHeader Odd header text + * @param {Boolean} opts.headerFooter.alignWithMargins Should header/footer align with margins + * @param {Boolean} opts.headerFooter.differentFirst Should header/footer show a different header/footer on first page + * @param {Boolean} opts.headerFooter.differentOddEven Should header/footer show a different header/footer on odd and even pages + * @param {Boolean} opts.headerFooter.scaleWithDoc Should header/footer scale when doc zoom is changed + * @param {Object} opts.pageSetup + * @param {Boolean} opts.pageSetup.blackAndWhite + * @param {String} opts.pageSetup.cellComments one of 'none', 'asDisplayed', 'atEnd' + * @param {Number} opts.pageSetup.copies How many copies to print + * @param {Boolean} opts.pageSetup.draft Should quality be draft + * @param {String} opts.pageSetup.errors One of 'displayed', 'blank', 'dash', 'NA' + * @param {Number} opts.pageSetup.firstPageNumber Should the page number of the first page be printed + * @param {Number} opts.pageSetup.fitToHeight Number of vertical pages to fit to + * @param {Number} opts.pageSetup.fitToWidth Number of horizontal pages to fit to + * @param {Number} opts.pageSetup.horizontalDpi + * @param {String} opts.pageSetup.orientation One of 'default', 'portrait', 'landscape' + * @param {String} opts.pageSetup.pageOrder One of 'downThenOver', 'overThenDown' + * @param {String} opts.pageSetup.paperHeight Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm' + * @param {String} opts.pageSetup.paperSize see lib/types/paperSize.js for all types and descriptions of types. setting paperSize overrides paperHeight and paperWidth settings + * @param {String} opts.pageSetup.paperWidth Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm' + * @param {Number} opts.pageSetup.scale zoom of worksheet + * @param {Boolean} opts.pageSetup.useFirstPageNumber + * @param {Boolean} opts.pageSetup.usePrinterDefaults + * @param {Number} opts.pageSetup.verticalDpi + * @param {Object} opts.sheetView + * @param {Object} opts.sheetView.pane + * @param {String} opts.sheetView.pane.activePane one of 'bottomLeft', 'bottomRight', 'topLeft', 'topRight' + * @param {String} opts.sheetView.pane.state ne of 'split', 'frozen', 'frozenSplit' + * @param {String} opts.sheetView.pane.topLeftCell Cell Reference i.e. 'A1' + * @param {String} opts.sheetView.pane.xSplit Horizontal position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of columns visible in the top pane. + * @param {String} opts.sheetView.pane.ySplit Vertical position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of rows visible in the left pane. + * @param {Boolean} opts.sheetView.rightToLeft Flag indicating whether the sheet is in 'right to left' display mode. When in this mode, Column A is on the far right, Column B ;is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format. + * @param {Boolean} opts.sheetView.showGridLines Flag indicating whether the sheet should have gridlines enabled or disabled during view. + * @param {Number} opts.sheetView.zoomScale Defaults to 100 + * @param {Number} opts.sheetView.zoomScaleNormal Defaults to 100 + * @param {Number} opts.sheetView.zoomScalePageLayoutView Defaults to 100 + * @param {Object} opts.sheetFormat + * @param {Number} opts.sheetFormat.baseColWidth Defaults to 10. Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters., + * @param {Number} opts.sheetFormat.defaultColWidth + * @param {Number} opts.sheetFormat.defaultRowHeight + * @param {Boolean} opts.sheetFormat.thickBottom 'True' if rows have a thick bottom border by default. + * @param {Boolean} opts.sheetFormat.thickTop 'True' if rows have a thick top border by default. + * @param {Object} opts.sheetProtection same as "Protect Sheet" in Review tab of Excel + * @param {Boolean} opts.sheetProtection.autoFilter True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.deleteColumns True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.deleteRows True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.formatCells True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.formatColumns True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.formatRows True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.insertColumns True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.insertHyperlinks True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.insertRows True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.objects True means that that user will be unable to modify this setting + * @param {String} opts.sheetProtection.password Password used to protect sheet + * @param {Boolean} opts.sheetProtection.pivotTables True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.scenarios True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.selectLockedCells True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.selectUnlockedCells True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.sheet True means that that user will be unable to modify this setting + * @param {Boolean} opts.sheetProtection.sort True means that that user will be unable to modify this setting + * @param {Object} opts.outline + * @param {Boolean} opts.outline.summaryBelow Flag indicating whether summary rows appear below detail in an outline, when applying an outline/grouping. + * @param {Boolean} opts.outline.summaryRight Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline/grouping. + * @param {Boolean} opts.disableRowSpansOptimization Flag indicated whether to not include a spans attribute to the row definition in the XML. helps with very large documents. + * @param {Boolean} opts.hidden Flag indicating whether to not hide the worksheet within the workbook. + * @returns {Worksheet} + */ + function Worksheet(wb, name) { + var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + _classCallCheck(this, Worksheet); + + this.wb = wb; + this.sheetId = this.wb.sheets.length + 1; + this.localSheetId = this.wb.sheets.length; + this.opts = deepmerge(wsDefaultParams, opts); + optsValidator(opts); + + this.name = name ? name : 'Sheet ' + this.sheetId; + this.hasGroupings = false; + this.cols = {}; // Columns keyed by column, contains column properties + this.rows = {}; // Rows keyed by row, contains row properties and array of cellRefs + this.cells = {}; // Cells keyed by Excel ref + this.mergedCells = []; + this.pageBreaks = { + row: [], + column: [] + }; + this.printArea = null; + this.lastUsedRow = 1; + this.lastUsedCol = 1; + + // conditional formatting rules hashed by sqref + this.cfRulesCollection = new CfRulesCollection(); + this.hyperlinkCollection = new HyperlinkCollection(); + this.dataValidationCollection = new DataValidation.DataValidationCollection(); + this.drawingCollection = new wsDrawing.DrawingCollection(); + this.legacyDrawingHeaderFooter = new wsDrawing.DrawingCollection(); + this.comments = {}; // Comments for cells keyed by excel ref + this.author = this.wb.author; + } + + _createClass(Worksheet, [{ + key: 'addConditionalFormattingRule', + + + /** + * @func Worksheet.addConditionalFormattingRule + * @param {String} sqref Text represetation of Cell range where the conditional formatting will take effect + * @param {Object} options Options for conditional formatting + * @param {String} options.type Type of conditional formatting + * @param {String} options.priority Priority level for this rule + * @param {String} options.formula Formula that returns nonzero or 0 value. If not 0 then rule will be applied + * @param {Style} options.style Style that should be applied if rule passes + * @returns {Worksheet} + */ + value: function addConditionalFormattingRule(sqref, options) { + var style = options.style || this.wb.Style(); + var dxf = this.wb.dxfCollection.add(style); + delete options.style; + options.dxfId = dxf.id; + this.cfRulesCollection.add(sqref, options); + return this; + } + /** + * @func Worksheet.addDataValidation + * @desc Add a data validation rule to the Worksheet + * @param {Object} opts Options for Data Validation rule + * @param {String} opts.sqref Required. Specifies range of cells to apply validate. i.e. "A1:A100" + * @param {Boolean} opts.allowBlank Allows cells to be empty + * @param {String} opts.errorStyle One of 'stop', 'warning', 'information'. You must specify an error string for this to take effect + * @param {String} opts.error Message to show on error + * @param {String} opts.errorTitle: String Title of message shown on error + * @param {Boolean} opts.showErrorMessage Defaults to true if error or errorTitle is set + * @param {String} opts.imeMode Restricts input to a specific set of characters. One of 'noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul' + * @param {String} opts.operator Must be one of 'between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual' + * @param {String} opts.prompt Message text of input prompt + * @param {String} opts.promptTitle Title of input prompt + * @param {Boolean} opts.showInputMessage Defaults to true if prompt or promptTitle is set + * @param {Boolean} opts.showDropDown A boolean value indicating whether to display a dropdown combo box for a list type data validation. + * @param {String} opts.type One of 'none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom' + * @param {Array.String} opts.formulas Minimum count 1, maximum count 2. Rules for validation + */ + + }, { + key: 'addDataValidation', + value: function addDataValidation(opts) { + var newValidation = this.dataValidationCollection.add(opts); + return newValidation; + } + /** + * @func Worksheet.generateRelsXML + * @desc When Workbook is being built, generate the XML that will go into the Worksheet .rels file + */ + + }, { + key: 'generateRelsXML', + value: function generateRelsXML() { + return xmlBuilder.relsXML(this); + } + }, { + key: 'generateCommentsXML', + value: function generateCommentsXML() { + if (Object.keys(this.comments).length === 0) { + return; + } + return xmlBuilder.commentsXML(this); + } + }, { + key: 'generateCommentsVmlXML', + value: function generateCommentsVmlXML() { + if (Object.keys(this.comments).length === 0) { + return; + } + return xmlBuilder.commentsVmlXML(this); + } + + /** + * @func Worksheet.generateXML + * @desc When Workbook is being built, generate the XML that will go into the Worksheet xml file + */ + + }, { + key: 'generateXML', + value: function generateXML() { + return xmlBuilder.sheetXML(this); + } + }, { + key: 'row', + value: function row(_row) { + return rowAccessor(this, _row); + } + }, { + key: 'column', + value: function column(col) { + return colAccessor(this, col); + } + /** + * @func Worksheet.addImage + * @param {Object} opts + * @param {String} opts.path File system path of image + * @param {Buffer} opts.image Buffer with image (against read file from opts.path) + * @param {String} opts.name Name of image + * @param {String} opts.type Type of image. Currently only 'picture' is supported + * @param {Object} opts.position Position object for image + * @param {String} opts.position.type Type of positional anchor to use. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor' + * @param {Object} opts.position.from Object containg position of top left corner of image. Used with oneCellAnchor and twoCellAchor types + * @param {Number} opts.position.from.col Left edge of image will align with left edge of this column + * @param {String} opts.position.from.colOff Offset from left edge of column + * @param {Number} opts.position.from.row Top edge of image will align with top edge of this row + * @param {String} opts.position.from.rowOff Offset from top edge of row + * @param {Object} opts.position.to Object containing position of bottom right corner of image + * @param {Number} opts.position.to.col Right edge of image will align with Left edge of this column + * @param {String} opts.position.to.colOff Offset of left edge of column + * @param {Number} opts.position.to.row Bottom edge of image will align with Top edge of this row + * @param {String} opts.position.to.rowOff Offset of top edge of row + * @param {String} opts.position.x X position of top left corner of image. Used with absoluteAchor type + * @param {String} opts.position.y Y position of top left corner of image + */ + + }, { + key: 'addImage', + value: function addImage(opts) { + opts = opts ? opts : {}; + var mediaID = this.wb.mediaCollection.add(opts.path || opts.image); + var newImage = this.drawingCollection.add(opts); + newImage.id = mediaID; + + return newImage; + } + + /** + * @func Worksheet.addPageBreak + * @param {string} type + * @param {number} position + * @returns {Worksheet} + */ + + }, { + key: 'addPageBreak', + value: function addPageBreak(type, position) { + if (type !== 'row' && type !== 'column' || typeof position !== 'number') { + this.wb.logger.warn('invalid option sent to addPageBreak method', type, position); + return; + } + if (this.pageBreaks[type].indexOf(position) < 0) { + this.pageBreaks[type].push(position); + } + return this; + } + + /** + * @method Worksheet.addPrintArea + * @param {number} startRow + * @param {number} startCol + * @param {number} endRow + * @param {number} endCol + * @returns {Worksheet} + */ + + }, { + key: 'setPrintArea', + value: function setPrintArea(startRow, startCol, endRow, endCol) { + if (typeof startRow !== 'number' || typeof startCol !== 'number' || typeof endRow !== 'number' || typeof endCol !== 'number') { + this.wb.logger.warn('invalid option sent to setPrintArea method'); + return; + } + this.printArea = { + startRow: startRow, + startCol: startCol, + endRow: endRow, + endCol: endCol + }; + return this; + } + + /** + * @func Worksheet.setHeaderFooterImage + * @param {Object} opts + * @param {String} opts.path File system path of image + * @param {Buffer} opts.image Buffer with image (against read file from opts.path) + * @param {String} opts.name Name of image + * @param {String} opts.type Type of image. Currently only 'picture' is supported + * @param {String} opts.position Position string for image: ['LF','CF', 'RF', 'LH', 'CH', 'RH'] + */ + + }, { + key: 'addHeaderFooterImage', + value: function addHeaderFooterImage(image, position) { + var headerFooterPositions = ['LF', 'CF', 'RF', 'LH', 'CH', 'RH']; + if (headerFooterPositions.indexOf(position) < 0) { + throw new Error('setHeaderFooterImage: Only allowed positions are LH, CH, RH, LF, CF, RF'); + } + if (image.type === 'picture') image.type = 'headerFooterPicture'; + var mediaId = this.wb.mediaCollection.add(image); + var ximg = this.legacyDrawingHeaderFooter.add(image); + ximg.position = position; + ximg.id = mediaId; + } + }, { + key: 'relationships', + get: function get() { + var rels = []; + if (!this.legacyDrawingHeaderFooter.isEmpty) { + rels.push('legacyDrawingHeaderFooter'); + } + this.hyperlinkCollection.links.forEach(function (l) { + rels.push(l); + }); + if (!this.drawingCollection.isEmpty) { + rels.push('drawing'); + } + if (Object.keys(this.comments).length > 0) { + rels.push('comments'); + rels.push('commentsVml'); + } + return rels; + } + }, { + key: 'columnCount', + get: function get() { + return Math.max.apply(Math, Object.keys(this.cols)); + } + }, { + key: 'rowCount', + get: function get() { + return Math.max.apply(Math, Object.keys(this.rows)); + } + }, { + key: 'cell', + get: function get() { + return cellAccessor.bind(this); + } + }]); + + return Worksheet; +}(); + +module.exports = Worksheet; +//# sourceMappingURL=worksheet.js.map \ No newline at end of file diff --git a/distribution/lib/worksheet/worksheet.js.map b/distribution/lib/worksheet/worksheet.js.map new file mode 100644 index 00000000..afb47bec --- /dev/null +++ b/distribution/lib/worksheet/worksheet.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/worksheet/worksheet.js"],"names":["deepmerge","require","CfRulesCollection","cellAccessor","rowAccessor","colAccessor","wsDefaultParams","HyperlinkCollection","DataValidation","wsDrawing","xmlBuilder","optsValidator","Worksheet","wb","name","opts","sheetId","sheets","length","localSheetId","hasGroupings","cols","rows","cells","mergedCells","pageBreaks","row","column","printArea","lastUsedRow","lastUsedCol","cfRulesCollection","hyperlinkCollection","dataValidationCollection","DataValidationCollection","drawingCollection","DrawingCollection","legacyDrawingHeaderFooter","comments","author","sqref","options","style","Style","dxf","dxfCollection","add","dxfId","id","newValidation","relsXML","Object","keys","commentsXML","commentsVmlXML","sheetXML","col","mediaID","mediaCollection","path","image","newImage","type","position","logger","warn","indexOf","push","startRow","startCol","endRow","endCol","headerFooterPositions","Error","mediaId","ximg","rels","isEmpty","links","forEach","l","Math","max","apply","bind","module","exports"],"mappings":";;;;;;AAAA,IAAMA,YAAYC,QAAQ,WAAR,CAAlB;AACA,IAAMC,oBAAoBD,QAAQ,0BAAR,CAA1B;AACA,IAAME,eAAeF,QAAQ,SAAR,CAArB;AACA,IAAMG,cAAcH,QAAQ,QAAR,CAApB;AACA,IAAMI,cAAcJ,QAAQ,WAAR,CAApB;AACA,IAAMK,kBAAkBL,QAAQ,2BAAR,CAAxB;AACA,IAAMM,sBAAsBN,QAAQ,wBAAR,EAAkCM,mBAA9D;AACA,IAAMC,iBAAiBP,QAAQ,6BAAR,CAAvB;AACA,IAAMQ,YAAYR,QAAQ,qBAA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,EAAqB9B,OAAOC,IAAP,CAAY,KAAK/B,IAAjB,CAArB,CAAP;AACH;;;4BAEc;AACX,mBAAO4D,KAAKC,GAAL,CAASC,KAAT,CAAeF,IAAf,EAAqB9B,OAAOC,IAAP,CAAY,KAAK9B,IAAjB,CAArB,CAAP;AACH;;;4BAyEU;AACP,mBAAOnB,aAAaiF,IAAb,CAAkB,IAAlB,CAAP;AACH;;;;;;AA0GLC,OAAOC,OAAP,GAAiB1E,SAAjB","file":"worksheet.js","sourcesContent":["const deepmerge = require('deepmerge');\r\nconst CfRulesCollection = require('./cf/cf_rules_collection');\r\nconst cellAccessor = require('../cell');\r\nconst rowAccessor = require('../row');\r\nconst colAccessor = require('../column');\r\nconst wsDefaultParams = require('./sheet_default_params.js');\r\nconst HyperlinkCollection = require('./classes/hyperlink.js').HyperlinkCollection;\r\nconst DataValidation = require('./classes/dataValidation.js');\r\nconst wsDrawing = require('../drawing/index.js');\r\nconst xmlBuilder = require('./builder.js');\r\nconst optsValidator = require('./optsValidator.js');\r\n\r\n\r\nclass Worksheet {\r\n /**\r\n * Create a Worksheet.\r\n * @class Worksheet\r\n * @param {Workbook} wb Workbook that the Worksheet will belong to\r\n * @param {String} name Name of Worksheet\r\n * @param {Object} opts Worksheet settings\r\n * @param {Object} opts.margins\r\n * @param {Number} opts.margins.bottom Bottom margin in inches\r\n * @param {Number} opts.margins.footer Footer margin in inches\r\n * @param {Number} opts.margins.header Header margin in inches\r\n * @param {Number} opts.margins.left Left margin in inches\r\n * @param {Number} opts.margins.right Right margin in inches\r\n * @param {Number} opts.margins.top Top margin in inches\r\n * @param {Object} opts.printOptions Print Options object\r\n * @param {Boolean} opts.printOptions.centerHorizontal Should data be centered horizontally when printed\r\n * @param {Boolean} opts.printOptions.centerVertical Should data be centered vertically when printed\r\n * @param {Boolean} opts.printOptions.printGridLines Should gridlines by printed\r\n * @param {Boolean} opts.printOptions.printHeadings Should Heading be printed\r\n * @param {String} opts.headerFooter Set Header and Footer strings and options. \r\n * @param {String} opts.headerFooter.evenFooter Even footer text\r\n * @param {String} opts.headerFooter.evenHeader Even header text\r\n * @param {String} opts.headerFooter.firstFooter First footer text\r\n * @param {String} opts.headerFooter.firstHeader First header text\r\n * @param {String} opts.headerFooter.oddFooter Odd footer text\r\n * @param {String} opts.headerFooter.oddHeader Odd header text\r\n * @param {Boolean} opts.headerFooter.alignWithMargins Should header/footer align with margins\r\n * @param {Boolean} opts.headerFooter.differentFirst Should header/footer show a different header/footer on first page\r\n * @param {Boolean} opts.headerFooter.differentOddEven Should header/footer show a different header/footer on odd and even pages\r\n * @param {Boolean} opts.headerFooter.scaleWithDoc Should header/footer scale when doc zoom is changed\r\n * @param {Object} opts.pageSetup\r\n * @param {Boolean} opts.pageSetup.blackAndWhite\r\n * @param {String} opts.pageSetup.cellComments one of 'none', 'asDisplayed', 'atEnd'\r\n * @param {Number} opts.pageSetup.copies How many copies to print\r\n * @param {Boolean} opts.pageSetup.draft Should quality be draft\r\n * @param {String} opts.pageSetup.errors One of 'displayed', 'blank', 'dash', 'NA'\r\n * @param {Number} opts.pageSetup.firstPageNumber Should the page number of the first page be printed\r\n * @param {Number} opts.pageSetup.fitToHeight Number of vertical pages to fit to\r\n * @param {Number} opts.pageSetup.fitToWidth Number of horizontal pages to fit to\r\n * @param {Number} opts.pageSetup.horizontalDpi \r\n * @param {String} opts.pageSetup.orientation One of 'default', 'portrait', 'landscape'\r\n * @param {String} opts.pageSetup.pageOrder One of 'downThenOver', 'overThenDown'\r\n * @param {String} opts.pageSetup.paperHeight Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {String} opts.pageSetup.paperSize see lib/types/paperSize.js for all types and descriptions of types. setting paperSize overrides paperHeight and paperWidth settings\r\n * @param {String} opts.pageSetup.paperWidth Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {Number} opts.pageSetup.scale zoom of worksheet\r\n * @param {Boolean} opts.pageSetup.useFirstPageNumber\r\n * @param {Boolean} opts.pageSetup.usePrinterDefaults\r\n * @param {Number} opts.pageSetup.verticalDpi \r\n * @param {Object} opts.sheetView \r\n * @param {Object} opts.sheetView.pane \r\n * @param {String} opts.sheetView.pane.activePane one of 'bottomLeft', 'bottomRight', 'topLeft', 'topRight'\r\n * @param {String} opts.sheetView.pane.state ne of 'split', 'frozen', 'frozenSplit'\r\n * @param {String} opts.sheetView.pane.topLeftCell Cell Reference i.e. 'A1'\r\n * @param {String} opts.sheetView.pane.xSplit Horizontal position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of columns visible in the top pane.\r\n * @param {String} opts.sheetView.pane.ySplit Vertical position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of rows visible in the left pane.\r\n * @param {Boolean} opts.sheetView.rightToLeft Flag indicating whether the sheet is in 'right to left' display mode. When in this mode, Column A is on the far right, Column B ;is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format.\r\n * @param {Boolean} opts.sheetView.showGridLines Flag indicating whether the sheet should have gridlines enabled or disabled during view.\r\n * @param {Number} opts.sheetView.zoomScale Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScaleNormal Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScalePageLayoutView Defaults to 100\r\n * @param {Object} opts.sheetFormat \r\n * @param {Number} opts.sheetFormat.baseColWidth Defaults to 10. Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.,\r\n * @param {Number} opts.sheetFormat.defaultColWidth\r\n * @param {Number} opts.sheetFormat.defaultRowHeight\r\n * @param {Boolean} opts.sheetFormat.thickBottom 'True' if rows have a thick bottom border by default.\r\n * @param {Boolean} opts.sheetFormat.thickTop 'True' if rows have a thick top border by default.\r\n * @param {Object} opts.sheetProtection same as \"Protect Sheet\" in Review tab of Excel \r\n * @param {Boolean} opts.sheetProtection.autoFilter True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertHyperlinks True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.objects True means that that user will be unable to modify this setting\r\n * @param {String} opts.sheetProtection.password Password used to protect sheet\r\n * @param {Boolean} opts.sheetProtection.pivotTables True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.scenarios True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectLockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectUnlockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sheet True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sort True means that that user will be unable to modify this setting\r\n * @param {Object} opts.outline \r\n * @param {Boolean} opts.outline.summaryBelow Flag indicating whether summary rows appear below detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.outline.summaryRight Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.disableRowSpansOptimization Flag indicated whether to not include a spans attribute to the row definition in the XML. helps with very large documents.\r\n * @param {Boolean} opts.hidden Flag indicating whether to not hide the worksheet within the workbook.\r\n * @returns {Worksheet}\r\n */\r\n constructor(wb, name, opts = {}) {\r\n\r\n this.wb = wb;\r\n this.sheetId = this.wb.sheets.length + 1;\r\n this.localSheetId = this.wb.sheets.length;\r\n this.opts = deepmerge(wsDefaultParams, opts);\r\n optsValidator(opts);\r\n \r\n this.name = name ? name : `Sheet ${this.sheetId}`;\r\n this.hasGroupings = false;\r\n this.cols = {}; // Columns keyed by column, contains column properties\r\n this.rows = {}; // Rows keyed by row, contains row properties and array of cellRefs\r\n this.cells = {}; // Cells keyed by Excel ref\r\n this.mergedCells = [];\r\n this.pageBreaks = {\r\n row: [],\r\n column: [],\r\n };\r\n this.printArea = null;\r\n this.lastUsedRow = 1;\r\n this.lastUsedCol = 1;\r\n\r\n // conditional formatting rules hashed by sqref\r\n this.cfRulesCollection = new CfRulesCollection();\r\n this.hyperlinkCollection = new HyperlinkCollection();\r\n this.dataValidationCollection = new DataValidation.DataValidationCollection();\r\n this.drawingCollection = new wsDrawing.DrawingCollection();\r\n this.legacyDrawingHeaderFooter = new wsDrawing.DrawingCollection();\r\n this.comments = {}; // Comments for cells keyed by excel ref\r\n this.author = this.wb.author;\r\n\r\n }\r\n\r\n get relationships() {\r\n let rels = [];\r\n if(!this.legacyDrawingHeaderFooter.isEmpty){\r\n rels.push('legacyDrawingHeaderFooter')\r\n }\r\n this.hyperlinkCollection.links.forEach((l) => {\r\n rels.push(l);\r\n });\r\n if (!this.drawingCollection.isEmpty) {\r\n rels.push('drawing');\r\n }\r\n if(Object.keys(this.comments).length > 0) {\r\n rels.push('comments');\r\n rels.push('commentsVml');\r\n }\r\n return rels;\r\n }\r\n\r\n get columnCount() {\r\n return Math.max.apply(Math, Object.keys(this.cols));\r\n }\r\n\r\n get rowCount() {\r\n return Math.max.apply(Math, Object.keys(this.rows));\r\n }\r\n\r\n /**\r\n * @func Worksheet.addConditionalFormattingRule\r\n * @param {String} sqref Text represetation of Cell range where the conditional formatting will take effect\r\n * @param {Object} options Options for conditional formatting\r\n * @param {String} options.type Type of conditional formatting\r\n * @param {String} options.priority Priority level for this rule\r\n * @param {String} options.formula Formula that returns nonzero or 0 value. If not 0 then rule will be applied\r\n * @param {Style} options.style Style that should be applied if rule passes\r\n * @returns {Worksheet}\r\n */\r\n addConditionalFormattingRule(sqref, options) {\r\n let style = options.style || this.wb.Style();\r\n let dxf = this.wb.dxfCollection.add(style);\r\n delete options.style;\r\n options.dxfId = dxf.id;\r\n this.cfRulesCollection.add(sqref, options);\r\n return this;\r\n }\r\n /**\r\n * @func Worksheet.addDataValidation\r\n * @desc Add a data validation rule to the Worksheet\r\n * @param {Object} opts Options for Data Validation rule\r\n * @param {String} opts.sqref Required. Specifies range of cells to apply validate. i.e. \"A1:A100\"\r\n * @param {Boolean} opts.allowBlank Allows cells to be empty\r\n * @param {String} opts.errorStyle One of 'stop', 'warning', 'information'. You must specify an error string for this to take effect\r\n * @param {String} opts.error Message to show on error\r\n * @param {String} opts.errorTitle: String Title of message shown on error\r\n * @param {Boolean} opts.showErrorMessage Defaults to true if error or errorTitle is set\r\n * @param {String} opts.imeMode Restricts input to a specific set of characters. One of 'noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul'\r\n * @param {String} opts.operator Must be one of 'between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual'\r\n * @param {String} opts.prompt Message text of input prompt\r\n * @param {String} opts.promptTitle Title of input prompt\r\n * @param {Boolean} opts.showInputMessage Defaults to true if prompt or promptTitle is set\r\n * @param {Boolean} opts.showDropDown A boolean value indicating whether to display a dropdown combo box for a list type data validation.\r\n * @param {String} opts.type One of 'none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom'\r\n * @param {Array.String} opts.formulas Minimum count 1, maximum count 2. Rules for validation\r\n */\r\n addDataValidation(opts) {\r\n let newValidation = this.dataValidationCollection.add(opts);\r\n return newValidation;\r\n }\r\n /**\r\n * @func Worksheet.generateRelsXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet .rels file\r\n */\r\n generateRelsXML() {\r\n return xmlBuilder.relsXML(this);\r\n }\r\n\r\n generateCommentsXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsXML(this);\r\n }\r\n\r\n generateCommentsVmlXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsVmlXML(this);\r\n }\r\n\r\n /**\r\n * @func Worksheet.generateXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet xml file \r\n */\r\n generateXML() {\r\n return xmlBuilder.sheetXML(this);\r\n }\r\n\r\n get cell() {\r\n return cellAccessor.bind(this);\r\n }\r\n\r\n row(row) {\r\n return rowAccessor(this, row);\r\n }\r\n\r\n column(col) {\r\n return colAccessor(this, col);\r\n }\r\n /**\r\n * @func Worksheet.addImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {Object} opts.position Position object for image\r\n * @param {String} opts.position.type Type of positional anchor to use. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor'\r\n * @param {Object} opts.position.from Object containg position of top left corner of image. Used with oneCellAnchor and twoCellAchor types\r\n * @param {Number} opts.position.from.col Left edge of image will align with left edge of this column\r\n * @param {String} opts.position.from.colOff Offset from left edge of column\r\n * @param {Number} opts.position.from.row Top edge of image will align with top edge of this row\r\n * @param {String} opts.position.from.rowOff Offset from top edge of row\r\n * @param {Object} opts.position.to Object containing position of bottom right corner of image\r\n * @param {Number} opts.position.to.col Right edge of image will align with Left edge of this column\r\n * @param {String} opts.position.to.colOff Offset of left edge of column\r\n * @param {Number} opts.position.to.row Bottom edge of image will align with Top edge of this row\r\n * @param {String} opts.position.to.rowOff Offset of top edge of row\r\n * @param {String} opts.position.x X position of top left corner of image. Used with absoluteAchor type\r\n * @param {String} opts.position.y Y position of top left corner of image\r\n */\r\n addImage(opts) {\r\n opts = opts ? opts : {};\r\n let mediaID = this.wb.mediaCollection.add(opts.path || opts.image);\r\n let newImage = this.drawingCollection.add(opts);\r\n newImage.id = mediaID;\r\n\r\n return newImage;\r\n }\r\n\r\n /**\r\n * @func Worksheet.addPageBreak\r\n * @param {string} type \r\n * @param {number} position \r\n * @returns {Worksheet}\r\n */\r\n addPageBreak(type, position) {\r\n if ((type !== 'row' && type !== 'column') || typeof position !== 'number') {\r\n this.wb.logger.warn('invalid option sent to addPageBreak method', type, position);\r\n return;\r\n }\r\n if (this.pageBreaks[type].indexOf(position) < 0) {\r\n this.pageBreaks[type].push(position);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @method Worksheet.addPrintArea\r\n * @param {number} startRow \r\n * @param {number} startCol \r\n * @param {number} endRow \r\n * @param {number} endCol \r\n * @returns {Worksheet}\r\n */\r\n setPrintArea(startRow, startCol, endRow, endCol) {\r\n if (\r\n typeof startRow !== 'number' ||\r\n typeof startCol !== 'number' ||\r\n typeof endRow !== 'number' ||\r\n typeof endCol !== 'number'\r\n ) {\r\n this.wb.logger.warn('invalid option sent to setPrintArea method');\r\n return;\r\n }\r\n this.printArea = {\r\n startRow,\r\n startCol,\r\n endRow,\r\n endCol,\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @func Worksheet.setHeaderFooterImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {String} opts.position Position string for image: ['LF','CF', 'RF', 'LH', 'CH', 'RH'] \r\n */\r\n addHeaderFooterImage(image, position){\r\n const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH'];\r\n if(headerFooterPositions.indexOf(position) < 0){\r\n throw new Error('setHeaderFooterImage: Only allowed positions are LH, CH, RH, LF, CF, RF');\r\n }\r\n if(image.type === 'picture') image.type = 'headerFooterPicture';\r\n var mediaId = this.wb.mediaCollection.add(image);\r\n var ximg = this.legacyDrawingHeaderFooter.add(image)\r\n ximg.position = position;\r\n ximg.id = mediaId;\r\n }\r\n}\r\n\r\nmodule.exports = Worksheet;"]} \ No newline at end of file From 7a416cf647dde5bdfa1345483b42f64d4c683b33 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 28 Dec 2020 13:29:50 +0300 Subject: [PATCH 06/12] trying again without prepublish script --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index d1eccd5f..2b117da4 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ "cover": "node nyc tape -r babel-register .\\tests/*.test.js", "build": "node ./node_modules/babel-cli/bin/babel.js source --presets babel-preset-env -s --out-dir distribution", "watch": "node ./node_modules/babel-cli/bin/babel.js source -w --presets babel-preset-env -s --out-dir distribution", - "document": "jsdoc ./source -r -d docs", - "prepublish": "npm run build && npm run test" + "document": "jsdoc ./source -r -d docs" }, "dependencies": { "deepmerge": "3.2.0", From de9f827dbd70955dbaa4d9d49bd7e8a99a94dcf5 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Tue, 29 Dec 2020 18:27:23 +0300 Subject: [PATCH 07/12] Remove the messages with my name --- distribution/lib/workbook/builder.js | 2 -- distribution/lib/workbook/builder.js.map | 2 +- source/lib/workbook/builder.js | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/distribution/lib/workbook/builder.js b/distribution/lib/workbook/builder.js index 7a77de95..290b5ae8 100644 --- a/distribution/lib/workbook/builder.js +++ b/distribution/lib/workbook/builder.js @@ -487,7 +487,6 @@ var addDrawingsXML = function addDrawingsXML(promiseObj) { var addLegacyHeaderFooterDrawingsXML = function addLegacyHeaderFooterDrawingsXML(promiseObj) { return new Promise(function (resolve) { - console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML'); if (!promiseObj.wb.mediaCollection.isEmpty) { promiseObj.wb.sheets.forEach(function (ws) { @@ -554,7 +553,6 @@ var addLegacyHeaderFooterDrawingsXML = function addLegacyHeaderFooterDrawingsXML var drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars); var drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars); - console.log('Genenrating VML Drawing File for ', ws.sheetId); promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr); promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr); } diff --git a/distribution/lib/workbook/builder.js.map b/distribution/lib/workbook/builder.js.map index 1769304a..5caf4f93 100644 --- a/distribution/lib/workbook/builder.js.map +++ b/distribution/lib/workbook/builder.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/workbook/builder.js"],"names":["xmlbuilder","require","JSZip","fs","CTColor","utils","addRootContentTypesXML","promiseObj","Promise","resolve","reject","xml","create","att","contentTypesAdded","extensionsAdded","wb","sheets","forEach","s","i","drawingCollection","length","drawings","d","indexOf","extension","typeRef","contentType","ele","push","Object","keys","comments","legacyDrawingHeaderFooter","sheetId","xmlString","doc","end","xmlOutVars","xlsx","file","addRootRelsXML","folder","addWorkbookXML","booksViewEle","workbookViewEle","opts","workbookView","viewOpts","activeTab","undefined","firstVisibleTab","sheet","hidden","autoFilterDateGrouping","boolToInt","firstSheet","minimized","showHorizontalScroll","showSheetTabs","showVerticalScroll","tabRatio","visibility","windowWidth","windowHeight","xWindow","yWindow","showComments","sheetsEle","name","printArea","startCellRef","getExcelAlpha","startCol","startRow","endCellRef","endCol","endRow","definedNameCollection","addDefinedName","localSheetId","refFormula","isEmpty","addToXMLele","addWorkbookRelsXML","addCorePropertiesXML","text","author","dtStr","Date","toISOString","addWorksheetsXML","curSheet","processNextSheet","thisSheet","generateXML","then","generateRelsXML","generateCommentsXML","generateCommentsVmlXML","catch","e","logger","error","stack","addSharedStringsXML","sharedStrings","txt","Array","thisSI","theseRuns","currProps","curRun","props","k","value","run","thisRun","thisRunProps","bold","italics","strike","outline","shadow","condense","extend","color","thisColor","size","underline","vertAlign","addStylesXML","styleData","numFmts","nfXML","nf","fontXML","fonts","f","fillXML","fills","fXML","borderXML","borders","b","cellXfsXML","styles","addXFtoXMLele","dxfCollection","addDrawingsXML","mediaCollection","ws","drawingRelXML","drawingsXML","kind","target","id","image","imagePath","readFileSync","rId","type","drawingsXMLStr","drawingRelXMLStr","addLegacyHeaderFooterDrawingsXML","console","log","drawingsVML","begin","sl","st","vf","writeToBuffer","Worksheet","jszip","generateAsync","buf","workbookXML","result","files","_data","module","exports"],"mappings":";;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ,OAAR,CAAd;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,UAAUH,QAAQ,6BAAR,CAAhB;AACA,IAAMI,QAAQJ,QAAQ,UAAR,CAAd;;AAEA,IAAIK,yBAAyB,SAAzBA,sBAAyB,CAACC,UAAD,EAAgB;AAC3C;AACA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAIC,MAAMX,WAAWY,MAAX,CACN,OADM,EACG;AACP,iBAAW,KADJ;AAEP,kBAAY,OAFL;AAGP,oBAAc,IAHP;AAIP,6BAAuB;AAJhB,KADH,EAQPC,GARO,CAQH,OARG,EAQM,8DARN,CAAV;;AAUA,QAAIC,oBAAoB,EAAxB;AACA,QAAIC,kBAAkB,EAAtB;AACAR,eAAWS,EAAX,CAAcC,MAAd,CAAqBC,OAArB,CAA6B,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACrC,UAAID,EAAEE,iBAAF,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAClCH,UAAEE,iBAAF,CAAoBE,QAApB,CAA6BL,OAA7B,CAAqC,UAACM,CAAD,EAAO;AAC1C,cAAIT,gBAAgBU,OAAhB,CAAwBD,EAAEE,SAA1B,IAAuC,CAA3C,EAA8C;AAC5C,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WAAc,CAAClK,EAAD,EAAQ;AACxB,MAAIT,aAAa;AACfS,QAAIA,EADW;AAEfwB,UAAM,IAAItC,KAAJ,EAFS;AAGfqC,gBAAY;AAHG,GAAjB;;AAMA,SAAOK,eAAerC,UAAf,EAA2B0F,IAA3B,CAAgC,UAACkF,MAAD,EAAY;AACjD,WAAOA,OAAO3I,IAAP,CAAY4I,KAAZ,CAAkB,iBAAlB,EAAqCC,KAA5C;AACD,GAFM,CAAP;AAGD,CAVD;;AAYAC,OAAOC,OAAP,GAAiB;AACfV,8BADe;AAEfK;AAFe,CAAjB","file":"builder.js","sourcesContent":["const xmlbuilder = require('xmlbuilder');\r\nconst JSZip = require('jszip');\r\nconst fs = require('fs');\r\nconst CTColor = require('../style/classes/ctColor.js');\r\nconst utils = require('../utils');\r\n\r\nlet addRootContentTypesXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Types', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');\r\n\r\n let contentTypesAdded = [];\r\n let extensionsAdded = [];\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n if (s.drawingCollection.length > 0) {\r\n s.drawingCollection.drawings.forEach((d) => {\r\n if (extensionsAdded.indexOf(d.extension) < 0) {\r\n let typeRef = d.contentType + '.' + d.extension;\r\n if (contentTypesAdded.indexOf(typeRef) < 0) {\r\n xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension);\r\n }\r\n extensionsAdded.push(d.extension);\r\n }\r\n });\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n }\r\n \r\n if(s.legacyDrawingHeaderFooter.length > 0){\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n if (extensionsAdded.indexOf('png') < 0){\r\n xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png');\r\n extensionsAdded.push('png');\r\n }\r\n }\r\n });\r\n xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml');\r\n xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml')\r\n \r\n\r\n if (s.drawingCollection.length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml')\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/comments' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml')\r\n }\r\n });\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.file('[Content_Types].xml', xmlString);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addRootRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId1')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument')\r\n .att('Target', 'xl/workbook.xml');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId2')\r\n .att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties')\r\n .att('Target', 'docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('_rels').file('.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'workbook', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n xml.att('mc:Ignorable', 'x15');\r\n xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');\r\n xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');\r\n\r\n let booksViewEle = xml.ele('bookViews');\r\n let workbookViewEle = booksViewEle.ele('workbookView');\r\n // bookViews (§18.2.1)\r\n if (promiseObj.wb.opts.workbookView) {\r\n const viewOpts = promiseObj.wb.opts.workbookView;\r\n if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) {\r\n workbookViewEle.att('activeTab', viewOpts.activeTab);\r\n } else {\r\n let firstVisibleTab = 0;\r\n for (let i = 0; i < promiseObj.wb.sheets.length; i++) {\r\n const sheet = promiseObj.wb.sheets[i];\r\n if (!sheet.opts.hidden) {\r\n firstVisibleTab = i;\r\n break;\r\n }\r\n }\r\n workbookViewEle.att('activeTab', firstVisibleTab);\r\n }\r\n if (viewOpts.autoFilterDateGrouping) {\r\n workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping));\r\n }\r\n if (viewOpts.firstSheet) {\r\n workbookViewEle.att('firstSheet', viewOpts.firstSheet);\r\n }\r\n if (viewOpts.minimized) {\r\n workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized));\r\n }\r\n if (viewOpts.showHorizontalScroll) {\r\n workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll));\r\n }\r\n if (viewOpts.showSheetTabs) {\r\n workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs));\r\n }\r\n if (viewOpts.showVerticalScroll) {\r\n workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll));\r\n }\r\n if (viewOpts.tabRatio) {\r\n workbookViewEle.att('tabRatio', viewOpts.tabRatio);\r\n }\r\n if (viewOpts.visibility) {\r\n workbookViewEle.att('visibility', viewOpts.visibility);\r\n }\r\n if (viewOpts.windowWidth) {\r\n workbookViewEle.att('windowWidth', viewOpts.windowWidth);\r\n }\r\n if (viewOpts.windowHeight) {\r\n workbookViewEle.att('windowHeight', viewOpts.windowHeight);\r\n }\r\n if (viewOpts.xWindow) {\r\n workbookViewEle.att('xWindow', viewOpts.xWindow);\r\n }\r\n if (viewOpts.yWindow) {\r\n workbookViewEle.att('yWindow', viewOpts.yWindow);\r\n }\r\n if (viewOpts.showComments) {\r\n workbookViewEle.att('showComments', viewOpts.showComments);\r\n }\r\n }\r\n\r\n let sheetsEle = xml.ele('sheets');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n const sheet = sheetsEle.ele('sheet')\r\n .att('name', s.name)\r\n .att('sheetId', i + 1)\r\n .att('r:id', `rId${i + 1}`);\r\n\r\n if (s.opts.hidden) {\r\n sheet.att('state', 'hidden');\r\n }\r\n\r\n if (s.printArea) {\r\n const name = s.name;\r\n const startCellRef = `$${utils.getExcelAlpha(s.printArea.startCol)}$${s.printArea.startRow}`;\r\n const endCellRef = `$${utils.getExcelAlpha(s.printArea.endCol)}$${s.printArea.endRow}`;\r\n s.wb.definedNameCollection.addDefinedName({\r\n name: '_xlnm.Print_Area',\r\n localSheetId: s.localSheetId,\r\n refFormula: `'${name}'!${startCellRef}:${endCellRef}`,\r\n });\r\n }\r\n });\r\n\r\n if (!promiseObj.wb.definedNameCollection.isEmpty) {\r\n promiseObj.wb.definedNameCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 1}`)\r\n .att('Target', 'sharedStrings.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 2}`)\r\n .att('Target', 'styles.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles');\r\n\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${i + 1}`)\r\n .att('Target', `worksheets/sheet${i + 1}.xml`)\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet');\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addCorePropertiesXML = (promiseObj) => {\r\n let xml = xmlbuilder.create(\r\n 'cp:coreProperties', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true\r\n }\r\n )\r\n .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties')\r\n .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/')\r\n .att('xmlns:dcterms', 'http://purl.org/dc/terms/')\r\n .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/')\r\n .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');\r\n\r\n xml.ele('dc:creator').text(promiseObj.wb.author);\r\n xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author);\r\n let dtStr = new Date().toISOString();\r\n xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('docProps').file('core.xml', xmlString);\r\n return promiseObj;\r\n};\r\n\r\nlet addWorksheetsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let curSheet = 0;\r\n\r\n let processNextSheet = () => {\r\n let thisSheet = promiseObj.wb.sheets[curSheet];\r\n if (thisSheet) {\r\n curSheet++;\r\n thisSheet.generateXML()\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n // Add worksheet to zip\r\n promiseObj.xlsx.folder('xl').folder('worksheets').file(`sheet${curSheet}.xml`, xml);\r\n\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateRelsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file(`sheet${curSheet}.xml.rels`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').file(`comments${curSheet}.xml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsVmlXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('drawings').file(`commentsVml${curSheet}.vml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(processNextSheet)\r\n .catch((e) => {\r\n promiseObj.wb.logger.error(e.stack);\r\n });\r\n } else {\r\n resolve(promiseObj);\r\n }\r\n };\r\n processNextSheet();\r\n\r\n });\r\n};\r\n\r\n/**\r\n * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer()\r\n * @private\r\n * @memberof Workbook\r\n * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars\r\n * @return {Promise} Resolves with promiseObj\r\n */\r\nlet addSharedStringsXML = (promiseObj) => {\r\n // §12.3.15 Shared String Table Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'sst', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('count', promiseObj.wb.sharedStrings.length)\r\n .att('uniqueCount', promiseObj.wb.sharedStrings.length)\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n promiseObj.wb.sharedStrings.forEach((s) => {\r\n if (typeof s === 'string') {\r\n xml.ele('si').ele('t').txt(s);\r\n } else if (s instanceof Array) {\r\n\r\n let thisSI = xml.ele('si');\r\n let theseRuns = []; // §18.4.4 r (Rich Text Run)\r\n let currProps = {};\r\n let curRun;\r\n let i = 0;\r\n while (i < s.length) {\r\n if (typeof s[i] === 'string') {\r\n if (curRun === undefined) {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n }\r\n curRun.text = curRun.text + s[i];\r\n } else if (typeof s[i] === 'object') {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n Object.keys(s[i]).forEach((k) => {\r\n currProps[k] = s[i][k];\r\n });\r\n Object.keys(currProps).forEach((k) => {\r\n curRun.props[k] = currProps[k];\r\n });\r\n if (s[i].value !== undefined) {\r\n curRun.text = s[i].value;\r\n }\r\n }\r\n i++;\r\n }\r\n\r\n theseRuns.forEach((run) => {\r\n if (Object.keys(run).length < 1) {\r\n thisSI.ele('t', run.text).att('xml:space', 'preserve');\r\n } else {\r\n let thisRun = thisSI.ele('r');\r\n let thisRunProps = thisRun.ele('rPr');\r\n typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null;\r\n run.props.bold === true ? thisRunProps.ele('b') : null;\r\n run.props.italics === true ? thisRunProps.ele('i') : null;\r\n run.props.strike === true ? thisRunProps.ele('strike') : null;\r\n run.props.outline === true ? thisRunProps.ele('outline') : null;\r\n run.props.shadow === true ? thisRunProps.ele('shadow') : null;\r\n run.props.condense === true ? thisRunProps.ele('condense') : null;\r\n run.props.extend === true ? thisRunProps.ele('extend') : null;\r\n if (typeof run.props.color === 'string') {\r\n let thisColor = new CTColor(run.props.color);\r\n thisColor.addToXMLele(thisRunProps);\r\n }\r\n typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null;\r\n run.props.underline === true ? thisRunProps.ele('u') : null;\r\n typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null;\r\n thisRun.ele('t', run.text).att('xml:space', 'preserve');\r\n }\r\n });\r\n\r\n }\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addStylesXML = (promiseObj) => {\r\n // §12.3.20 Styles Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'styleSheet', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n if (promiseObj.wb.styleData.numFmts.length > 0) {\r\n let nfXML = xml\r\n .ele('numFmts')\r\n .att('count', promiseObj.wb.styleData.numFmts.length);\r\n promiseObj.wb.styleData.numFmts.forEach((nf) => {\r\n nf.addToXMLele(nfXML);\r\n });\r\n }\r\n\r\n let fontXML = xml\r\n .ele('fonts')\r\n .att('count', promiseObj.wb.styleData.fonts.length);\r\n promiseObj.wb.styleData.fonts.forEach((f) => {\r\n f.addToXMLele(fontXML);\r\n });\r\n\r\n let fillXML = xml\r\n .ele('fills')\r\n .att('count', promiseObj.wb.styleData.fills.length);\r\n promiseObj.wb.styleData.fills.forEach((f) => {\r\n let fXML = fillXML.ele('fill');\r\n f.addToXMLele(fXML);\r\n });\r\n\r\n let borderXML = xml\r\n .ele('borders')\r\n .att('count', promiseObj.wb.styleData.borders.length);\r\n promiseObj.wb.styleData.borders.forEach((b) => {\r\n b.addToXMLele(borderXML);\r\n });\r\n\r\n\r\n let cellXfsXML = xml\r\n .ele('cellXfs')\r\n .att('count', promiseObj.wb.styles.length);\r\n promiseObj.wb.styles.forEach((s) => {\r\n s.addXFtoXMLele(cellXfsXML);\r\n });\r\n\r\n if (promiseObj.wb.dxfCollection.length > 0) {\r\n promiseObj.wb.dxfCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('styles.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n if (!ws.drawingCollection.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsXML = xmlbuilder.create(\r\n 'xdr:wsDr', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n drawingsXML\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');\r\n\r\n ws.drawingCollection.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n\r\n\r\n d.addToXMLele(drawingsXML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addLegacyHeaderFooterDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML')\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n \r\n if (!ws.legacyDrawingHeaderFooter.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsVML = xmlbuilder.begin().ele('xml');\r\n drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = drawingsVML.ele('v:shapetype')\r\n .att('id', '_x0000_t75')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '75')\r\n .att('o:preferrelative', 't')\r\n .att('path', 'm@4@5l@4@11@9@11@9@5xe')\r\n .att('filled', 'f').att('stroked', 'f');\r\n\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n var vf = st.ele('v:formulas');\r\n vf.ele('v:f').att('eqn', \"if lineDrawn pixelLineWidth 0\")\r\n vf.ele('v:f').att('eqn', \"sum @0 1 0\");\r\n vf.ele('v:f').att('eqn', \"sum 0 0 @1\");\r\n vf.ele('v:f').att('eqn', \"prod @2 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @0 0 1\");\r\n vf.ele('v:f').att('eqn', \"prod @6 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"sum @8 21600 0\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @10 21600 0\");\r\n\r\n st.ele('v:path')\r\n .att('o:extrusionok','f')\r\n .att('gradientshapeok','t')\r\n .att('o:connecttype','rect')\r\n\r\n st.ele('o:lock').att('v:ext','edit').att('aspectratio','t');\r\n\r\n // const sh = drawingsVML.ele('v:shape');\r\n // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75')\r\n // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`);\r\n // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1')\r\n // sh.ele('o:lock').att('v:ext','edit').att('rotation','t');\r\n\r\n // const textB = sh.ele('v:textbox').text('VML TextBox')\r\n\r\n ws.legacyDrawingHeaderFooter.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n d.addToXMLele(drawingsVML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n console.log('Genenrating VML Drawing File for ', ws.sheetId);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\n\r\n/**\r\n * Use JSZip to generate file to a node buffer\r\n * @private\r\n * @memberof Workbook\r\n * @param {Workbook} wb Workbook instance\r\n * @return {Promise} resolves with Buffer\r\n */\r\nlet writeToBuffer = (wb) => {\r\n return new Promise((resolve, reject) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n if (promiseObj.wb.sheets.length === 0) {\r\n promiseObj.wb.Worksheet();\r\n }\r\n\r\n addRootContentTypesXML(promiseObj)\r\n .then(addWorksheetsXML)\r\n .then(addRootRelsXML)\r\n .then(addWorkbookXML)\r\n .then(addWorkbookRelsXML)\r\n .then(addCorePropertiesXML)\r\n .then(addSharedStringsXML)\r\n .then(addStylesXML)\r\n .then(addDrawingsXML)\r\n .then(addLegacyHeaderFooterDrawingsXML)\r\n .then(() => {\r\n wb.opts.jszip.type = 'nodebuffer';\r\n promiseObj.xlsx.generateAsync(wb.opts.jszip)\r\n .then((buf) => {\r\n resolve(buf);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n\r\n });\r\n};\r\n\r\n/**\r\n * @desc Currently only used for testing the XML generated for a Workbook.\r\n * @param {*} wb Workbook instance\r\n * @return {Promise} resolves with Workbook XML\r\n */\r\nlet workbookXML = (wb) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n return addWorkbookXML(promiseObj).then((result) => {\r\n return result.xlsx.files['xl/workbook.xml']._data;\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n writeToBuffer,\r\n workbookXML\r\n};"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/workbook/builder.js"],"names":["xmlbuilder","require","JSZip","fs","CTColor","utils","addRootContentTypesXML","promiseObj","Promise","resolve","reject","xml","create","att","contentTypesAdded","extensionsAdded","wb","sheets","forEach","s","i","drawingCollection","length","drawings","d","indexOf","extension","typeRef","contentType","ele","push","Object","keys","comments","legacyDrawingHeaderFooter","sheetId","xmlString","doc","end","xmlOutVars","xlsx","file","addRootRelsXML","folder","addWorkbookXML","booksViewEle","workbookViewEle","opts","workbookView","viewOpts","activeTab","undefined","firstVisibleTab","sheet","hidden","autoFilterDateGrouping","boolToInt","firstSheet","minimized","showHorizontalScroll","showSheetTabs","showVerticalScroll","tabRatio","visibility","windowWidth","windowHeight","xWindow","yWindow","showComments","sheetsEle","name","printArea","startCellRef","getExcelAlpha","startCol","startRow","endCellRef","endCol","endRow","definedNameCollection","addDefinedName","localSheetId","refFormula","isEmpty","addToXMLele","addWorkbookRelsXML","addCorePropertiesXML","text","author","dtStr","Date","toISOString","addWorksheetsXML","curSheet","processNextSheet","thisSheet","generateXML","then","generateRelsXML","generateCommentsXML","generateCommentsVmlXML","catch","e","logger","error","stack","addSharedStringsXML","sharedStrings","txt","Array","thisSI","theseRuns","currProps","curRun","props","k","value","run","thisRun","thisRunProps","bold","italics","strike","outline","shadow","condense","extend","color","thisColor","size","underline","vertAlign","addStylesXML","styleData","numFmts","nfXML","nf","fontXML","fonts","f","fillXML","fills","fXML","borderXML","borders","b","cellXfsXML","styles","addXFtoXMLele","dxfCollection","addDrawingsXML","mediaCollection","ws","drawingRelXML","drawingsXML","kind","target","id","image","imagePath","readFileSync","rId","type","drawingsXMLStr","drawingRelXMLStr","addLegacyHeaderFooterDrawingsXML","drawingsVML","begin","sl","st","vf","writeToBuffer","Worksheet","jszip","generateAsync","buf","workbookXML","result","files","_data","module","exports"],"mappings":";;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ,OAAR,CAAd;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,UAAUH,QAAQ,6BAAR,CAAhB;AACA,IAAMI,QAAQJ,QAAQ,UAAR,CAAd;;AAEA,IAAIK,yBAAyB,SAAzBA,sBAAyB,CAACC,UAAD,EAAgB;AAC3C;AACA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAIC,MAAMX,WAAWY,MAAX,CACN,OADM,EACG;AACP,iBAAW,KADJ;AAEP,kBAAY,OAFL;AAGP,oBAAc,IAHP;AAIP,6BAAuB;AAJhB,KADH,EAQPC,GARO,CAQH,OARG,EAQM,8DARN,CAAV;;AAUA,QAAIC,oBAAoB,EAAxB;AACA,QAAIC,kBAAkB,EAAtB;AACAR,eAAWS,EAAX,CAAcC,MAAd,CAAqBC,OAArB,CAA6B,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACrC,UAAID,EAAEE,iBAAF,CAAoBC,MAApB,GAA6B,CAAjC,EAAoC;AAClCH,UAAEE,iBAAF,CAAoBE,QAApB,CAA6BL,OAA7B,CAAqC,UAACM,CAAD,EAAO;AAC1C,cAAIT,gBAAgBU,OAAhB,CAAwBD,EAAEE,SAA1B,IAAuC,CAA3C,EAA8C;AAC5C,gBAAIC,UAAUH,EAAEI,WAAF,GAAgB,GAAhB,GAAsBJ,EAAEE,SAAtC;AACA,gBAAIZ,kBAAkBW,OAAlB,CAA0BE,OAA1B,IAAqC,CAAzC,EAA4C;AAC1ChB,kBAAIkB,GAAJ,CAAQ,SAAR,EAAmB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5C;AACD,GAFM,CAAP;AAGD,CAVD;;AAYAC,OAAOC,OAAP,GAAiB;AACfV,8BADe;AAEfK;AAFe,CAAjB","file":"builder.js","sourcesContent":["const xmlbuilder = require('xmlbuilder');\r\nconst JSZip = require('jszip');\r\nconst fs = require('fs');\r\nconst CTColor = require('../style/classes/ctColor.js');\r\nconst utils = require('../utils');\r\n\r\nlet addRootContentTypesXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Types', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');\r\n\r\n let contentTypesAdded = [];\r\n let extensionsAdded = [];\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n if (s.drawingCollection.length > 0) {\r\n s.drawingCollection.drawings.forEach((d) => {\r\n if (extensionsAdded.indexOf(d.extension) < 0) {\r\n let typeRef = d.contentType + '.' + d.extension;\r\n if (contentTypesAdded.indexOf(typeRef) < 0) {\r\n xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension);\r\n }\r\n extensionsAdded.push(d.extension);\r\n }\r\n });\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n }\r\n \r\n if(s.legacyDrawingHeaderFooter.length > 0){\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n if (extensionsAdded.indexOf('png') < 0){\r\n xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png');\r\n extensionsAdded.push('png');\r\n }\r\n }\r\n });\r\n xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml');\r\n xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml')\r\n \r\n\r\n if (s.drawingCollection.length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml')\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/comments' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml')\r\n }\r\n });\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.file('[Content_Types].xml', xmlString);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addRootRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId1')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument')\r\n .att('Target', 'xl/workbook.xml');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId2')\r\n .att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties')\r\n .att('Target', 'docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('_rels').file('.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'workbook', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n xml.att('mc:Ignorable', 'x15');\r\n xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');\r\n xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');\r\n\r\n let booksViewEle = xml.ele('bookViews');\r\n let workbookViewEle = booksViewEle.ele('workbookView');\r\n // bookViews (§18.2.1)\r\n if (promiseObj.wb.opts.workbookView) {\r\n const viewOpts = promiseObj.wb.opts.workbookView;\r\n if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) {\r\n workbookViewEle.att('activeTab', viewOpts.activeTab);\r\n } else {\r\n let firstVisibleTab = 0;\r\n for (let i = 0; i < promiseObj.wb.sheets.length; i++) {\r\n const sheet = promiseObj.wb.sheets[i];\r\n if (!sheet.opts.hidden) {\r\n firstVisibleTab = i;\r\n break;\r\n }\r\n }\r\n workbookViewEle.att('activeTab', firstVisibleTab);\r\n }\r\n if (viewOpts.autoFilterDateGrouping) {\r\n workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping));\r\n }\r\n if (viewOpts.firstSheet) {\r\n workbookViewEle.att('firstSheet', viewOpts.firstSheet);\r\n }\r\n if (viewOpts.minimized) {\r\n workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized));\r\n }\r\n if (viewOpts.showHorizontalScroll) {\r\n workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll));\r\n }\r\n if (viewOpts.showSheetTabs) {\r\n workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs));\r\n }\r\n if (viewOpts.showVerticalScroll) {\r\n workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll));\r\n }\r\n if (viewOpts.tabRatio) {\r\n workbookViewEle.att('tabRatio', viewOpts.tabRatio);\r\n }\r\n if (viewOpts.visibility) {\r\n workbookViewEle.att('visibility', viewOpts.visibility);\r\n }\r\n if (viewOpts.windowWidth) {\r\n workbookViewEle.att('windowWidth', viewOpts.windowWidth);\r\n }\r\n if (viewOpts.windowHeight) {\r\n workbookViewEle.att('windowHeight', viewOpts.windowHeight);\r\n }\r\n if (viewOpts.xWindow) {\r\n workbookViewEle.att('xWindow', viewOpts.xWindow);\r\n }\r\n if (viewOpts.yWindow) {\r\n workbookViewEle.att('yWindow', viewOpts.yWindow);\r\n }\r\n if (viewOpts.showComments) {\r\n workbookViewEle.att('showComments', viewOpts.showComments);\r\n }\r\n }\r\n\r\n let sheetsEle = xml.ele('sheets');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n const sheet = sheetsEle.ele('sheet')\r\n .att('name', s.name)\r\n .att('sheetId', i + 1)\r\n .att('r:id', `rId${i + 1}`);\r\n\r\n if (s.opts.hidden) {\r\n sheet.att('state', 'hidden');\r\n }\r\n\r\n if (s.printArea) {\r\n const name = s.name;\r\n const startCellRef = `$${utils.getExcelAlpha(s.printArea.startCol)}$${s.printArea.startRow}`;\r\n const endCellRef = `$${utils.getExcelAlpha(s.printArea.endCol)}$${s.printArea.endRow}`;\r\n s.wb.definedNameCollection.addDefinedName({\r\n name: '_xlnm.Print_Area',\r\n localSheetId: s.localSheetId,\r\n refFormula: `'${name}'!${startCellRef}:${endCellRef}`,\r\n });\r\n }\r\n });\r\n\r\n if (!promiseObj.wb.definedNameCollection.isEmpty) {\r\n promiseObj.wb.definedNameCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 1}`)\r\n .att('Target', 'sharedStrings.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 2}`)\r\n .att('Target', 'styles.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles');\r\n\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${i + 1}`)\r\n .att('Target', `worksheets/sheet${i + 1}.xml`)\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet');\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addCorePropertiesXML = (promiseObj) => {\r\n let xml = xmlbuilder.create(\r\n 'cp:coreProperties', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true\r\n }\r\n )\r\n .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties')\r\n .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/')\r\n .att('xmlns:dcterms', 'http://purl.org/dc/terms/')\r\n .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/')\r\n .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');\r\n\r\n xml.ele('dc:creator').text(promiseObj.wb.author);\r\n xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author);\r\n let dtStr = new Date().toISOString();\r\n xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('docProps').file('core.xml', xmlString);\r\n return promiseObj;\r\n};\r\n\r\nlet addWorksheetsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let curSheet = 0;\r\n\r\n let processNextSheet = () => {\r\n let thisSheet = promiseObj.wb.sheets[curSheet];\r\n if (thisSheet) {\r\n curSheet++;\r\n thisSheet.generateXML()\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n // Add worksheet to zip\r\n promiseObj.xlsx.folder('xl').folder('worksheets').file(`sheet${curSheet}.xml`, xml);\r\n\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateRelsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file(`sheet${curSheet}.xml.rels`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').file(`comments${curSheet}.xml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsVmlXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('drawings').file(`commentsVml${curSheet}.vml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(processNextSheet)\r\n .catch((e) => {\r\n promiseObj.wb.logger.error(e.stack);\r\n });\r\n } else {\r\n resolve(promiseObj);\r\n }\r\n };\r\n processNextSheet();\r\n\r\n });\r\n};\r\n\r\n/**\r\n * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer()\r\n * @private\r\n * @memberof Workbook\r\n * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars\r\n * @return {Promise} Resolves with promiseObj\r\n */\r\nlet addSharedStringsXML = (promiseObj) => {\r\n // §12.3.15 Shared String Table Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'sst', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('count', promiseObj.wb.sharedStrings.length)\r\n .att('uniqueCount', promiseObj.wb.sharedStrings.length)\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n promiseObj.wb.sharedStrings.forEach((s) => {\r\n if (typeof s === 'string') {\r\n xml.ele('si').ele('t').txt(s);\r\n } else if (s instanceof Array) {\r\n\r\n let thisSI = xml.ele('si');\r\n let theseRuns = []; // §18.4.4 r (Rich Text Run)\r\n let currProps = {};\r\n let curRun;\r\n let i = 0;\r\n while (i < s.length) {\r\n if (typeof s[i] === 'string') {\r\n if (curRun === undefined) {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n }\r\n curRun.text = curRun.text + s[i];\r\n } else if (typeof s[i] === 'object') {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n Object.keys(s[i]).forEach((k) => {\r\n currProps[k] = s[i][k];\r\n });\r\n Object.keys(currProps).forEach((k) => {\r\n curRun.props[k] = currProps[k];\r\n });\r\n if (s[i].value !== undefined) {\r\n curRun.text = s[i].value;\r\n }\r\n }\r\n i++;\r\n }\r\n\r\n theseRuns.forEach((run) => {\r\n if (Object.keys(run).length < 1) {\r\n thisSI.ele('t', run.text).att('xml:space', 'preserve');\r\n } else {\r\n let thisRun = thisSI.ele('r');\r\n let thisRunProps = thisRun.ele('rPr');\r\n typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null;\r\n run.props.bold === true ? thisRunProps.ele('b') : null;\r\n run.props.italics === true ? thisRunProps.ele('i') : null;\r\n run.props.strike === true ? thisRunProps.ele('strike') : null;\r\n run.props.outline === true ? thisRunProps.ele('outline') : null;\r\n run.props.shadow === true ? thisRunProps.ele('shadow') : null;\r\n run.props.condense === true ? thisRunProps.ele('condense') : null;\r\n run.props.extend === true ? thisRunProps.ele('extend') : null;\r\n if (typeof run.props.color === 'string') {\r\n let thisColor = new CTColor(run.props.color);\r\n thisColor.addToXMLele(thisRunProps);\r\n }\r\n typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null;\r\n run.props.underline === true ? thisRunProps.ele('u') : null;\r\n typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null;\r\n thisRun.ele('t', run.text).att('xml:space', 'preserve');\r\n }\r\n });\r\n\r\n }\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addStylesXML = (promiseObj) => {\r\n // §12.3.20 Styles Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'styleSheet', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n if (promiseObj.wb.styleData.numFmts.length > 0) {\r\n let nfXML = xml\r\n .ele('numFmts')\r\n .att('count', promiseObj.wb.styleData.numFmts.length);\r\n promiseObj.wb.styleData.numFmts.forEach((nf) => {\r\n nf.addToXMLele(nfXML);\r\n });\r\n }\r\n\r\n let fontXML = xml\r\n .ele('fonts')\r\n .att('count', promiseObj.wb.styleData.fonts.length);\r\n promiseObj.wb.styleData.fonts.forEach((f) => {\r\n f.addToXMLele(fontXML);\r\n });\r\n\r\n let fillXML = xml\r\n .ele('fills')\r\n .att('count', promiseObj.wb.styleData.fills.length);\r\n promiseObj.wb.styleData.fills.forEach((f) => {\r\n let fXML = fillXML.ele('fill');\r\n f.addToXMLele(fXML);\r\n });\r\n\r\n let borderXML = xml\r\n .ele('borders')\r\n .att('count', promiseObj.wb.styleData.borders.length);\r\n promiseObj.wb.styleData.borders.forEach((b) => {\r\n b.addToXMLele(borderXML);\r\n });\r\n\r\n\r\n let cellXfsXML = xml\r\n .ele('cellXfs')\r\n .att('count', promiseObj.wb.styles.length);\r\n promiseObj.wb.styles.forEach((s) => {\r\n s.addXFtoXMLele(cellXfsXML);\r\n });\r\n\r\n if (promiseObj.wb.dxfCollection.length > 0) {\r\n promiseObj.wb.dxfCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('styles.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n if (!ws.drawingCollection.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsXML = xmlbuilder.create(\r\n 'xdr:wsDr', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n drawingsXML\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');\r\n\r\n ws.drawingCollection.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n\r\n\r\n d.addToXMLele(drawingsXML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addLegacyHeaderFooterDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n \r\n if (!ws.legacyDrawingHeaderFooter.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsVML = xmlbuilder.begin().ele('xml');\r\n drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = drawingsVML.ele('v:shapetype')\r\n .att('id', '_x0000_t75')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '75')\r\n .att('o:preferrelative', 't')\r\n .att('path', 'm@4@5l@4@11@9@11@9@5xe')\r\n .att('filled', 'f').att('stroked', 'f');\r\n\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n var vf = st.ele('v:formulas');\r\n vf.ele('v:f').att('eqn', \"if lineDrawn pixelLineWidth 0\")\r\n vf.ele('v:f').att('eqn', \"sum @0 1 0\");\r\n vf.ele('v:f').att('eqn', \"sum 0 0 @1\");\r\n vf.ele('v:f').att('eqn', \"prod @2 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @0 0 1\");\r\n vf.ele('v:f').att('eqn', \"prod @6 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"sum @8 21600 0\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @10 21600 0\");\r\n\r\n st.ele('v:path')\r\n .att('o:extrusionok','f')\r\n .att('gradientshapeok','t')\r\n .att('o:connecttype','rect')\r\n\r\n st.ele('o:lock').att('v:ext','edit').att('aspectratio','t');\r\n\r\n // const sh = drawingsVML.ele('v:shape');\r\n // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75')\r\n // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`);\r\n // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1')\r\n // sh.ele('o:lock').att('v:ext','edit').att('rotation','t');\r\n\r\n // const textB = sh.ele('v:textbox').text('VML TextBox')\r\n\r\n ws.legacyDrawingHeaderFooter.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n d.addToXMLele(drawingsVML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\n\r\n/**\r\n * Use JSZip to generate file to a node buffer\r\n * @private\r\n * @memberof Workbook\r\n * @param {Workbook} wb Workbook instance\r\n * @return {Promise} resolves with Buffer\r\n */\r\nlet writeToBuffer = (wb) => {\r\n return new Promise((resolve, reject) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n if (promiseObj.wb.sheets.length === 0) {\r\n promiseObj.wb.Worksheet();\r\n }\r\n\r\n addRootContentTypesXML(promiseObj)\r\n .then(addWorksheetsXML)\r\n .then(addRootRelsXML)\r\n .then(addWorkbookXML)\r\n .then(addWorkbookRelsXML)\r\n .then(addCorePropertiesXML)\r\n .then(addSharedStringsXML)\r\n .then(addStylesXML)\r\n .then(addDrawingsXML)\r\n .then(addLegacyHeaderFooterDrawingsXML)\r\n .then(() => {\r\n wb.opts.jszip.type = 'nodebuffer';\r\n promiseObj.xlsx.generateAsync(wb.opts.jszip)\r\n .then((buf) => {\r\n resolve(buf);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n\r\n });\r\n};\r\n\r\n/**\r\n * @desc Currently only used for testing the XML generated for a Workbook.\r\n * @param {*} wb Workbook instance\r\n * @return {Promise} resolves with Workbook XML\r\n */\r\nlet workbookXML = (wb) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n return addWorkbookXML(promiseObj).then((result) => {\r\n return result.xlsx.files['xl/workbook.xml']._data;\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n writeToBuffer,\r\n workbookXML\r\n};"]} \ No newline at end of file diff --git a/source/lib/workbook/builder.js b/source/lib/workbook/builder.js index e7fb00a9..eb0dda5d 100644 --- a/source/lib/workbook/builder.js +++ b/source/lib/workbook/builder.js @@ -579,7 +579,6 @@ let addDrawingsXML = (promiseObj) => { let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { return new Promise((resolve) => { - console.log('Mohanad Says hi from addLegacyDrawingHeaderFooterVML') if (!promiseObj.wb.mediaCollection.isEmpty) { promiseObj.wb.sheets.forEach((ws) => { @@ -661,7 +660,6 @@ let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars); let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars); - console.log('Genenrating VML Drawing File for ', ws.sheetId); promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr); promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr); } From 16ac4b6ee874c39ec6caf9323784ea5051361e46 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 11 Jan 2021 01:00:51 +0300 Subject: [PATCH 08/12] Added charts to excel4node --- .gitignore | 3 +- sample3.js | 400 ++++++++++++++++++++++++ source/lib/drawing/chart.js | 258 +++++++++++++++ source/lib/drawing/index.js | 7 +- source/lib/workbook/builder.js | 210 +++++++------ source/lib/workbook/chartsCollection.js | 20 ++ source/lib/workbook/workbook.js | 2 + source/lib/worksheet/worksheet.js | 7 + 8 files changed, 816 insertions(+), 91 deletions(-) create mode 100644 sample3.js create mode 100644 source/lib/drawing/chart.js create mode 100644 source/lib/workbook/chartsCollection.js diff --git a/.gitignore b/.gitignore index a6e2bf47..4c1cca10 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ coverage .nyc_output package-lock.json testzip -testzip/* \ No newline at end of file +testzip/* +*.xlsx \ No newline at end of file diff --git a/sample3.js b/sample3.js new file mode 100644 index 00000000..afaad6c3 --- /dev/null +++ b/sample3.js @@ -0,0 +1,400 @@ +const fs = require('fs'); +const path = require('path'); +const unzipper = require('unzipper') + +const xl = require('./source') + +const aca_data = { + 'FacultyName': 'كلية الهندسة', + 'AcademicYear': '2018/2019', + 'AcademicGrade': 'الرابع', + 'Department': 'الهندسة الكهربائية و الإلكترونية', + 'Discipline': 'غير متخصص', + 'BoardMeetingNo': '2019/06', + 'BoardMeetingDate': '07/12/2020', + + 'AcademicYear_M_1': '2017/2018', + 'AcademicYear_M_2': '2016/2017', + + RegistrarName: 'أ. المحيا الأمين خلف الله محمد خير', + DeputyDeanName: 'د. مجدي محمد زمراوي', + DeanName: 'د.علي محمد علي السيوري', + + 'HonorsOrGraduates': 'Honours', + + dataTables: { + RegStudents: { + "Total": [100, 90, 85, "العدد الكلي"], + "Examined": [80, 75, 70, "الجالسون"], + "Passed": [75, 70, 65, "النجاح"], + "Subs": [3, 2, 4, "البدائل"], + "Supp": [2, 3, 1, "ازالة الرسوب (الملاحق)"], + "SubsSupp": [1, 0, 3, "البدائل وازالة الرسوب"], + "Repeat": [0, 1, 2, "اعادة العام"], + "Dismissals": [0, 2, 1, "المفصولون"], + "Recess": [0, 0, 0, "المجمدون"], + "SpecialCases": [0, 0, 0, "حالات خاصة"], + "CheatCases": [0, 1, 2, "حالات مخالفة لائحة الامتحانات"] + }, + ExtStudents: { + "Total": [100, 90, 85], + "Examined": [80, 75, 70], + "Passed": [75, 70, 65], + "Subs": [3, 2, 4], + "Supp": [2, 3, 1], + "SubsSupp": [1, 0, 3], + "Failed": [0, 1, 2], + "SpecialCases": [0, 0, 0], + "CheatCases": [0, 1, 2] + }, + RegStudentsHonours: { + Total: [30, 25, 23, "العدد الكلي"], + FirstClass: [20, 15, 19, "مرتبة الشرف الأولى"], + SecondClassFirst: [10, 14, 18, "مرتبة الشرف الثانية - القسم الأول"], + SecondClassSecond: [1, 2, 3, "مرتبة الشرف الثانية - القسم الثاني"], + ThirdClass: [4, 5, 6, "مرتبة الشرف الثالثة"] + }, + ExtStudentsHonours: { + Total: [30, 25, 23, ""], + FirstClass: [20, 15, 19, "مرتبة الشرف الأولى"], + SecondClassFirst: [10, 14, 18, "مرتبة الشرف الثانية - القسم الأول"], + SecondClassSecond: [1, 2, 3, "مرتبة الشرف الثانية - القسم الثاني"], + ThirdClass: [4, 5, 6, "مرتبة الشرف الثالثة"] + } + } +} + +var wb = new xl.Workbook({ + defaultFont: { + name: 'Sakkal Majalla', + size: 14 + }, + dateFormat: 'mm/dd/yyyy hh:mm:ss', + logLevel: 1, + workbookView: { + windowWidth: 28800, + windowHeight: 17620, + xWindow: 240, + yWindow: 480, + }, + author: 'Mohanad Ahmed', + calculationProperties: { + fullCalculationOnLoad: true + } +}); + +var wx = wb.addWorksheet("Sheet2", { + pageSetup: { + fitToWidth: 1, + paperSize: 'A4_PAPER', + orientation: 'portrait' + }, + sheetView: { + 'rightToLeft': true + } +}) + +wx.column(1).width = 3.14; +wx.column(2).width = 26.57; +wx.column(3).width = 8.43; +wx.column(4).width = 8.43; +wx.column(5).width = 8.43; +wx.column(6).width = 8.43; +wx.column(7).width = 8.43; +wx.column(8).width = 8.43; + +var borderx = { + left: { style: 'medium', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'medium', color: 'black' }, + bottom: { style: 'medium', color: 'black' } +}; +// var bordermed = { +// left: { style: 'thick', color: 'black' }, +// right: { style: 'thick', color: 'black' }, +// top: { style: 'thick', color: 'black' }, +// bottom: { style: 'thick', color: 'black' } +// }; +var bordert_top = { + top: { style: 'thick', color: 'black' }, +}; +var sumStyle = { + font: { bold: true, size: 14 }, + alignment: { + horizontal: 'center', + vertical: 'center' + }, + border: borderx +}; + +var titleStyle = { + font: { bold: true, size: 18 }, + alignment: { + horizontal: 'center', + vertical: 'center' + } +}; + +wx.cell(1, 2, 1, 8, true).string('جامعة الخرطوم').style(titleStyle); +wx.cell(2, 2, 2, 8, true).string('أمانة الشؤون العلمية').style(titleStyle) +wx.cell(3, 2, 3, 8, true).string('الإحصائية العامة لنتائج الامتحانات النهائية - الخريجون - مرتبة الشرف') + .style(titleStyle) + +wx.cell(4, 2, 4, 8, true).style({ border: bordert_top }) + +wx.row(1).height = 20.25; +wx.row(2).height = 20.25; +wx.row(3).height = 20.25; +wx.row(4).height = 3.75; +wx.row(5).height = 9.75; + +var topDataStyle = { border: borderx, alignment: { horizontal: 'right' } }; +wx.cell(6, 3, 6, 8, true).string(aca_data.FacultyName).style(topDataStyle) +wx.cell(7, 3, 7, 8, true).string(aca_data.AcademicYear).style(topDataStyle) +wx.cell(8, 3, 8, 8, true).string(aca_data.AcademicGrade).style(topDataStyle) +wx.cell(9, 3, 9, 8, true).string(aca_data.Department).style(topDataStyle) +wx.cell(10, 3, 10, 8, true).string(aca_data.Discipline).style(topDataStyle) +wx.cell(11, 3, 11, 8, true).string(aca_data.BoardMeetingNo).style(topDataStyle) +wx.cell(12, 3, 12, 8, true).string(aca_data.BoardMeetingDate).style(topDataStyle) + +var topLabelsStyle = { border: borderx, font: { bold: true } }; +wx.cell(6, 2).string('الكلية').style(topLabelsStyle) +wx.cell(7, 2).string('العام الدراسي').style(topLabelsStyle) +wx.cell(8, 2).string('المستوى').style(topLabelsStyle) +wx.cell(9, 2).string('القسم').style(topLabelsStyle) +wx.cell(10, 2).string('التخصص').style(topLabelsStyle) +wx.cell(11, 2).string('رقم اجتماع مجلس الكلية').style(topLabelsStyle) +wx.cell(12, 2).string('تاريخ الاجتماع').style(topLabelsStyle) + +const BigLabels = ['أولا', 'ثانيا', 'ثالثا', 'رابعا', 'خامسا', 'سادسا']; +var currentRow = 14; +var tabNum = 0; +let vTitle = ''; + +var regStud = aca_data.dataTables.RegStudents; +wx.cell(currentRow, 2).string('اولاً: الطلاب النظاميون:').style({ font: { bold: true, size: 16 } }) +GenerateACADataTable(wx, currentRow + 1, aca_data, regStud) +currentRow += Object.keys(regStud).length + 6; +wx.cell(currentRow - 2, 2).string('المجموع').style(sumStyle) +wx.cell(currentRow - 2, 3).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 3)}:${xl.getExcelCellRef(currentRow - 3, 3)})`).style(sumStyle) +wx.cell(currentRow - 2, 4).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 4)}:${xl.getExcelCellRef(currentRow - 3, 4)})`).style(sumStyle) +wx.cell(currentRow - 2, 5).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 5)}:${xl.getExcelCellRef(currentRow - 3, 5)})`).style(sumStyle) +wx.cell(currentRow - 2, 6).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 6)}:${xl.getExcelCellRef(currentRow - 3, 6)})`).style(sumStyle) +wx.cell(currentRow - 2, 7).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 7)}:${xl.getExcelCellRef(currentRow - 3, 7)})`).style(sumStyle) +wx.cell(currentRow - 2, 8).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 8)}:${xl.getExcelCellRef(currentRow - 3, 8)})`).style(sumStyle) +tabNum += 1; + +if (aca_data.HonorsOrGraduates) { + vTitle = BigLabels[tabNum] + ': ' + 'الحاصلون على مرتبة الشرف (نظاميون)'; + var regStudHonours = aca_data.dataTables.RegStudentsHonours; + wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) + GenerateACADataTable(wx, currentRow + 1, aca_data, regStudHonours) + currentRow += Object.keys(regStudHonours).length + 6; + var crw = currentRow - 2; + wx.cell(crw, 2).string('المجموع').style(sumStyle) + wx.cell(crw, 3).formula(`SUM(${xl.getExcelCellRef(crw - 4, 3)}:${xl.getExcelCellRef(crw - 1, 3)})`).style(sumStyle) + wx.cell(crw, 4).formula(`SUM(${xl.getExcelCellRef(crw - 4, 4)}:${xl.getExcelCellRef(crw - 1, 4)})`).style(sumStyle) + wx.cell(crw, 5).formula(`SUM(${xl.getExcelCellRef(crw - 4, 5)}:${xl.getExcelCellRef(crw - 1, 5)})`).style(sumStyle) + wx.cell(crw, 6).formula(`SUM(${xl.getExcelCellRef(crw - 4, 6)}:${xl.getExcelCellRef(crw - 1, 6)})`).style(sumStyle) + wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 4, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) + wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 4, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) + tabNum += 1; +} + +vTitle = BigLabels[tabNum] + ': ' + 'الممتحنون من الخارج'; +var extStud = aca_data.dataTables.ExtStudents; +wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) +GenerateACADataTable(wx, currentRow + 1, aca_data, extStud) +currentRow += Object.keys(extStud).length + 6; +var crw = currentRow - 2; +wx.cell(crw, 2).string('المجموع').style(sumStyle) +wx.cell(crw, 3).formula(`SUM(${xl.getExcelCellRef(crw - 7, 3)}:${xl.getExcelCellRef(crw - 1, 3)})`).style(sumStyle) +wx.cell(crw, 4).formula(`SUM(${xl.getExcelCellRef(crw - 7, 4)}:${xl.getExcelCellRef(crw - 1, 4)})`).style(sumStyle) +wx.cell(crw, 5).formula(`SUM(${xl.getExcelCellRef(crw - 7, 5)}:${xl.getExcelCellRef(crw - 1, 5)})`).style(sumStyle) +wx.cell(crw, 6).formula(`SUM(${xl.getExcelCellRef(crw - 7, 6)}:${xl.getExcelCellRef(crw - 1, 6)})`).style(sumStyle) +wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 7, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) +wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 7, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) + +tabNum += 1; + +if (aca_data.HonorsOrGraduates) { + vTitle = BigLabels[tabNum] + ': ' + 'الحاصلون على مرتبة الشرف (خارجيون) '; + var extStudHonours = aca_data.dataTables.ExtStudentsHonours; + wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) + GenerateACADataTable(wx, currentRow + 1, aca_data, extStudHonours) + currentRow += Object.keys(extStudHonours).length + 6; + var crw = currentRow - 2; + wx.cell(crw, 2).string('المجموع').style(sumStyle) + wx.cell(crw, 3).formula(`SUM(${xl.getExcelCellRef(crw - 4, 3)}:${xl.getExcelCellRef(crw - 1, 3)})`).style(sumStyle) + wx.cell(crw, 4).formula(`SUM(${xl.getExcelCellRef(crw - 4, 4)}:${xl.getExcelCellRef(crw - 1, 4)})`).style(sumStyle) + wx.cell(crw, 5).formula(`SUM(${xl.getExcelCellRef(crw - 4, 5)}:${xl.getExcelCellRef(crw - 1, 5)})`).style(sumStyle) + wx.cell(crw, 6).formula(`SUM(${xl.getExcelCellRef(crw - 4, 6)}:${xl.getExcelCellRef(crw - 1, 6)})`).style(sumStyle) + wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 4, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) + wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 4, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) +} + +function GenerateACADataTable(ws, srow, acd, dtab, tabNum) { + + if (true) { + var xsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'thin', color: 'black' }, + right: { style: 'thin', color: 'black' }, + top: { style: 'thin', color: 'black' }, + bottom: { style: 'thin', color: 'black' } + } + }; + + var zsty = { + font: { bold: true }, alignment: { horizontal: 'right', vertical: 'center' }, + border: { + left: { style: 'medium', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + bottom: { style: 'thin', color: 'black' } + } + }; + + var r1sty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'medium', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'medium', color: 'black' }, + } + }; + + var r2sty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'medium', color: 'black' }, + right: { style: 'medium', color: 'black' }, + bottom: { style: 'thin', color: 'black' }, + } + }; + + var r3lsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'thin', color: 'black' }, + right: { style: 'medium', color: 'black' }, + bottom: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + } + }; + var r3rsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'medium', color: 'black' }, + right: { style: 'thin', color: 'black' }, + bottom: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + } + }; + + + ws.cell(srow, 2, srow + 2, 2, true).string('الوصف').style({ + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'medium', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'medium', color: 'black' }, + bottom: { style: 'medium', color: 'black' } + } + }); + + ws.cell(srow, 3, srow, 4, true).string('العام الدراسي').style(r1sty) + ws.cell(srow, 5, srow, 6, true).string('العام الدراسي').style(r1sty) + ws.cell(srow, 7, srow, 8, true).string('العام الدراسي').style(r1sty) + + ws.cell(srow + 1, 3, srow + 1, 4, true).string(acd.AcademicYear).style(r2sty) + ws.cell(srow + 1, 5, srow + 1, 6, true).string(acd.AcademicYear_M_1).style(r2sty) + ws.cell(srow + 1, 7, srow + 1, 8, true).string(acd.AcademicYear_M_2).style(r2sty) + + ws.cell(srow + 2, 3).string('العدد').style(r3rsty) + ws.cell(srow + 2, 4).string('النسبة').style(r3lsty) + ws.cell(srow + 2, 5).string('العدد').style(r3rsty) + ws.cell(srow + 2, 6).string('النسبة').style(r3lsty) + ws.cell(srow + 2, 7).string('العدد').style(r3rsty) + ws.cell(srow + 2, 8).string('النسبة').style(r3lsty) + } + var n = 3; + for (var label in dtab) { + var val = dtab[label]; + // console.log(val) + var zlab = val[3] ? val[3] : label; + ws.cell(srow + n, 2).string(zlab).style(zsty) + ws.cell(srow + n, 3).number(val[0]).style(xsty) + ws.cell(srow + n, 5).number(val[1]).style(xsty) + ws.cell(srow + n, 7).number(val[2]).style(xsty) + ws.row(srow + n).height = 17.25; + n++; + } +} + +wx.addChart({ + type: 'chart', + chartType: 'bar', + chartData: { + title: 'الطلاب النظاميون', + dataSeries: [ + { + label: 'العام الحالي', range: "'Sheet2'!$D$18:$D$28", + pattern: 'solidDmnd', catRange: "'Sheet2'!$B$18:$B$28" + }, + { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$18:$F$28", catRange: "'Sheet2'!$B$18:$B$28" }, + { label: 'العام الحالي', pattern: 'wdDnDiag', range: "'Sheet2'!$H$18:$H$28", catRange: "'Sheet2'!$B$18:$B$28" }, + ], + dataLegend: [ + + ], + catAxisLabels: { + range: "'Sheet2'!$B$18:$B$28" + } + }, + position: { + type: 'twoCellAnchor', + from: { + col: 2, row: 69, colOff: 19050, rowOff: 76200 + }, + to: { + col: 8, row: 85, colOff: 600075, rowOff: 190500 + } + } +}) + +// wx.addChart({ +// type: 'chart', +// chartType: 'bar', +// chartData: { +// title: 'الطلاب النظاميون', +// dataSeries: [ +// { +// label: 'العام الحالي', range: "'Sheet2'!$D$18:$D$28", +// pattern: 'solidDmnd', catRange: "'Sheet2'!$B$18:$B$28" +// }, +// { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$18:$F$28", catRange: "'Sheet2'!$B$18:$B$28" }, +// { label: 'العام الحالي', pattern: 'wdDnDiag', range: "'Sheet2'!$H$18:$H$28", catRange: "'Sheet2'!$B$18:$B$28" }, +// ], +// dataLegend: [ + +// ], +// catAxisLabels: { +// range: "'Sheet2'!$B$18:$B$28" +// } +// }, +// position: { +// type: 'twoCellAnchor', +// from: { +// col: 10, row: 1, colOff: 19050, rowOff: 76200 +// }, +// to: { +// col: 16, row: 17, colOff: 600075, rowOff: 190500 +// } +// } +// }) + +wb.write('Excel.xlsx') +var dir = require('path').join(__dirname, '/testzip') +fs.createReadStream('Excel.xlsx').pipe(unzipper.Extract({ path: dir })); diff --git a/source/lib/drawing/chart.js b/source/lib/drawing/chart.js new file mode 100644 index 00000000..47247fc1 --- /dev/null +++ b/source/lib/drawing/chart.js @@ -0,0 +1,258 @@ +const Drawing = require('./drawing.js'); +const xmlbuilder = require('xmlbuilder'); +const EMU = require('../classes/emu.js') +const { v4: uuidv4 } = require('uuid'); + +class Chart extends Drawing { + /** + * Element representing an Excel Picture subclass of Drawing + * @property {String} kind Kind of picture + */ + constructor(opts) { + super(); + this.kind = 'chart'; + this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart'; + this._title; + this.chartData = opts.chartData; + + if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) { + this.anchor(opts.position.type, opts.position.from, opts.position.to); + } else if (opts.position.type === 'absoluteAnchor') { + this.position(opts.position.x, opts.position.y); + } else { + throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor'); + } + } + + get name() { + return this._name; + } + set name(newName) { + this._name = newName; + } + get id() { + return this._id; + } + set id(id) { + this._id = id; + } + + get rId() { + return 'rId' + this._id; + } + + get description() { + return this._descr !== null ? this._descr : this._name; + } + set description(desc) { + this._descr = desc; + } + + get title() { + return this._title !== null ? this._title : this._name; + } + set title(title) { + this._title = title; + } + + get extension() { + return this._extension; + } + + get width() { + let inWidth = this._pxWidth / 96; + let emu = new EMU(inWidth + 'in'); + return emu.value; + } + + get height() { + let inHeight = this._pxHeight / 96; + let emu = new EMU(inHeight + 'in'); + return emu.value; + } + + /** + * @alias Picture.addToXMLele + * @desc When generating Workbook output, attaches pictures to the drawings xml file + * @func Picture.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + addToXMLele(ele) { + + let anchorEle = ele.ele('xdr:' + this.anchorType); + + // if (this.editAs !== null) { + // anchorEle.att('editAs', this.editAs); + // } + + if (this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y); + } + + if (this.anchorType !== 'absoluteAnchor') { + let af = this.anchorFrom; + let afEle = anchorEle.ele('xdr:from'); + afEle.ele('xdr:col').text(af.col); + afEle.ele('xdr:colOff').text(af.colOff); + afEle.ele('xdr:row').text(af.row); + afEle.ele('xdr:rowOff').text(af.rowOff); + } + + if (this.anchorTo && this.anchorType === 'twoCellAnchor') { + let at = this.anchorTo; + let atEle = anchorEle.ele('xdr:to'); + atEle.ele('xdr:col').text(at.col); + atEle.ele('xdr:colOff').text(at.colOff); + atEle.ele('xdr:row').text(at.row); + atEle.ele('xdr:rowOff').text(at.rowOff); + } + + if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height); + } + + let graphicFrame = anchorEle.ele('xdr:graphicFrame'); + graphicFrame.att("macro", ""); + let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr'); + let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att("id", this.id).att("name", "Chart " + this.id); + // this.axExtId1 = uuidv4() + // this.axExtId2 = uuidv4(); + + // let extLst = cNvPrEle.ele("a:extLst") + // let aext = extLst.ele("a:ext").att("uri", this.axExtId1) + // let a16creat = aext.ele("a16:creationId").att("xmlns:a16", "http://schemas.microsoft.com/office/drawing/2014/main") + // a16creat.att("id", this.axExtId2) + nvGraphicFramePr.ele("xdr:cNvGraphicFramePr").ele("a:graphicFrameLocks"); + + let xfrm = graphicFrame.ele("xdr:xfrm") + xfrm.ele("a:off").att("x", 0).att("y", 0) + xfrm.ele("a:ext").att("cx", 0).att("cy", 0) + + let graphicData = graphicFrame.ele("a:graphic").ele("a:graphicData").att("uri", "http://schemas.openxmlformats.org/drawingml/2006/chart") + graphicData.ele("c:chart").att("xmlns:c", "http://schemas.openxmlformats.org/drawingml/2006/chart") + .att("xmlns:r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships") + .att("r:id", this.rId) + + anchorEle.ele('xdr:clientData'); + } + + chartPartXML(xmlcx) { + console.log('chartPartXML') + xmlcx.ele('c:date1904').att('val', 0); + xmlcx.ele('c:lang').att('val', 'en-US'); + xmlcx.ele('c:roundedCorners').att('val', 0); + let xchart = xmlcx.ele('c:chart'); + let title = xchart.ele('c:title'); + let title_rich = title.ele('c:tx').ele('c:rich') + title_rich.ele('a:bodyPr') + title_rich.ele('a:lstStyle') + let titlep = title_rich.ele('a:p'); + titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400) + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + let titlepr = titlep.ele('a:r') + titlepr.ele("a:rPr").att("sz", 1400).att('lang', 'ar-SA') + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + titlepr.ele('a:t', this.chartData.title) + titlep.ele("a:endParaRPr").att("sz", 1400).att('lang', 'en-US') + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + title.ele("c:overlay").att("val", 1) + + xchart.ele("c:autoTitleDeleted").att("val", 0); + + let plotArea = xchart.ele("c:plotArea") + let layout = plotArea.ele("c:layout") + let ml = layout.ele('c:manualLayout') + ml.ele('c:layoutTarget').att('val', 'inner') + ml.ele('c:xMode').att('val', 'edge') + ml.ele('c:yMode').att('val', 'edge') + ml.ele('c:x').att('val', 0.1165589095638537) + ml.ele('c:y').att('val', 0.11177904648711365) + ml.ele('c:w').att('val', 0.7404672613266795) + ml.ele('c:h').att('val', 0.66684834207044885) + + let barChart = plotArea.ele("c:barChart") + let catAx = plotArea.ele("c:catAx") + let valAx = plotArea.ele("c:valAx") + + barChart.ele("c:barDir").att("val", "col") + barChart.ele("c:grouping").att("val", "clustered") + barChart.ele("c:varyColors").att("val", 0) + for (var sno in this.chartData.dataSeries) { + var sx = this.chartData.dataSeries[sno]; + // console.log(sno, sx) + let ser = barChart.ele("c:ser") + ser.ele("c:idx").att("val", sno); + ser.ele("c:order").att("val", sno); + ser.ele('c:tx').ele('c:v', sx.label); + let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern); + + ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1'); + ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1'); + ser.ele('c:invertIfNegative').att('val', 0) + + if (sx.range) { + ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range) + } + // if (sx.catRange){ + // ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange); + // } + // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart') + // .att('uri', this.axExtId1) + // .ele('c16:uniqueId').att('val', this.axExtId2) + } + let dLbl = barChart.ele('c:dLbls'); + dLbl.ele('c:showLegendKey').att('val',0) + dLbl.ele('c:showVal').att('val',0) + dLbl.ele('c:showCatName').att('val',0) + dLbl.ele('c:showSerName').att('val',0) + dLbl.ele('c:showPercent').att('val',0) + dLbl.ele('c:showBubbleSize').att('val',0) + + barChart.ele('c:gapWidth').att('val', 150) + barChart.ele('c:axId').att('val', 361690304) + barChart.ele('c:axId').att('val', 1) + + catAx.ele('c:axId').att('val', 361690304) + catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax') + catAx.ele('c:delete').att('val', 0) + catAx.ele('c:axPos').att('val', 'b') + catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0) + catAx.ele('c:majorTickMark').att('val', 'out') + catAx.ele('c:minorTickMark').att('val', 'none') + catAx.ele('c:tickLblPos').att('val', 'nextTo') + catAx.ele('c:crossAx').att('val', 1) + catAx.ele('c:crosses').att('val', "autoZero") + catAx.ele('c:auto').att('val', 1) + catAx.ele('c:lblAlgn').att('val', "ctr") + catAx.ele('c:lblOffset').att('val', 100) + catAx.ele('c:noMultiLvlLbl').att('val', 0) + + valAx.ele('c:axId').att('val', 1) + valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax') + valAx.ele('c:delete').att('val', 0) + valAx.ele('c:axPos').att('val', 'l') + valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1) + valAx.ele('c:majorTickMark').att('val', 'out') + valAx.ele('c:minorTickMark').att('val', 'none') + valAx.ele('c:tickLblPos').att('val', 'nextTo') + valAx.ele('c:crossAx').att('val', 361690304) + valAx.ele('c:crosses').att('val', "autoZero") + valAx.ele('c:crossBetween').att('val', "between") + + + let legend = xchart.ele("c:legend"); + legend.ele("c:legendPos").att("val", "r"); + legend.ele("c:overlay").att("val", "0"); + let txPr = legend.ele("c:txPr"); txPr.ele("a:bodyPr"); + txPr.ele("a:lstStyle"); + let txPrp = txPr.ele("a:p"); + txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200) + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + txPrp.ele("a:endParaRPr").att('lang', 'en-US') + xchart.ele("c:plotVisOnly").att("val", 1) + xchart.ele("c:dispBlanksAs").att("val", "gap") + xchart.ele("c:showDLblsOverMax").att("val", 0) + } +} + +module.exports = Chart; \ No newline at end of file diff --git a/source/lib/drawing/index.js b/source/lib/drawing/index.js index 0b6a21fd..9e09a375 100644 --- a/source/lib/drawing/index.js +++ b/source/lib/drawing/index.js @@ -1,6 +1,7 @@ let Drawing = require('./drawing.js'); let Picture = require('./picture.js'); -let headerFooterPicture = require('./headerFooterPicture.js') +let headerFooterPicture = require('./headerFooterPicture.js'); +let Chart = require('./chart.js') class DrawingCollection { constructor() { @@ -21,6 +22,10 @@ class DrawingCollection { let xPic = new headerFooterPicture(opts); this.drawings.push(xPic ); return xPic; + case 'chart': + let cPic = new Chart(opts); + this.drawings.push(cPic); + return cPic default: throw new TypeError('this option is not yet supported'); } diff --git a/source/lib/workbook/builder.js b/source/lib/workbook/builder.js index eb0dda5d..88eb369b 100644 --- a/source/lib/workbook/builder.js +++ b/source/lib/workbook/builder.js @@ -8,13 +8,13 @@ let addRootContentTypesXML = (promiseObj) => { // Required as stated in §12.2 return new Promise((resolve, reject) => { let xml = xmlbuilder.create( - 'Types', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } - ) + 'Types', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } + ) .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); let contentTypesAdded = []; @@ -23,11 +23,13 @@ let addRootContentTypesXML = (promiseObj) => { if (s.drawingCollection.length > 0) { s.drawingCollection.drawings.forEach((d) => { if (extensionsAdded.indexOf(d.extension) < 0) { - let typeRef = d.contentType + '.' + d.extension; - if (contentTypesAdded.indexOf(typeRef) < 0) { - xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension); + if (d.contentType) { + let typeRef = d.contentType + '.' + d.extension; + if (contentTypesAdded.indexOf(typeRef) < 0) { + xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension); + } + extensionsAdded.push(d.extension); } - extensionsAdded.push(d.extension); } }); } @@ -37,13 +39,13 @@ let addRootContentTypesXML = (promiseObj) => { extensionsAdded.push('vml'); } } - - if(s.legacyDrawingHeaderFooter.length > 0){ + + if (s.legacyDrawingHeaderFooter.length > 0) { if (extensionsAdded.indexOf('vml') < 0) { xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing'); extensionsAdded.push('vml'); } - if (extensionsAdded.indexOf('png') < 0){ + if (extensionsAdded.indexOf('png') < 0) { xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png'); extensionsAdded.push('png'); } @@ -54,24 +56,30 @@ let addRootContentTypesXML = (promiseObj) => { xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml'); promiseObj.wb.sheets.forEach((s, i) => { xml.ele('Override') - .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`) - .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml') - + .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`) + .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml') + if (s.drawingCollection.length > 0) { xml.ele('Override') - .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') - .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml') + .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') + .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml') } if (Object.keys(s.comments).length > 0) { xml.ele('Override') - .att('PartName', '/xl/comments' + s.sheetId + '.xml') - .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml') + .att('PartName', '/xl/comments' + s.sheetId + '.xml') + .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml') } }); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml'); + promiseObj.wb.chartsCollection.items.forEach((s, i) => { + console.log('Charts to Content Types') + xml.ele('Override') + .att('PartName', `/xl/charts/chart${i + 1}.xml`) + .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml') + }) let xmlString = xml.doc().end(promiseObj.xmlOutVars); promiseObj.xlsx.file('[Content_Types].xml', xmlString); @@ -83,13 +91,13 @@ let addRootRelsXML = (promiseObj) => { // Required as stated in §12.2 return new Promise((resolve, reject) => { let xml = xmlbuilder.create( - 'Relationships', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } - ) + 'Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } + ) .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); xml @@ -117,17 +125,18 @@ let addWorkbookXML = (promiseObj) => { let xml = xmlbuilder.create( 'workbook', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } ); xml.att('mc:Ignorable', 'x15'); xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'); + xml.att('xmlns:x', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); let booksViewEle = xml.ele('bookViews'); let workbookViewEle = booksViewEle.ele('workbookView'); @@ -215,6 +224,14 @@ let addWorkbookXML = (promiseObj) => { promiseObj.wb.definedNameCollection.addToXMLele(xml); } + if(promiseObj.wb.opts.calculationProperties){ + let calcPr = xml.ele('x:calcPr'); + if(promiseObj.wb.opts.calculationProperties.fullCalculationOnLoad){ + // calcPr.att('calcId', 15234) + calcPr.att('fullCalcOnLoad', 1) + } + } + let xmlString = xml.doc().end(promiseObj.xmlOutVars); promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString); resolve(promiseObj); @@ -227,13 +244,13 @@ let addWorkbookRelsXML = (promiseObj) => { return new Promise((resolve, reject) => { let xml = xmlbuilder.create( - 'Relationships', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } - ) + 'Relationships', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } + ) .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); xml @@ -266,16 +283,16 @@ let addWorkbookRelsXML = (promiseObj) => { let addCorePropertiesXML = (promiseObj) => { let xml = xmlbuilder.create( 'cp:coreProperties', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true - } + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true + } ) - .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties') - .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/') - .att('xmlns:dcterms', 'http://purl.org/dc/terms/') - .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/') - .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); + .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties') + .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/') + .att('xmlns:dcterms', 'http://purl.org/dc/terms/') + .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/') + .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); xml.ele('dc:creator').text(promiseObj.wb.author); xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author); @@ -364,13 +381,13 @@ let addSharedStringsXML = (promiseObj) => { return new Promise((resolve, reject) => { let xml = xmlbuilder.create( - 'sst', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } - ) + 'sst', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } + ) .att('count', promiseObj.wb.sharedStrings.length) .att('uniqueCount', promiseObj.wb.sharedStrings.length) .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); @@ -455,13 +472,13 @@ let addStylesXML = (promiseObj) => { return new Promise((resolve, reject) => { let xml = xmlbuilder.create( - 'styleSheet', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } - ) + 'styleSheet', { + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } + ) .att('mc:Ignorable', 'x14ac') .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main') .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006') @@ -519,33 +536,32 @@ let addStylesXML = (promiseObj) => { let addDrawingsXML = (promiseObj) => { return new Promise((resolve) => { - if (!promiseObj.wb.mediaCollection.isEmpty) { + if (!promiseObj.wb.mediaCollection.isEmpty || !promiseObj.wb.chartsCollection.isEmpty) { promiseObj.wb.sheets.forEach((ws) => { if (!ws.drawingCollection.isEmpty) { let drawingRelXML = xmlbuilder.create('Relationships', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - }) + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + }) .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); let drawingsXML = xmlbuilder.create( 'xdr:wsDr', { - 'version': '1.0', - 'encoding': 'UTF-8', - 'standalone': true, - 'allowSurrogateChars': true - } + 'version': '1.0', + 'encoding': 'UTF-8', + 'standalone': true, + 'allowSurrogateChars': true + } ); drawingsXML .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main') .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); ws.drawingCollection.drawings.forEach((d) => { - if (d.kind === 'image') { let target = 'image' + d.id + '.' + d.extension; @@ -558,9 +574,25 @@ let addDrawingsXML = (promiseObj) => { .att('Type', d.type); } + if (d.kind == 'chart') { + let target = 'chart' + d.id + '.xml'; + let chartBuilder = xmlbuilder.create('c:chartSpace', { + 'version': '1.0', 'encoding': 'UTF-8', 'standalone': true + }) + .att('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart') + .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main') + .att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships') + .att('xmlns:c16r2', 'http://schemas.microsoft.com/office/drawing/2015/06/chart'); + + d.chartPartXML(chartBuilder); + let chartXMLStr = chartBuilder.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').folder('charts').file(target, chartXMLStr); + drawingRelXML.ele('Relationship') + .att('Id', d.rId) + .att('Target', '../charts/' + target) + .att('Type', d.type); - - + } d.addToXMLele(drawingsXML); }); @@ -582,7 +614,7 @@ let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { if (!promiseObj.wb.mediaCollection.isEmpty) { promiseObj.wb.sheets.forEach((ws) => { - + if (!ws.legacyDrawingHeaderFooter.isEmpty) { let drawingRelXML = xmlbuilder.create('Relationships', { @@ -591,15 +623,15 @@ let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { 'standalone': true, 'allowSurrogateChars': true }) - .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); + .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); - let drawingsVML = xmlbuilder.begin().ele('xml'); - drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml') - drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); - drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); + let drawingsVML = xmlbuilder.begin().ele('xml'); + drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml') + drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office'); + drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); - const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit'); - sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); + const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit'); + sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId); const st = drawingsVML.ele('v:shapetype') .att('id', '_x0000_t75') @@ -625,11 +657,11 @@ let addLegacyHeaderFooterDrawingsXML = (promiseObj) => { vf.ele('v:f').att('eqn', "sum @10 21600 0"); st.ele('v:path') - .att('o:extrusionok','f') - .att('gradientshapeok','t') - .att('o:connecttype','rect') + .att('o:extrusionok', 'f') + .att('gradientshapeok', 't') + .att('o:connecttype', 'rect') - st.ele('o:lock').att('v:ext','edit').att('aspectratio','t'); + st.ele('o:lock').att('v:ext', 'edit').att('aspectratio', 't'); // const sh = drawingsVML.ele('v:shape'); // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75') diff --git a/source/lib/workbook/chartsCollection.js b/source/lib/workbook/chartsCollection.js new file mode 100644 index 00000000..5834c34a --- /dev/null +++ b/source/lib/workbook/chartsCollection.js @@ -0,0 +1,20 @@ +class ChartsCollection { + constructor() { + this.items = []; + } + + add(item) { + this.items.push(item); + return this.items.length; + } + + get isEmpty() { + if (this.items.length === 0) { + return true; + } else { + return false; + } + } +} + +module.exports = ChartsCollection; \ No newline at end of file diff --git a/source/lib/workbook/workbook.js b/source/lib/workbook/workbook.js index cc171e9c..7e925c05 100644 --- a/source/lib/workbook/workbook.js +++ b/source/lib/workbook/workbook.js @@ -9,6 +9,7 @@ const Fill = require('../style/classes/fill.js'); const Font = require('../style/classes/font'); const DXFCollection = require('./dxfCollection.js'); const MediaCollection = require('./mediaCollection.js'); +const ChartsCollection = require('./chartsCollection.js'); const DefinedNameCollection = require('../classes/definedNameCollection.js'); const types = require('../types/index.js'); const builder = require('./builder.js'); @@ -95,6 +96,7 @@ class Workbook { this.stylesLookup = new Map(); this.dxfCollection = new DXFCollection(this); this.mediaCollection = new MediaCollection(); + this.chartsCollection = new ChartsCollection(); this.definedNameCollection = new DefinedNameCollection(); this.styleData = { 'numFmts': [], diff --git a/source/lib/worksheet/worksheet.js b/source/lib/worksheet/worksheet.js index 1e38a8ce..e6dd6837 100644 --- a/source/lib/worksheet/worksheet.js +++ b/source/lib/worksheet/worksheet.js @@ -275,6 +275,13 @@ class Worksheet { return newImage; } + addChart(opts){ + let mediaID = this.wb.chartsCollection.add(opts); + let newImage = this.drawingCollection.add(opts); + newImage.id = mediaID; + return newImage; + } + /** * @func Worksheet.addPageBreak * @param {string} type From e001b94fed1e7af5d76b3e4396850726aa6a6878 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Mon, 11 Jan 2021 17:53:22 +0300 Subject: [PATCH 09/12] Added Charts with and removed some console log statements --- distribution/lib/drawing/index.js | 5 + distribution/lib/drawing/index.js.map | 2 +- distribution/lib/workbook/builder.js | 37 ++- distribution/lib/workbook/builder.js.map | 2 +- distribution/lib/workbook/workbook.js | 2 + distribution/lib/workbook/workbook.js.map | 2 +- distribution/lib/worksheet/worksheet.js | 8 + distribution/lib/worksheet/worksheet.js.map | 2 +- sample3.js | 259 ++++++++++++++++---- source/lib/drawing/chart.js | 72 ++++-- source/lib/workbook/builder.js | 1 - 11 files changed, 313 insertions(+), 79 deletions(-) diff --git a/distribution/lib/drawing/index.js b/distribution/lib/drawing/index.js index 2340effd..2e109082 100644 --- a/distribution/lib/drawing/index.js +++ b/distribution/lib/drawing/index.js @@ -7,6 +7,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var Drawing = require('./drawing.js'); var Picture = require('./picture.js'); var headerFooterPicture = require('./headerFooterPicture.js'); +var Chart = require('./chart.js'); var DrawingCollection = function () { function DrawingCollection() { @@ -27,6 +28,10 @@ var DrawingCollection = function () { var xPic = new headerFooterPicture(opts); this.drawings.push(xPic); return xPic; + case 'chart': + var cPic = new Chart(opts); + this.drawings.push(cPic); + return cPic; default: throw new TypeError('this option is not yet supported'); } diff --git a/distribution/lib/drawing/index.js.map b/distribution/lib/drawing/index.js.map index 52bfa6b3..2a60c6b4 100644 --- a/distribution/lib/drawing/index.js.map +++ b/distribution/lib/drawing/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/drawing/index.js"],"names":["Drawing","require","Picture","headerFooterPicture","DrawingCollection","drawings","opts","type","newPic","push","xPic","TypeError","length","module","exports"],"mappings":";;;;;;AAAA,IAAIA,UAAUC,QAAQ,cAAR,CAAd;AACA,IAAIC,UAAUD,QAAQ,cAAR,CAAd;AACA,IAAIE,sBAAsBF,QAAQ,0BAAR,CAA1B;;IAEMG,iB;AACF,iCAAc;AAAA;;AACV,aAAKC,QAAL,GAAgB,EAAhB;AACH;;;;4BAMGC,I,EAAM;AACN,oBAAQA,KAAKC,IAAb;AACA,qBAAK,SAAL;AACI,wBAAIC,SAAS,IAAIN,OAAJ,CAAYI,IAAZ,CAAb;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBD,MAAnB;AACA,2BAAOA,MAAP;AACJ,qBAAK,qBAAL;AACI,wBAAIE,OAAO,IAAIP,mBAAJ,CAAwBG,IAAxB,CAAX;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBC,IAAnB;AACA,2BAAOA,IAAP;AACJ;AACI,0BAAM,IAAIC,SAAJ,CAAc,kCAAd,CAAN;AAVJ;AAYH;;;4BAjBY;AACT,mBAAO,KAAKN,QAAL,CAAcO,MAArB;AACH;;;4BAiBa;AACV,gBAAI,KAAKP,QAAL,CAAcO,MAAd,KAAyB,CAA7B,EAAgC;AAC5B,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAGLC,OAAOC,OAAP,GAAiB,EAAEV,oCAAF,EAAqBJ,gBAArB,EAA8BE,gBAA9B,EAAuCC,wCAAvC,EAAjB","file":"index.js","sourcesContent":["let Drawing = require('./drawing.js');\r\nlet Picture = require('./picture.js');\r\nlet headerFooterPicture = require('./headerFooterPicture.js')\r\n\r\nclass DrawingCollection {\r\n constructor() {\r\n this.drawings = [];\r\n }\r\n\r\n get length() {\r\n return this.drawings.length;\r\n }\r\n\r\n add(opts) {\r\n switch (opts.type) {\r\n case 'picture':\r\n let newPic = new Picture(opts);\r\n this.drawings.push(newPic);\r\n return newPic;\r\n case 'headerFooterPicture':\r\n let xPic = new headerFooterPicture(opts);\r\n this.drawings.push(xPic );\r\n return xPic;\r\n default:\r\n throw new TypeError('this option is not yet supported');\r\n }\r\n }\r\n\r\n get isEmpty() {\r\n if (this.drawings.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = { DrawingCollection, Drawing, Picture, headerFooterPicture };\r\n"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/drawing/index.js"],"names":["Drawing","require","Picture","headerFooterPicture","Chart","DrawingCollection","drawings","opts","type","newPic","push","xPic","cPic","TypeError","length","module","exports"],"mappings":";;;;;;AAAA,IAAIA,UAAUC,QAAQ,cAAR,CAAd;AACA,IAAIC,UAAUD,QAAQ,cAAR,CAAd;AACA,IAAIE,sBAAsBF,QAAQ,0BAAR,CAA1B;AACA,IAAIG,QAAQH,QAAQ,YAAR,CAAZ;;IAEMI,iB;AACF,iCAAc;AAAA;;AACV,aAAKC,QAAL,GAAgB,EAAhB;AACH;;;;4BAMGC,I,EAAM;AACN,oBAAQA,KAAKC,IAAb;AACA,qBAAK,SAAL;AACI,wBAAIC,SAAS,IAAIP,OAAJ,CAAYK,IAAZ,CAAb;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBD,MAAnB;AACA,2BAAOA,MAAP;AACJ,qBAAK,qBAAL;AACI,wBAAIE,OAAO,IAAIR,mBAAJ,CAAwBI,IAAxB,CAAX;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBC,IAAnB;AACA,2BAAOA,IAAP;AACJ,qBAAK,OAAL;AACI,wBAAIC,OAAO,IAAIR,KAAJ,CAAUG,IAAV,CAAX;AACA,yBAAKD,QAAL,CAAcI,IAAd,CAAmBE,IAAnB;AACA,2BAAOA,IAAP;AACJ;AACI,0BAAM,IAAIC,SAAJ,CAAc,kCAAd,CAAN;AAdJ;AAgBH;;;4BArBY;AACT,mBAAO,KAAKP,QAAL,CAAcQ,MAArB;AACH;;;4BAqBa;AACV,gBAAI,KAAKR,QAAL,CAAcQ,MAAd,KAAyB,CAA7B,EAAgC;AAC5B,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAGLC,OAAOC,OAAP,GAAiB,EAAEX,oCAAF,EAAqBL,gBAArB,EAA8BE,gBAA9B,EAAuCC,wCAAvC,EAAjB","file":"index.js","sourcesContent":["let Drawing = require('./drawing.js');\r\nlet Picture = require('./picture.js');\r\nlet headerFooterPicture = require('./headerFooterPicture.js');\r\nlet Chart = require('./chart.js')\r\n\r\nclass DrawingCollection {\r\n constructor() {\r\n this.drawings = [];\r\n }\r\n\r\n get length() {\r\n return this.drawings.length;\r\n }\r\n\r\n add(opts) {\r\n switch (opts.type) {\r\n case 'picture':\r\n let newPic = new Picture(opts);\r\n this.drawings.push(newPic);\r\n return newPic;\r\n case 'headerFooterPicture':\r\n let xPic = new headerFooterPicture(opts);\r\n this.drawings.push(xPic );\r\n return xPic;\r\n case 'chart':\r\n let cPic = new Chart(opts);\r\n this.drawings.push(cPic);\r\n return cPic\r\n default:\r\n throw new TypeError('this option is not yet supported');\r\n }\r\n }\r\n\r\n get isEmpty() {\r\n if (this.drawings.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = { DrawingCollection, Drawing, Picture, headerFooterPicture };\r\n"]} \ No newline at end of file diff --git a/distribution/lib/workbook/builder.js b/distribution/lib/workbook/builder.js index 290b5ae8..1b3f641c 100644 --- a/distribution/lib/workbook/builder.js +++ b/distribution/lib/workbook/builder.js @@ -24,11 +24,13 @@ var addRootContentTypesXML = function addRootContentTypesXML(promiseObj) { if (s.drawingCollection.length > 0) { s.drawingCollection.drawings.forEach(function (d) { if (extensionsAdded.indexOf(d.extension) < 0) { - var typeRef = d.contentType + '.' + d.extension; - if (contentTypesAdded.indexOf(typeRef) < 0) { - xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension); + if (d.contentType) { + var typeRef = d.contentType + '.' + d.extension; + if (contentTypesAdded.indexOf(typeRef) < 0) { + xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension); + } + extensionsAdded.push(d.extension); } - extensionsAdded.push(d.extension); } }); } @@ -66,6 +68,9 @@ var addRootContentTypesXML = function addRootContentTypesXML(promiseObj) { xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml'); + promiseObj.wb.chartsCollection.items.forEach(function (s, i) { + xml.ele('Override').att('PartName', '/xl/charts/chart' + (i + 1) + '.xml').att('ContentType', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'); + }); var xmlString = xml.doc().end(promiseObj.xmlOutVars); promiseObj.xlsx.file('[Content_Types].xml', xmlString); @@ -108,6 +113,7 @@ var addWorkbookXML = function addWorkbookXML(promiseObj) { xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'); + xml.att('xmlns:x', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); var booksViewEle = xml.ele('bookViews'); var workbookViewEle = booksViewEle.ele('workbookView'); @@ -192,6 +198,14 @@ var addWorkbookXML = function addWorkbookXML(promiseObj) { promiseObj.wb.definedNameCollection.addToXMLele(xml); } + if (promiseObj.wb.opts.calculationProperties) { + var calcPr = xml.ele('x:calcPr'); + if (promiseObj.wb.opts.calculationProperties.fullCalculationOnLoad) { + // calcPr.att('calcId', 15234) + calcPr.att('fullCalcOnLoad', 1); + } + } + var xmlString = xml.doc().end(promiseObj.xmlOutVars); promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString); resolve(promiseObj); @@ -440,7 +454,7 @@ var addStylesXML = function addStylesXML(promiseObj) { var addDrawingsXML = function addDrawingsXML(promiseObj) { return new Promise(function (resolve) { - if (!promiseObj.wb.mediaCollection.isEmpty) { + if (!promiseObj.wb.mediaCollection.isEmpty || !promiseObj.wb.chartsCollection.isEmpty) { promiseObj.wb.sheets.forEach(function (ws) { if (!ws.drawingCollection.isEmpty) { @@ -461,7 +475,6 @@ var addDrawingsXML = function addDrawingsXML(promiseObj) { drawingsXML.att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main').att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing'); ws.drawingCollection.drawings.forEach(function (d) { - if (d.kind === 'image') { var target = 'image' + d.id + '.' + d.extension; @@ -470,7 +483,17 @@ var addDrawingsXML = function addDrawingsXML(promiseObj) { drawingRelXML.ele('Relationship').att('Id', d.rId).att('Target', '../media/' + target).att('Type', d.type); } - + if (d.kind == 'chart') { + var _target = 'chart' + d.id + '.xml'; + var chartBuilder = xmlbuilder.create('c:chartSpace', { + 'version': '1.0', 'encoding': 'UTF-8', 'standalone': true + }).att('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart').att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main').att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships').att('xmlns:c16r2', 'http://schemas.microsoft.com/office/drawing/2015/06/chart'); + + d.chartPartXML(chartBuilder); + var chartXMLStr = chartBuilder.doc().end(promiseObj.xmlOutVars); + promiseObj.xlsx.folder('xl').folder('charts').file(_target, chartXMLStr); + drawingRelXML.ele('Relationship').att('Id', d.rId).att('Target', '../charts/' + _target).att('Type', d.type); + } d.addToXMLele(drawingsXML); }); diff --git a/distribution/lib/workbook/builder.js.map b/distribution/lib/workbook/builder.js.map index 5caf4f93..b1e625ef 100644 --- a/distribution/lib/workbook/builder.js.map +++ b/distribution/lib/workbook/builder.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/workbook/builder.js"],"names":["xmlbuilder","require","JSZip","fs","CTColor","utils","addRootContentTypesXML","promiseObj","Promise","resolve","reject","xml","create","att","contentTypesAdded","extensionsAdded","wb","sheets","forEach","s","i","drawingCollection","length","drawings","d","indexOf","extension","typeRef","contentType","ele","push","Object","keys","comments","legacyDrawingHeaderFooter","sheetId","xmlString","doc","end","xmlOutVars","xlsx","file","addRootRelsXML","folder","addWorkbookXML","booksViewEle","workbookViewEle","opts","workbookView","viewOpts","activeTab","undefined","firstVisibleTab","sheet","hidden","autoFilterDateGrouping","boolToInt","firstSheet","minimized","showHorizontalScroll","showSheetTabs","showVerticalScroll","tabRatio","visibility","windowWidth","windowHeight","xWindow","yWindow","showComments","sheetsEle","name","printArea","startCellRef","getExcelAlpha","startCol","startRow","endCellRef","endCol","endRow","definedNameCollection","addDefinedName","localSheetId","refFormula","isEmpty","addToXMLele","addWorkbookRelsXML","addCorePropertiesXML","text","author","dtStr","Date","toISOString","addWorksheetsXML","curSheet","processNextSheet","thisSheet","generateXML","then","generateRelsXML","generateCommentsXML","generateCommentsVmlXML","catch","e","logger","error","stack","addSharedStringsXML","sharedStrings","txt","Array","thisSI","theseRuns","currProps","curRun","props","k","value","run","thisRun","thisRunProps","bold","italics","strike","outline","shadow","condense","extend","color","thisColor","size","underline","vertAlign","addStylesXML","styleData","numFmts","nfXML","nf","fontXML","fonts","f","fillXML","fills","fXML","borderXML","borders","b","cellXfsXML","styles","addXFtoXMLele","dxfCollection","addDrawingsXML","mediaCollection","ws","drawingRelXML","drawingsXML","kind","target","id","image","imagePath","readFileSync","rId","type","drawingsXMLStr","drawingRelXMLStr","addLegacyHeaderFooterDrawingsXML","drawingsVML","begin","sl","st","vf","writeToBuffer","Worksheet","jszip","generateAsync","buf","workbookXML","result","files","_data","module","exports"],"mappings":";;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ,OAAR,CAAd;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,UAAUH,QAAQ,6BAAR,CAAhB;AACA,IAAMI,QAAQJ,QAAQ,UAAR,CAAd;;AAEA,IAAIK,yBAAyB,SAAzBA,sBAAyB,CAACC,UAAD,EAAgB;AAC3C;AACA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAIC,MAAMX,WAAWY,M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8H,KAAR,CAAcX,IAAd,GAAqB,YAArB;AACA3J,iBAAWiC,IAAX,CAAgBsI,aAAhB,CAA8B9J,GAAG+B,IAAH,CAAQ8H,KAAtC,EACG5E,IADH,CACQ,UAAC8E,GAAD,EAAS;AACbtK,gBAAQsK,GAAR;AACD,OAHH,EAIG1E,KAJH,CAIS,UAACC,CAAD,EAAO;AACZ5F,eAAO4F,CAAP;AACD,OANH;AAOD,KAnBH,EAoBGD,KApBH,CAoBS,UAACC,CAAD,EAAO;AACZ5F,aAAO4F,CAAP;AACD,KAtBH;AAwBD,GAnCM,CAAP;AAoCD,CArCD;;AAuCA;;;;;AAKA,IAAI0E,cAAc,SAAdA,WAAc,CAAChK,EAAD,EAAQ;AACxB,MAAIT,aAAa;AACfS,QAAIA,EADW;AAEfwB,UAAM,IAAItC,KAAJ,EAFS;AAGfqC,gBAAY;AAHG,GAAjB;;AAMA,SAAOK,eAAerC,UAAf,EAA2B0F,IAA3B,CAAgC,UAACgF,MAAD,EAAY;AACjD,WAAOA,OAAOzI,IAAP,CAAY0I,KAAZ,CAAkB,iBAAlB,EAAqCC,KAA5C;AACD,GAFM,CAAP;AAGD,CAVD;;AAYAC,OAAOC,OAAP,GAAiB;AACfV,8BADe;AAEfK;AAFe,CAAjB","file":"builder.js","sourcesContent":["const xmlbuilder = require('xmlbuilder');\r\nconst JSZip = require('jszip');\r\nconst fs = require('fs');\r\nconst CTColor = require('../style/classes/ctColor.js');\r\nconst utils = require('../utils');\r\n\r\nlet addRootContentTypesXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Types', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');\r\n\r\n let contentTypesAdded = [];\r\n let extensionsAdded = [];\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n if (s.drawingCollection.length > 0) {\r\n s.drawingCollection.drawings.forEach((d) => {\r\n if (extensionsAdded.indexOf(d.extension) < 0) {\r\n let typeRef = d.contentType + '.' + d.extension;\r\n if (contentTypesAdded.indexOf(typeRef) < 0) {\r\n xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension);\r\n }\r\n extensionsAdded.push(d.extension);\r\n }\r\n });\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n }\r\n \r\n if(s.legacyDrawingHeaderFooter.length > 0){\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n if (extensionsAdded.indexOf('png') < 0){\r\n xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png');\r\n extensionsAdded.push('png');\r\n }\r\n }\r\n });\r\n xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml');\r\n xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml')\r\n \r\n\r\n if (s.drawingCollection.length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml')\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/comments' + s.sheetId + '.xml') \r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml')\r\n }\r\n });\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.file('[Content_Types].xml', xmlString);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addRootRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId1')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument')\r\n .att('Target', 'xl/workbook.xml');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId2')\r\n .att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties')\r\n .att('Target', 'docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('_rels').file('.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'workbook', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n xml.att('mc:Ignorable', 'x15');\r\n xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');\r\n xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');\r\n\r\n let booksViewEle = xml.ele('bookViews');\r\n let workbookViewEle = booksViewEle.ele('workbookView');\r\n // bookViews (§18.2.1)\r\n if (promiseObj.wb.opts.workbookView) {\r\n const viewOpts = promiseObj.wb.opts.workbookView;\r\n if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) {\r\n workbookViewEle.att('activeTab', viewOpts.activeTab);\r\n } else {\r\n let firstVisibleTab = 0;\r\n for (let i = 0; i < promiseObj.wb.sheets.length; i++) {\r\n const sheet = promiseObj.wb.sheets[i];\r\n if (!sheet.opts.hidden) {\r\n firstVisibleTab = i;\r\n break;\r\n }\r\n }\r\n workbookViewEle.att('activeTab', firstVisibleTab);\r\n }\r\n if (viewOpts.autoFilterDateGrouping) {\r\n workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping));\r\n }\r\n if (viewOpts.firstSheet) {\r\n workbookViewEle.att('firstSheet', viewOpts.firstSheet);\r\n }\r\n if (viewOpts.minimized) {\r\n workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized));\r\n }\r\n if (viewOpts.showHorizontalScroll) {\r\n workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll));\r\n }\r\n if (viewOpts.showSheetTabs) {\r\n workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs));\r\n }\r\n if (viewOpts.showVerticalScroll) {\r\n workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll));\r\n }\r\n if (viewOpts.tabRatio) {\r\n workbookViewEle.att('tabRatio', viewOpts.tabRatio);\r\n }\r\n if (viewOpts.visibility) {\r\n workbookViewEle.att('visibility', viewOpts.visibility);\r\n }\r\n if (viewOpts.windowWidth) {\r\n workbookViewEle.att('windowWidth', viewOpts.windowWidth);\r\n }\r\n if (viewOpts.windowHeight) {\r\n workbookViewEle.att('windowHeight', viewOpts.windowHeight);\r\n }\r\n if (viewOpts.xWindow) {\r\n workbookViewEle.att('xWindow', viewOpts.xWindow);\r\n }\r\n if (viewOpts.yWindow) {\r\n workbookViewEle.att('yWindow', viewOpts.yWindow);\r\n }\r\n if (viewOpts.showComments) {\r\n workbookViewEle.att('showComments', viewOpts.showComments);\r\n }\r\n }\r\n\r\n let sheetsEle = xml.ele('sheets');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n const sheet = sheetsEle.ele('sheet')\r\n .att('name', s.name)\r\n .att('sheetId', i + 1)\r\n .att('r:id', `rId${i + 1}`);\r\n\r\n if (s.opts.hidden) {\r\n sheet.att('state', 'hidden');\r\n }\r\n\r\n if (s.printArea) {\r\n const name = s.name;\r\n const startCellRef = `$${utils.getExcelAlpha(s.printArea.startCol)}$${s.printArea.startRow}`;\r\n const endCellRef = `$${utils.getExcelAlpha(s.printArea.endCol)}$${s.printArea.endRow}`;\r\n s.wb.definedNameCollection.addDefinedName({\r\n name: '_xlnm.Print_Area',\r\n localSheetId: s.localSheetId,\r\n refFormula: `'${name}'!${startCellRef}:${endCellRef}`,\r\n });\r\n }\r\n });\r\n\r\n if (!promiseObj.wb.definedNameCollection.isEmpty) {\r\n promiseObj.wb.definedNameCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 1}`)\r\n .att('Target', 'sharedStrings.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 2}`)\r\n .att('Target', 'styles.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles');\r\n\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${i + 1}`)\r\n .att('Target', `worksheets/sheet${i + 1}.xml`)\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet');\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addCorePropertiesXML = (promiseObj) => {\r\n let xml = xmlbuilder.create(\r\n 'cp:coreProperties', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true\r\n }\r\n )\r\n .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties')\r\n .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/')\r\n .att('xmlns:dcterms', 'http://purl.org/dc/terms/')\r\n .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/')\r\n .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');\r\n\r\n xml.ele('dc:creator').text(promiseObj.wb.author);\r\n xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author);\r\n let dtStr = new Date().toISOString();\r\n xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('docProps').file('core.xml', xmlString);\r\n return promiseObj;\r\n};\r\n\r\nlet addWorksheetsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let curSheet = 0;\r\n\r\n let processNextSheet = () => {\r\n let thisSheet = promiseObj.wb.sheets[curSheet];\r\n if (thisSheet) {\r\n curSheet++;\r\n thisSheet.generateXML()\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n // Add worksheet to zip\r\n promiseObj.xlsx.folder('xl').folder('worksheets').file(`sheet${curSheet}.xml`, xml);\r\n\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateRelsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file(`sheet${curSheet}.xml.rels`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').file(`comments${curSheet}.xml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsVmlXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('drawings').file(`commentsVml${curSheet}.vml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(processNextSheet)\r\n .catch((e) => {\r\n promiseObj.wb.logger.error(e.stack);\r\n });\r\n } else {\r\n resolve(promiseObj);\r\n }\r\n };\r\n processNextSheet();\r\n\r\n });\r\n};\r\n\r\n/**\r\n * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer()\r\n * @private\r\n * @memberof Workbook\r\n * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars\r\n * @return {Promise} Resolves with promiseObj\r\n */\r\nlet addSharedStringsXML = (promiseObj) => {\r\n // §12.3.15 Shared String Table Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'sst', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('count', promiseObj.wb.sharedStrings.length)\r\n .att('uniqueCount', promiseObj.wb.sharedStrings.length)\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n promiseObj.wb.sharedStrings.forEach((s) => {\r\n if (typeof s === 'string') {\r\n xml.ele('si').ele('t').txt(s);\r\n } else if (s instanceof Array) {\r\n\r\n let thisSI = xml.ele('si');\r\n let theseRuns = []; // §18.4.4 r (Rich Text Run)\r\n let currProps = {};\r\n let curRun;\r\n let i = 0;\r\n while (i < s.length) {\r\n if (typeof s[i] === 'string') {\r\n if (curRun === undefined) {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n }\r\n curRun.text = curRun.text + s[i];\r\n } else if (typeof s[i] === 'object') {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n Object.keys(s[i]).forEach((k) => {\r\n currProps[k] = s[i][k];\r\n });\r\n Object.keys(currProps).forEach((k) => {\r\n curRun.props[k] = currProps[k];\r\n });\r\n if (s[i].value !== undefined) {\r\n curRun.text = s[i].value;\r\n }\r\n }\r\n i++;\r\n }\r\n\r\n theseRuns.forEach((run) => {\r\n if (Object.keys(run).length < 1) {\r\n thisSI.ele('t', run.text).att('xml:space', 'preserve');\r\n } else {\r\n let thisRun = thisSI.ele('r');\r\n let thisRunProps = thisRun.ele('rPr');\r\n typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null;\r\n run.props.bold === true ? thisRunProps.ele('b') : null;\r\n run.props.italics === true ? thisRunProps.ele('i') : null;\r\n run.props.strike === true ? thisRunProps.ele('strike') : null;\r\n run.props.outline === true ? thisRunProps.ele('outline') : null;\r\n run.props.shadow === true ? thisRunProps.ele('shadow') : null;\r\n run.props.condense === true ? thisRunProps.ele('condense') : null;\r\n run.props.extend === true ? thisRunProps.ele('extend') : null;\r\n if (typeof run.props.color === 'string') {\r\n let thisColor = new CTColor(run.props.color);\r\n thisColor.addToXMLele(thisRunProps);\r\n }\r\n typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null;\r\n run.props.underline === true ? thisRunProps.ele('u') : null;\r\n typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null;\r\n thisRun.ele('t', run.text).att('xml:space', 'preserve');\r\n }\r\n });\r\n\r\n }\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addStylesXML = (promiseObj) => {\r\n // §12.3.20 Styles Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'styleSheet', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n if (promiseObj.wb.styleData.numFmts.length > 0) {\r\n let nfXML = xml\r\n .ele('numFmts')\r\n .att('count', promiseObj.wb.styleData.numFmts.length);\r\n promiseObj.wb.styleData.numFmts.forEach((nf) => {\r\n nf.addToXMLele(nfXML);\r\n });\r\n }\r\n\r\n let fontXML = xml\r\n .ele('fonts')\r\n .att('count', promiseObj.wb.styleData.fonts.length);\r\n promiseObj.wb.styleData.fonts.forEach((f) => {\r\n f.addToXMLele(fontXML);\r\n });\r\n\r\n let fillXML = xml\r\n .ele('fills')\r\n .att('count', promiseObj.wb.styleData.fills.length);\r\n promiseObj.wb.styleData.fills.forEach((f) => {\r\n let fXML = fillXML.ele('fill');\r\n f.addToXMLele(fXML);\r\n });\r\n\r\n let borderXML = xml\r\n .ele('borders')\r\n .att('count', promiseObj.wb.styleData.borders.length);\r\n promiseObj.wb.styleData.borders.forEach((b) => {\r\n b.addToXMLele(borderXML);\r\n });\r\n\r\n\r\n let cellXfsXML = xml\r\n .ele('cellXfs')\r\n .att('count', promiseObj.wb.styles.length);\r\n promiseObj.wb.styles.forEach((s) => {\r\n s.addXFtoXMLele(cellXfsXML);\r\n });\r\n\r\n if (promiseObj.wb.dxfCollection.length > 0) {\r\n promiseObj.wb.dxfCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('styles.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n if (!ws.drawingCollection.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsXML = xmlbuilder.create(\r\n 'xdr:wsDr', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n drawingsXML\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');\r\n\r\n ws.drawingCollection.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n\r\n\r\n d.addToXMLele(drawingsXML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addLegacyHeaderFooterDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n \r\n if (!ws.legacyDrawingHeaderFooter.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsVML = xmlbuilder.begin().ele('xml');\r\n drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = drawingsVML.ele('v:shapetype')\r\n .att('id', '_x0000_t75')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '75')\r\n .att('o:preferrelative', 't')\r\n .att('path', 'm@4@5l@4@11@9@11@9@5xe')\r\n .att('filled', 'f').att('stroked', 'f');\r\n\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n var vf = st.ele('v:formulas');\r\n vf.ele('v:f').att('eqn', \"if lineDrawn pixelLineWidth 0\")\r\n vf.ele('v:f').att('eqn', \"sum @0 1 0\");\r\n vf.ele('v:f').att('eqn', \"sum 0 0 @1\");\r\n vf.ele('v:f').att('eqn', \"prod @2 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @0 0 1\");\r\n vf.ele('v:f').att('eqn', \"prod @6 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"sum @8 21600 0\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @10 21600 0\");\r\n\r\n st.ele('v:path')\r\n .att('o:extrusionok','f')\r\n .att('gradientshapeok','t')\r\n .att('o:connecttype','rect')\r\n\r\n st.ele('o:lock').att('v:ext','edit').att('aspectratio','t');\r\n\r\n // const sh = drawingsVML.ele('v:shape');\r\n // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75')\r\n // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`);\r\n // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1')\r\n // sh.ele('o:lock').att('v:ext','edit').att('rotation','t');\r\n\r\n // const textB = sh.ele('v:textbox').text('VML TextBox')\r\n\r\n ws.legacyDrawingHeaderFooter.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n d.addToXMLele(drawingsVML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\n\r\n/**\r\n * Use JSZip to generate file to a node buffer\r\n * @private\r\n * @memberof Workbook\r\n * @param {Workbook} wb Workbook instance\r\n * @return {Promise} resolves with Buffer\r\n */\r\nlet writeToBuffer = (wb) => {\r\n return new Promise((resolve, reject) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n if (promiseObj.wb.sheets.length === 0) {\r\n promiseObj.wb.Worksheet();\r\n }\r\n\r\n addRootContentTypesXML(promiseObj)\r\n .then(addWorksheetsXML)\r\n .then(addRootRelsXML)\r\n .then(addWorkbookXML)\r\n .then(addWorkbookRelsXML)\r\n .then(addCorePropertiesXML)\r\n .then(addSharedStringsXML)\r\n .then(addStylesXML)\r\n .then(addDrawingsXML)\r\n .then(addLegacyHeaderFooterDrawingsXML)\r\n .then(() => {\r\n wb.opts.jszip.type = 'nodebuffer';\r\n promiseObj.xlsx.generateAsync(wb.opts.jszip)\r\n .then((buf) => {\r\n resolve(buf);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n\r\n });\r\n};\r\n\r\n/**\r\n * @desc Currently only used for testing the XML generated for a Workbook.\r\n * @param {*} wb Workbook instance\r\n * @return {Promise} resolves with Workbook XML\r\n */\r\nlet workbookXML = (wb) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n return addWorkbookXML(promiseObj).then((result) => {\r\n return result.xlsx.files['xl/workbook.xml']._data;\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n writeToBuffer,\r\n workbookXML\r\n};"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/workbook/builder.js"],"names":["xmlbuilder","require","JSZip","fs","CTColor","utils","addRootContentTypesXML","promiseObj","Promise","resolve","reject","xml","create","att","contentTypesAdded","extensionsAdded","wb","sheets","forEach","s","i","drawingCollection","length","drawings","d","indexOf","extension","contentType","typeRef","ele","push","Object","keys","comments","legacyDrawingHeaderFooter","sheetId","chartsCollection","items","xmlString","doc","end","xmlOutVars","xlsx","file","addRootRelsXML","folder","addWorkbookXML","booksViewEle","workbookViewEle","opts","workbookView","viewOpts","activeTab","undefined","firstVisibleTab","sheet","hidden","autoFilterDateGrouping","boolToInt","firstSheet","minimized","showHorizontalScroll","showSheetTabs","showVerticalScroll","tabRatio","visibility","windowWidth","windowHeight","xWindow","yWindow","showComments","sheetsEle","name","printArea","startCellRef","getExcelAlpha","startCol","startRow","endCellRef","endCol","endRow","definedNameCollection","addDefinedName","localSheetId","refFormula","isEmpty","addToXMLele","calculationProperties","calcPr","fullCalculationOnLoad","addWorkbookRelsXML","addCorePropertiesXML","text","author","dtStr","Date","toISOString","addWorksheetsXML","curSheet","processNextSheet","thisSheet","generateXML","then","generateRelsXML","generateCommentsXML","generateCommentsVmlXML","catch","e","logger","error","stack","addSharedStringsXML","sharedStrings","txt","Array","thisSI","theseRuns","currProps","curRun","props","k","value","run","thisRun","thisRunProps","bold","italics","strike","outline","shadow","condense","extend","color","thisColor","size","underline","vertAlign","addStylesXML","styleData","numFmts","nfXML","nf","fontXML","fonts","f","fillXML","fills","fXML","borderXML","borders","b","cellXfsXML","styles","addXFtoXMLele","dxfCollection","addDrawingsXML","mediaCollection","ws","drawingRelXML","drawingsXML","kind","target","id","image","imagePath","readFileSync","rId","type","chartBuilder","chartPartXML","chartXMLStr","drawingsXMLStr","drawingRelXMLStr","addLegacyHeaderFooterDrawingsXML","drawingsVML","begin","sl","st","vf","writeToBuffer","Worksheet","jszip","generateAsync","buf","workbookXML","result","files","_data","module","exports"],"mappings":";;;;AAAA,IAAMA,aAAaC,QAAQ,YAAR,CAAnB;AACA,IAAMC,QAAQD,QAAQ,OAAR,CAAd;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,UAAUH,QAAQ,6BAAR,CAAhB;AACA,IAAMI,QAAQJ,QAAQ,UAAR,CAAd;;AAEA,IAAIK,yBAAyB,SAAzBA,sBAAyB,CAACC,UAAD,EAAgB;AAC3C;AACA,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAIC,MAAMX,WAAWY,MAAX,CACR,OADQ,EACC;AACT,iBAAW,KADF;AAET,kBAAY,OAFH;AAGT,oBAAc,IAHL;AAIT,6BAAuB;AAJd,KADD,EAQPC,GARO,CAQH,OARG,EAQM,8DARN,CAAV;;AAUA,QAAIC,oBAAoB,EAAxB;AACA,QAAIC,kBAAkB,EAAtB;AACAR,eAAWS,EAAX,CAAcC,MAAd,CAAqBC,OAArB,CAA6B,UAACC,CAAD,EAAIC,CAAJ,EAAU;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SAAGiC,IAAH,CAAQoI,KAAR,CAAcd,IAAd,GAAqB,YAArB;AACAhK,iBAAWmC,IAAX,CAAgB4I,aAAhB,CAA8BtK,GAAGiC,IAAH,CAAQoI,KAAtC,EACG/E,IADH,CACQ,UAACiF,GAAD,EAAS;AACb9K,gBAAQ8K,GAAR;AACD,OAHH,EAIG7E,KAJH,CAIS,UAACC,CAAD,EAAO;AACZjG,eAAOiG,CAAP;AACD,OANH;AAOD,KAnBH,EAoBGD,KApBH,CAoBS,UAACC,CAAD,EAAO;AACZjG,aAAOiG,CAAP;AACD,KAtBH;AAwBD,GAnCM,CAAP;AAoCD,CArCD;;AAuCA;;;;;AAKA,IAAI6E,cAAc,SAAdA,WAAc,CAACxK,EAAD,EAAQ;AACxB,MAAIT,aAAa;AACfS,QAAIA,EADW;AAEf0B,UAAM,IAAIxC,KAAJ,EAFS;AAGfuC,gBAAY;AAHG,GAAjB;;AAMA,SAAOK,eAAevC,UAAf,EAA2B+F,IAA3B,CAAgC,UAACmF,MAAD,EAAY;AACjD,WAAOA,OAAO/I,IAAP,CAAYgJ,KAAZ,CAAkB,iBAAlB,EAAqCC,KAA5C;AACD,GAFM,CAAP;AAGD,CAVD;;AAYAC,OAAOC,OAAP,GAAiB;AACfV,8BADe;AAEfK;AAFe,CAAjB","file":"builder.js","sourcesContent":["const xmlbuilder = require('xmlbuilder');\r\nconst JSZip = require('jszip');\r\nconst fs = require('fs');\r\nconst CTColor = require('../style/classes/ctColor.js');\r\nconst utils = require('../utils');\r\n\r\nlet addRootContentTypesXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Types', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');\r\n\r\n let contentTypesAdded = [];\r\n let extensionsAdded = [];\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n if (s.drawingCollection.length > 0) {\r\n s.drawingCollection.drawings.forEach((d) => {\r\n if (extensionsAdded.indexOf(d.extension) < 0) {\r\n if (d.contentType) {\r\n let typeRef = d.contentType + '.' + d.extension;\r\n if (contentTypesAdded.indexOf(typeRef) < 0) {\r\n xml.ele('Default').att('ContentType', d.contentType).att('Extension', d.extension);\r\n }\r\n extensionsAdded.push(d.extension);\r\n }\r\n }\r\n });\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n }\r\n\r\n if (s.legacyDrawingHeaderFooter.length > 0) {\r\n if (extensionsAdded.indexOf('vml') < 0) {\r\n xml.ele('Default').att('Extension', 'vml').att('ContentType', 'application/vnd.openxmlformats-officedocument.vmlDrawing');\r\n extensionsAdded.push('vml');\r\n }\r\n if (extensionsAdded.indexOf('png') < 0) {\r\n xml.ele('Default').att('Extension', 'png').att('ContentType', 'image/png');\r\n extensionsAdded.push('png');\r\n }\r\n }\r\n });\r\n xml.ele('Default').att('Extension', 'xml').att('ContentType', 'application/xml');\r\n xml.ele('Default').att('Extension', 'rels').att('ContentType', 'application/vnd.openxmlformats-package.relationships+xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml').att('PartName', '/xl/workbook.xml');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/worksheets/sheet${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml')\r\n\r\n\r\n if (s.drawingCollection.length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/drawings/drawing' + s.sheetId + '.xml')\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawing+xml')\r\n }\r\n if (Object.keys(s.comments).length > 0) {\r\n xml.ele('Override')\r\n .att('PartName', '/xl/comments' + s.sheetId + '.xml')\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml')\r\n }\r\n });\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml').att('PartName', '/xl/styles.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml');\r\n xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml');\r\n promiseObj.wb.chartsCollection.items.forEach((s, i) => {\r\n xml.ele('Override')\r\n .att('PartName', `/xl/charts/chart${i + 1}.xml`)\r\n .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml')\r\n })\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.file('[Content_Types].xml', xmlString);\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addRootRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId1')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument')\r\n .att('Target', 'xl/workbook.xml');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', 'rId2')\r\n .att('Type', 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties')\r\n .att('Target', 'docProps/core.xml');\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('_rels').file('.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'workbook', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n xml.att('mc:Ignorable', 'x15');\r\n xml.att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n xml.att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006');\r\n xml.att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');\r\n xml.att('xmlns:x15', 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main');\r\n xml.att('xmlns:x', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n let booksViewEle = xml.ele('bookViews');\r\n let workbookViewEle = booksViewEle.ele('workbookView');\r\n // bookViews (§18.2.1)\r\n if (promiseObj.wb.opts.workbookView) {\r\n const viewOpts = promiseObj.wb.opts.workbookView;\r\n if (viewOpts.activeTab !== null && viewOpts.activeTab !== undefined) {\r\n workbookViewEle.att('activeTab', viewOpts.activeTab);\r\n } else {\r\n let firstVisibleTab = 0;\r\n for (let i = 0; i < promiseObj.wb.sheets.length; i++) {\r\n const sheet = promiseObj.wb.sheets[i];\r\n if (!sheet.opts.hidden) {\r\n firstVisibleTab = i;\r\n break;\r\n }\r\n }\r\n workbookViewEle.att('activeTab', firstVisibleTab);\r\n }\r\n if (viewOpts.autoFilterDateGrouping) {\r\n workbookViewEle.att('autoFilterDateGrouping', utils.boolToInt(viewOpts.autoFilterDateGrouping));\r\n }\r\n if (viewOpts.firstSheet) {\r\n workbookViewEle.att('firstSheet', viewOpts.firstSheet);\r\n }\r\n if (viewOpts.minimized) {\r\n workbookViewEle.att('minimized', utils.boolToInt(viewOpts.minimized));\r\n }\r\n if (viewOpts.showHorizontalScroll) {\r\n workbookViewEle.att('showHorizontalScroll', utils.boolToInt(viewOpts.showHorizontalScroll));\r\n }\r\n if (viewOpts.showSheetTabs) {\r\n workbookViewEle.att('showSheetTabs', utils.boolToInt(viewOpts.showSheetTabs));\r\n }\r\n if (viewOpts.showVerticalScroll) {\r\n workbookViewEle.att('showVerticalScroll', utils.boolToInt(viewOpts.showVerticalScroll));\r\n }\r\n if (viewOpts.tabRatio) {\r\n workbookViewEle.att('tabRatio', viewOpts.tabRatio);\r\n }\r\n if (viewOpts.visibility) {\r\n workbookViewEle.att('visibility', viewOpts.visibility);\r\n }\r\n if (viewOpts.windowWidth) {\r\n workbookViewEle.att('windowWidth', viewOpts.windowWidth);\r\n }\r\n if (viewOpts.windowHeight) {\r\n workbookViewEle.att('windowHeight', viewOpts.windowHeight);\r\n }\r\n if (viewOpts.xWindow) {\r\n workbookViewEle.att('xWindow', viewOpts.xWindow);\r\n }\r\n if (viewOpts.yWindow) {\r\n workbookViewEle.att('yWindow', viewOpts.yWindow);\r\n }\r\n if (viewOpts.showComments) {\r\n workbookViewEle.att('showComments', viewOpts.showComments);\r\n }\r\n }\r\n\r\n let sheetsEle = xml.ele('sheets');\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n const sheet = sheetsEle.ele('sheet')\r\n .att('name', s.name)\r\n .att('sheetId', i + 1)\r\n .att('r:id', `rId${i + 1}`);\r\n\r\n if (s.opts.hidden) {\r\n sheet.att('state', 'hidden');\r\n }\r\n\r\n if (s.printArea) {\r\n const name = s.name;\r\n const startCellRef = `$${utils.getExcelAlpha(s.printArea.startCol)}$${s.printArea.startRow}`;\r\n const endCellRef = `$${utils.getExcelAlpha(s.printArea.endCol)}$${s.printArea.endRow}`;\r\n s.wb.definedNameCollection.addDefinedName({\r\n name: '_xlnm.Print_Area',\r\n localSheetId: s.localSheetId,\r\n refFormula: `'${name}'!${startCellRef}:${endCellRef}`,\r\n });\r\n }\r\n });\r\n\r\n if (!promiseObj.wb.definedNameCollection.isEmpty) {\r\n promiseObj.wb.definedNameCollection.addToXMLele(xml);\r\n }\r\n\r\n if(promiseObj.wb.opts.calculationProperties){\r\n let calcPr = xml.ele('x:calcPr');\r\n if(promiseObj.wb.opts.calculationProperties.fullCalculationOnLoad){\r\n // calcPr.att('calcId', 15234)\r\n calcPr.att('fullCalcOnLoad', 1)\r\n }\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('workbook.xml', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addWorkbookRelsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 1}`)\r\n .att('Target', 'sharedStrings.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings');\r\n\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${promiseObj.wb.sheets.length + 2}`)\r\n .att('Target', 'styles.xml')\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles');\r\n\r\n promiseObj.wb.sheets.forEach((s, i) => {\r\n xml\r\n .ele('Relationship')\r\n .att('Id', `rId${i + 1}`)\r\n .att('Target', `worksheets/sheet${i + 1}.xml`)\r\n .att('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet');\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('_rels').file('workbook.xml.rels', xmlString);\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addCorePropertiesXML = (promiseObj) => {\r\n let xml = xmlbuilder.create(\r\n 'cp:coreProperties', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true\r\n }\r\n )\r\n .att('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties')\r\n .att('xmlns:dc', 'http://purl.org/dc/elements/1.1/')\r\n .att('xmlns:dcterms', 'http://purl.org/dc/terms/')\r\n .att('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/')\r\n .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');\r\n\r\n xml.ele('dc:creator').text(promiseObj.wb.author);\r\n xml.ele('cp:lastModifiedBy').text(promiseObj.wb.author);\r\n let dtStr = new Date().toISOString();\r\n xml.ele('dcterms:created').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n xml.ele('dcterms:modified').att('xsi:type', 'dcterms:W3CDTF').text(dtStr);\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('docProps').file('core.xml', xmlString);\r\n return promiseObj;\r\n};\r\n\r\nlet addWorksheetsXML = (promiseObj) => {\r\n // Required as stated in §12.2\r\n return new Promise((resolve, reject) => {\r\n\r\n let curSheet = 0;\r\n\r\n let processNextSheet = () => {\r\n let thisSheet = promiseObj.wb.sheets[curSheet];\r\n if (thisSheet) {\r\n curSheet++;\r\n thisSheet.generateXML()\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n // Add worksheet to zip\r\n promiseObj.xlsx.folder('xl').folder('worksheets').file(`sheet${curSheet}.xml`, xml);\r\n\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateRelsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('worksheets').folder('_rels').file(`sheet${curSheet}.xml.rels`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').file(`comments${curSheet}.xml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(() => {\r\n return thisSheet.generateCommentsVmlXML();\r\n })\r\n .then((xml) => {\r\n return new Promise((resolve) => {\r\n if (xml) {\r\n promiseObj.xlsx.folder('xl').folder('drawings').file(`commentsVml${curSheet}.vml`, xml);\r\n }\r\n resolve();\r\n });\r\n })\r\n .then(processNextSheet)\r\n .catch((e) => {\r\n promiseObj.wb.logger.error(e.stack);\r\n });\r\n } else {\r\n resolve(promiseObj);\r\n }\r\n };\r\n processNextSheet();\r\n\r\n });\r\n};\r\n\r\n/**\r\n * Generate XML for SharedStrings.xml file and add it to zip file. Called from _writeToBuffer()\r\n * @private\r\n * @memberof Workbook\r\n * @param {Object} promiseObj object containing jszip instance, workbook intance and xmlvars\r\n * @return {Promise} Resolves with promiseObj\r\n */\r\nlet addSharedStringsXML = (promiseObj) => {\r\n // §12.3.15 Shared String Table Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'sst', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('count', promiseObj.wb.sharedStrings.length)\r\n .att('uniqueCount', promiseObj.wb.sharedStrings.length)\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');\r\n\r\n promiseObj.wb.sharedStrings.forEach((s) => {\r\n if (typeof s === 'string') {\r\n xml.ele('si').ele('t').txt(s);\r\n } else if (s instanceof Array) {\r\n\r\n let thisSI = xml.ele('si');\r\n let theseRuns = []; // §18.4.4 r (Rich Text Run)\r\n let currProps = {};\r\n let curRun;\r\n let i = 0;\r\n while (i < s.length) {\r\n if (typeof s[i] === 'string') {\r\n if (curRun === undefined) {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n }\r\n curRun.text = curRun.text + s[i];\r\n } else if (typeof s[i] === 'object') {\r\n theseRuns.push({\r\n props: {},\r\n text: ''\r\n });\r\n curRun = theseRuns[theseRuns.length - 1];\r\n Object.keys(s[i]).forEach((k) => {\r\n currProps[k] = s[i][k];\r\n });\r\n Object.keys(currProps).forEach((k) => {\r\n curRun.props[k] = currProps[k];\r\n });\r\n if (s[i].value !== undefined) {\r\n curRun.text = s[i].value;\r\n }\r\n }\r\n i++;\r\n }\r\n\r\n theseRuns.forEach((run) => {\r\n if (Object.keys(run).length < 1) {\r\n thisSI.ele('t', run.text).att('xml:space', 'preserve');\r\n } else {\r\n let thisRun = thisSI.ele('r');\r\n let thisRunProps = thisRun.ele('rPr');\r\n typeof run.props.name === 'string' ? thisRunProps.ele('rFont').att('val', run.props.name) : null;\r\n run.props.bold === true ? thisRunProps.ele('b') : null;\r\n run.props.italics === true ? thisRunProps.ele('i') : null;\r\n run.props.strike === true ? thisRunProps.ele('strike') : null;\r\n run.props.outline === true ? thisRunProps.ele('outline') : null;\r\n run.props.shadow === true ? thisRunProps.ele('shadow') : null;\r\n run.props.condense === true ? thisRunProps.ele('condense') : null;\r\n run.props.extend === true ? thisRunProps.ele('extend') : null;\r\n if (typeof run.props.color === 'string') {\r\n let thisColor = new CTColor(run.props.color);\r\n thisColor.addToXMLele(thisRunProps);\r\n }\r\n typeof run.props.size === 'number' ? thisRunProps.ele('sz').att('val', run.props.size) : null;\r\n run.props.underline === true ? thisRunProps.ele('u') : null;\r\n typeof run.props.vertAlign === 'string' ? thisRunProps.ele('vertAlign').att('val', run.props.vertAlign) : null;\r\n thisRun.ele('t', run.text).att('xml:space', 'preserve');\r\n }\r\n });\r\n\r\n }\r\n });\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('sharedStrings.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n\r\n });\r\n};\r\n\r\nlet addStylesXML = (promiseObj) => {\r\n // §12.3.20 Styles Part\r\n return new Promise((resolve, reject) => {\r\n\r\n let xml = xmlbuilder.create(\r\n 'styleSheet', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n )\r\n .att('mc:Ignorable', 'x14ac')\r\n .att('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main')\r\n .att('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006')\r\n .att('xmlns:x14ac', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac');\r\n\r\n if (promiseObj.wb.styleData.numFmts.length > 0) {\r\n let nfXML = xml\r\n .ele('numFmts')\r\n .att('count', promiseObj.wb.styleData.numFmts.length);\r\n promiseObj.wb.styleData.numFmts.forEach((nf) => {\r\n nf.addToXMLele(nfXML);\r\n });\r\n }\r\n\r\n let fontXML = xml\r\n .ele('fonts')\r\n .att('count', promiseObj.wb.styleData.fonts.length);\r\n promiseObj.wb.styleData.fonts.forEach((f) => {\r\n f.addToXMLele(fontXML);\r\n });\r\n\r\n let fillXML = xml\r\n .ele('fills')\r\n .att('count', promiseObj.wb.styleData.fills.length);\r\n promiseObj.wb.styleData.fills.forEach((f) => {\r\n let fXML = fillXML.ele('fill');\r\n f.addToXMLele(fXML);\r\n });\r\n\r\n let borderXML = xml\r\n .ele('borders')\r\n .att('count', promiseObj.wb.styleData.borders.length);\r\n promiseObj.wb.styleData.borders.forEach((b) => {\r\n b.addToXMLele(borderXML);\r\n });\r\n\r\n\r\n let cellXfsXML = xml\r\n .ele('cellXfs')\r\n .att('count', promiseObj.wb.styles.length);\r\n promiseObj.wb.styles.forEach((s) => {\r\n s.addXFtoXMLele(cellXfsXML);\r\n });\r\n\r\n if (promiseObj.wb.dxfCollection.length > 0) {\r\n promiseObj.wb.dxfCollection.addToXMLele(xml);\r\n }\r\n\r\n let xmlString = xml.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').file('styles.xml', xmlString);\r\n\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty || !promiseObj.wb.chartsCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n if (!ws.drawingCollection.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsXML = xmlbuilder.create(\r\n 'xdr:wsDr', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n }\r\n );\r\n drawingsXML\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');\r\n\r\n ws.drawingCollection.drawings.forEach((d) => {\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n if (d.kind == 'chart') {\r\n let target = 'chart' + d.id + '.xml';\r\n let chartBuilder = xmlbuilder.create('c:chartSpace', {\r\n 'version': '1.0', 'encoding': 'UTF-8', 'standalone': true\r\n })\r\n .att('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart')\r\n .att('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main')\r\n .att('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')\r\n .att('xmlns:c16r2', 'http://schemas.microsoft.com/office/drawing/2015/06/chart');\r\n\r\n d.chartPartXML(chartBuilder);\r\n let chartXMLStr = chartBuilder.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('charts').file(target, chartXMLStr);\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../charts/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n d.addToXMLele(drawingsXML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsXML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('drawing' + ws.sheetId + '.xml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('drawing' + ws.sheetId + '.xml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\nlet addLegacyHeaderFooterDrawingsXML = (promiseObj) => {\r\n return new Promise((resolve) => {\r\n if (!promiseObj.wb.mediaCollection.isEmpty) {\r\n\r\n promiseObj.wb.sheets.forEach((ws) => {\r\n\r\n if (!ws.legacyDrawingHeaderFooter.isEmpty) {\r\n\r\n let drawingRelXML = xmlbuilder.create('Relationships', {\r\n 'version': '1.0',\r\n 'encoding': 'UTF-8',\r\n 'standalone': true,\r\n 'allowSurrogateChars': true\r\n })\r\n .att('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');\r\n\r\n let drawingsVML = xmlbuilder.begin().ele('xml');\r\n drawingsVML.att('xmlns:v', 'urn:schemas-microsoft-com:vml')\r\n drawingsVML.att('xmlns:o', 'urn:schemas-microsoft-com:office:office');\r\n drawingsVML.att('xmlns:x', 'urn:schemas-microsoft-com:office:excel');\r\n\r\n const sl = drawingsVML.ele('o:shapelayout').att('v:ext', 'edit');\r\n sl.ele('o:idmap').att('v:ext', 'edit').att('data', ws.sheetId);\r\n\r\n const st = drawingsVML.ele('v:shapetype')\r\n .att('id', '_x0000_t75')\r\n .att('coordsize', '21600,21600')\r\n .att('o:spt', '75')\r\n .att('o:preferrelative', 't')\r\n .att('path', 'm@4@5l@4@11@9@11@9@5xe')\r\n .att('filled', 'f').att('stroked', 'f');\r\n\r\n st.ele('v:stroke').att('joinstyle', 'miter');\r\n var vf = st.ele('v:formulas');\r\n vf.ele('v:f').att('eqn', \"if lineDrawn pixelLineWidth 0\")\r\n vf.ele('v:f').att('eqn', \"sum @0 1 0\");\r\n vf.ele('v:f').att('eqn', \"sum 0 0 @1\");\r\n vf.ele('v:f').att('eqn', \"prod @2 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"prod @3 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @0 0 1\");\r\n vf.ele('v:f').att('eqn', \"prod @6 1 2\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelWidth\");\r\n vf.ele('v:f').att('eqn', \"sum @8 21600 0\");\r\n vf.ele('v:f').att('eqn', \"prod @7 21600 pixelHeight\");\r\n vf.ele('v:f').att('eqn', \"sum @10 21600 0\");\r\n\r\n st.ele('v:path')\r\n .att('o:extrusionok', 'f')\r\n .att('gradientshapeok', 't')\r\n .att('o:connecttype', 'rect')\r\n\r\n st.ele('o:lock').att('v:ext', 'edit').att('aspectratio', 't');\r\n\r\n // const sh = drawingsVML.ele('v:shape');\r\n // sh.att('id','CF').att('o:spid','_x0000_s1025').att('type', '#_x0000_t75')\r\n // .att('style',`position:absolute;margin-left:0;margin-top:0;width:510.75pt;height:45.75pt;z-index:1`);\r\n // sh.ele('v:imagedata').att('o:relid','rId1').att('o:title','image1')\r\n // sh.ele('o:lock').att('v:ext','edit').att('rotation','t');\r\n\r\n // const textB = sh.ele('v:textbox').text('VML TextBox')\r\n\r\n ws.legacyDrawingHeaderFooter.drawings.forEach((d) => {\r\n\r\n if (d.kind === 'image') {\r\n let target = 'image' + d.id + '.' + d.extension;\r\n\r\n let image = d.imagePath ? fs.readFileSync(d.imagePath) : d.image;\r\n promiseObj.xlsx.folder('xl').folder('media').file(target, image);\r\n\r\n drawingRelXML.ele('Relationship')\r\n .att('Id', d.rId)\r\n .att('Target', '../media/' + target)\r\n .att('Type', d.type);\r\n\r\n }\r\n\r\n d.addToXMLele(drawingsVML);\r\n\r\n });\r\n\r\n let drawingsXMLStr = drawingsVML.doc().end(promiseObj.xmlOutVars);\r\n let drawingRelXMLStr = drawingRelXML.doc().end(promiseObj.xmlOutVars);\r\n promiseObj.xlsx.folder('xl').folder('drawings').file('vmlDrawing' + ws.sheetId + '.vml', drawingsXMLStr);\r\n promiseObj.xlsx.folder('xl').folder('drawings').folder('_rels').file('vmlDrawing' + ws.sheetId + '.vml.rels', drawingRelXMLStr);\r\n }\r\n });\r\n\r\n }\r\n resolve(promiseObj);\r\n });\r\n};\r\n\r\n\r\n/**\r\n * Use JSZip to generate file to a node buffer\r\n * @private\r\n * @memberof Workbook\r\n * @param {Workbook} wb Workbook instance\r\n * @return {Promise} resolves with Buffer\r\n */\r\nlet writeToBuffer = (wb) => {\r\n return new Promise((resolve, reject) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n if (promiseObj.wb.sheets.length === 0) {\r\n promiseObj.wb.Worksheet();\r\n }\r\n\r\n addRootContentTypesXML(promiseObj)\r\n .then(addWorksheetsXML)\r\n .then(addRootRelsXML)\r\n .then(addWorkbookXML)\r\n .then(addWorkbookRelsXML)\r\n .then(addCorePropertiesXML)\r\n .then(addSharedStringsXML)\r\n .then(addStylesXML)\r\n .then(addDrawingsXML)\r\n .then(addLegacyHeaderFooterDrawingsXML)\r\n .then(() => {\r\n wb.opts.jszip.type = 'nodebuffer';\r\n promiseObj.xlsx.generateAsync(wb.opts.jszip)\r\n .then((buf) => {\r\n resolve(buf);\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n });\r\n\r\n });\r\n};\r\n\r\n/**\r\n * @desc Currently only used for testing the XML generated for a Workbook.\r\n * @param {*} wb Workbook instance\r\n * @return {Promise} resolves with Workbook XML\r\n */\r\nlet workbookXML = (wb) => {\r\n let promiseObj = {\r\n wb: wb,\r\n xlsx: new JSZip(),\r\n xmlOutVars: {}\r\n };\r\n\r\n return addWorkbookXML(promiseObj).then((result) => {\r\n return result.xlsx.files['xl/workbook.xml']._data;\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n writeToBuffer,\r\n workbookXML\r\n};"]} \ No newline at end of file diff --git a/distribution/lib/workbook/workbook.js b/distribution/lib/workbook/workbook.js index 6ae06da6..8b3ab4c3 100644 --- a/distribution/lib/workbook/workbook.js +++ b/distribution/lib/workbook/workbook.js @@ -17,6 +17,7 @@ var Fill = require('../style/classes/fill.js'); var Font = require('../style/classes/font'); var DXFCollection = require('./dxfCollection.js'); var MediaCollection = require('./mediaCollection.js'); +var ChartsCollection = require('./chartsCollection.js'); var DefinedNameCollection = require('../classes/definedNameCollection.js'); var types = require('../types/index.js'); var builder = require('./builder.js'); @@ -105,6 +106,7 @@ var Workbook = function () { this.stylesLookup = new Map(); this.dxfCollection = new DXFCollection(this); this.mediaCollection = new MediaCollection(); + this.chartsCollection = new ChartsCollection(); this.definedNameCollection = new DefinedNameCollection(); this.styleData = { 'numFmts': [], diff --git a/distribution/lib/workbook/workbook.js.map b/distribution/lib/workbook/workbook.js.map index 34860990..6b771397 100644 --- a/distribution/lib/workbook/workbook.js.map +++ b/distribution/lib/workbook/workbook.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/workbook/workbook.js"],"names":["_isUndefined","require","deepmerge","fs","utils","Worksheet","Style","Border","Fill","Font","DXFCollection","MediaCollection","DefinedNameCollection","types","builder","http","SimpleLogger","workbookDefaultOpts","jszip","compression","defaultFont","dateFormat","Workbook","opts","hasCustomLogger","logger","undefined","hasValidCustomLogger","warn","error","logLevel","Number","isNaN","parseInt","log","author","sheets","sharedStrings","sharedStringLookup","Map","styles","stylesLookup","dxfCollection","mediaCollection","definedNameCollection","styleData","type","patternType","styleDataLookup","fills","reduce","ret","fill","index","JSON","stringify","toObject","borders","border","createStyle","font","id","forEach","s","sheetId","sheetView","tabSelected","writeToBuffer","fileName","handler","then","buffer","ServerResponse","writeHead","length","encodeURIComponent","end","TypeError","writeFile","err","stat","catch","e","stack","status","setHeader","name","newLength","push","thisStyle","lookupKey","get","set","ids","cellXfs","val","target","workbookXML","module","exports"],"mappings":";;;;;;;;AAAA,IAAMA,eAAeC,QAAQ,oBAAR,CAArB;AACA,IAAMC,YAAYD,QAAQ,WAAR,CAAlB;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,QAAQH,QAAQ,aAAR,CAAd;AACA,IAAMI,YAAYJ,QAAQ,cAAR,CAAlB;AACA,IAAMK,QAAQL,QAAQ,UAAR,CAAd;AACA,IAAMM,SAASN,QAAQ,4BAAR,CAAf;AACA,IAAMO,OAAOP,QAAQ,0BAAR,CAAb;AACA,IAAMQ,OAAOR,QAAQ,uBAAR,CAAb;AACA,IAAMS,gBAAgBT,QAAQ,oBAAR,CAAtB;AACA,IAAMU,kBAAkBV,QAAQ,sBAAR,CAAxB;AACA,IAAMW,wBAAwBX,QAAQ,qCAAR,CAA9B;AACA,IAAMY,QAAQZ,QAAQ,mBAAR,CAAd;AACA,IAAMa,UAAUb,QAAQ,cAAR,CAAhB;AACA,IAAMc,OAAOd,QAAQ,MAAR,CAAb;AACA,IAAMe,eAAef,QAAQ,WAAR,CAArB;;AAEA;;;;;;;;;;;;AAYA;AACA,IAAIgB,sBAAsB;AACtBC,WAAO;AACHC,qBAAa;AADV,KADe;AAItBC,iBAAa;AACT,iBAAS,UADA;AAET,gBAAQ,SAFC;AAGT,gBAAQ,EAHC;AAIT,kBAAU;AAJD,KAJS;AAUtBC,gBAAY;AAVU,CAA1B;;IAcMC,Q;;AAEF;;;;;;;;;;;;;;;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4BD,SAA5B,CAAf;AACA,gBAAI1F,aAAagG,MAAb,CAAJ,EAA0B;AACtB,oBAAM3C,QAAQ,KAAKhB,aAAL,CAAmBmD,IAAnB,CAAwBO,GAAxB,IAA+B,CAA7C;AACA,qBAAKzD,kBAAL,CAAwBsD,GAAxB,CAA4BF,SAA5B,EAAuCrC,KAAvC;AACA,uBAAOA,KAAP;AACH,aAJD,MAIO;AACH,uBAAO2C,MAAP;AACH;AACJ;;AAED;;;;;;;;uCAKe;AACX,mBAAOlF,QAAQmF,WAAR,CAAoB,IAApB,CAAP;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiB7E,QAAjB","file":"workbook.js","sourcesContent":["const _isUndefined = require('lodash.isundefined');\r\nconst deepmerge = require('deepmerge');\r\nconst fs = require('fs');\r\nconst utils = require('../utils.js');\r\nconst Worksheet = require('../worksheet');\r\nconst Style = require('../style');\r\nconst Border = require('../style/classes/border.js');\r\nconst Fill = require('../style/classes/fill.js');\r\nconst Font = require('../style/classes/font');\r\nconst DXFCollection = require('./dxfCollection.js');\r\nconst MediaCollection = require('./mediaCollection.js');\r\nconst DefinedNameCollection = require('../classes/definedNameCollection.js');\r\nconst types = require('../types/index.js');\r\nconst builder = require('./builder.js');\r\nconst http = require('http');\r\nconst SimpleLogger = require('../logger');\r\n\r\n/* Available options for Workbook\r\n{\r\n jszip : {\r\n compression : 'DEFLATE'\r\n },\r\n defaultFont : {\r\n size : 12,\r\n family : 'Calibri',\r\n color : 'FFFFFFFF'\r\n }\r\n}\r\n*/\r\n// Default Options for Workbook\r\nlet workbookDefaultOpts = {\r\n jszip: {\r\n compression: 'DEFLATE'\r\n },\r\n defaultFont: {\r\n 'color': 'FF000000',\r\n 'name': 'Calibri',\r\n 'size': 12,\r\n 'family': 'roman'\r\n },\r\n dateFormat: 'm/d/yy'\r\n};\r\n\r\n\r\nclass Workbook {\r\n\r\n /**\r\n * @class Workbook\r\n * @param {Object} opts Workbook settings\r\n * @param {Object} opts.jszip\r\n * @param {String} opts.jszip.compression JSZip compression type. defaults to 'DEFLATE'\r\n * @param {Object} opts.defaultFont\r\n * @param {String} opts.defaultFont.color HEX value of default font color. defaults to #000000\r\n * @param {String} opts.defaultFont.name Font name. defaults to Calibri\r\n * @param {Number} opts.defaultFont.size Font size. defaults to 12\r\n * @param {String} opts.defaultFont.family Font family. defaults to roman\r\n * @param {String} opts.dataFormat Specifies the format for dates in the Workbook. defaults to 'm/d/yy'\r\n * @param {Number} opts.workbookView.activeTab Specifies an unsignedInt that contains the index to the active sheet in this book view.\r\n * @param {Boolean} opts.workbookView.autoFilterDateGrouping Specifies a boolean value that indicates whether to group dates when presenting the user with filtering options in the user interface.\r\n * @param {Number} opts.workbookView.firstSheet Specifies the index to the first sheet in this book view.\r\n * @param {Boolean} opts.workbookView.minimized Specifies a boolean value that indicates whether the workbook window is minimized.\r\n * @param {Boolean} opts.workbookView.showHorizontalScroll Specifies a boolean value that indicates whether to display the horizontal scroll bar in the user interface.\r\n * @param {Boolean} opts.workbookView.showSheetTabs Specifies a boolean value that indicates whether to display the sheet tabs in the user interface.\r\n * @param {Boolean} opts.workbookView.showVerticalScroll Specifies a boolean value that indicates whether to display the vertical scroll bar.\r\n * @param {Number} opts.workbookView.tabRatio Specifies ratio between the workbook tabs bar and the horizontal scroll bar.\r\n * @param {String} opts.workbookView.visibility Specifies visible state of the workbook window. ('hidden', 'veryHidden', 'visible') (§18.18.89)\r\n * @param {Number} opts.workbookView.windowHeight Specifies the height of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.windowWidth Specifies the width of the workbook window. The unit of measurement for this value is twips..\r\n * @param {Number} opts.workbookView.xWindow Specifies the X coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.yWindow Specifies the Y coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Boolean} opts.workbookView\r\n * @param {Object} opts.logger Logger that supports warn and error method, defaults to console\r\n * @param {String} opts.author Name displayed as document's author\r\n * @returns {Workbook}\r\n */\r\n constructor(opts = {}) {\r\n\r\n const hasCustomLogger = opts.logger !== undefined;\r\n const hasValidCustomLogger = hasCustomLogger && typeof opts.logger.warn === 'function' && typeof opts.logger.error === 'function';\r\n\r\n this.logger = hasValidCustomLogger ? opts.logger : new SimpleLogger({\r\n logLevel: Number.isNaN(parseInt(opts.logLevel)) ? 0 : parseInt(opts.logLevel)\r\n });\r\n if (hasCustomLogger && !hasValidCustomLogger) {\r\n this.logger.log('opts.logger is not a valid logger');\r\n }\r\n\r\n this.opts = deepmerge(workbookDefaultOpts, opts);\r\n this.author = this.opts.author || 'Microsoft Office User';\r\n\r\n this.sheets = [];\r\n this.sharedStrings = [];\r\n this.sharedStringLookup = new Map();\r\n this.styles = [];\r\n this.stylesLookup = new Map();\r\n this.dxfCollection = new DXFCollection(this);\r\n this.mediaCollection = new MediaCollection();\r\n this.definedNameCollection = new DefinedNameCollection();\r\n this.styleData = {\r\n 'numFmts': [],\r\n 'fonts': [],\r\n 'fills': [new Fill({\r\n type: 'pattern',\r\n patternType: 'none'\r\n }), new Fill({\r\n type: 'pattern',\r\n patternType: 'gray125'\r\n })],\r\n 'borders': [new Border()],\r\n 'cellXfs': [{\r\n 'borderId': null,\r\n 'fillId': null,\r\n 'fontId': 0,\r\n 'numFmtId': null\r\n }]\r\n };\r\n\r\n // Lookups for style components to quickly find existing entries\r\n // - Lookup keys are stringified JSON of a style's toObject result\r\n // - Lookup values are the indexes for the actual entry in the styleData arrays\r\n this.styleDataLookup = {\r\n 'fonts': {},\r\n 'fills': this.styleData.fills.reduce((ret, fill, index) => {\r\n ret[JSON.stringify(fill.toObject())] = index;\r\n return ret;\r\n }, {}),\r\n 'borders': this.styleData.borders.reduce((ret, border, index) => {\r\n ret[JSON.stringify(border.toObject())] = index;\r\n return ret;\r\n }, {})\r\n };\r\n\r\n // Set Default Font and Style\r\n this.createStyle({\r\n font: this.opts.defaultFont\r\n });\r\n }\r\n\r\n /**\r\n * setSelectedTab\r\n * @param {Number} tab number of sheet that should be displayed when workbook opens. tabs are indexed starting with 1\r\n **/\r\n setSelectedTab(id) {\r\n this.sheets.forEach((s) => {\r\n if (s.sheetId === id) {\r\n s.opts.sheetView.tabSelected = 1;\r\n } else {\r\n s.opts.sheetView.tabSelected = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * writeToBuffer\r\n * Writes Excel data to a node Buffer.\r\n */\r\n writeToBuffer() {\r\n return builder.writeToBuffer(this);\r\n }\r\n\r\n /**\r\n * Generate .xlsx file.\r\n * @param {String} fileName Name of Excel workbook with .xslx extension\r\n * @param {http.response | callback} http response object or callback function (optional).\r\n * If http response object is given, file is written to http response. Useful for web applications.\r\n * If callback is given, callback called with (err, fs.Stats) passed\r\n */\r\n write(fileName, handler) {\r\n\r\n builder.writeToBuffer(this)\r\n .then((buffer) => {\r\n switch (typeof handler) {\r\n // handler passed as http response object.\r\n\r\n case 'object':\r\n if (handler instanceof http.ServerResponse) {\r\n handler.writeHead(200, {\r\n 'Content-Length': buffer.length,\r\n 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\r\n 'Content-Disposition': `attachment; filename=\"${encodeURIComponent(fileName)}\"; filename*=utf-8''${encodeURIComponent(fileName)};`,\r\n });\r\n handler.end(buffer);\r\n } else {\r\n throw new TypeError('Unknown object sent to write function.');\r\n }\r\n break;\r\n\r\n // handler passed as callback function\r\n case 'function':\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n handler(err);\r\n } else {\r\n fs.stat(fileName, handler);\r\n }\r\n });\r\n break;\r\n\r\n // no handler passed, write file to FS.\r\n default:\r\n\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n throw err;\r\n }\r\n });\r\n break;\r\n }\r\n })\r\n .catch((e) => {\r\n if (handler instanceof http.ServerResponse) {\r\n this.logger.error(e.stack);\r\n handler.status = 500;\r\n handler.setHeader('Content-Type', 'text/plain');\r\n handler.end('500 Server Error');\r\n } else if (typeof handler === 'function') {\r\n handler(e.stack);\r\n } else {\r\n this.logger.error(e.stack);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Add a worksheet to the Workbook\r\n * @param {String} name Name of the Worksheet\r\n * @param {Object} opts Options for Worksheet. See Worksheet class definition\r\n * @returns {Worksheet}\r\n */\r\n addWorksheet(name, opts) {\r\n let newLength = this.sheets.push(new Worksheet(this, name, opts));\r\n return this.sheets[newLength - 1];\r\n }\r\n\r\n /**\r\n * Add a Style to the Workbook\r\n * @param {Object} opts Options for the style. See Style class definition\r\n * @returns {Style}\r\n */\r\n createStyle(opts) {\r\n const thisStyle = new Style(this, opts);\r\n const lookupKey = JSON.stringify(thisStyle.toObject());\r\n\r\n // Use existing style if one exists\r\n if (this.stylesLookup.get(lookupKey)) {\r\n return this.stylesLookup.get(lookupKey);\r\n }\r\n\r\n this.stylesLookup.set(lookupKey, thisStyle);\r\n const index = this.styles.push(thisStyle) - 1;\r\n this.styles[index].ids.cellXfs = index;\r\n return this.styles[index];\r\n }\r\n\r\n /**\r\n * Gets the index of a string from the shared string array if exists and adds the string if it does not and returns the new index\r\n * @param {String} val Text of string\r\n * @returns {Number} index of the string in the shared strings array\r\n */\r\n getStringIndex(val) {\r\n const lookupKey = typeof val === \"string\" ? val : JSON.stringify(val);\r\n const target = this.sharedStringLookup.get(lookupKey);\r\n if (_isUndefined(target)) {\r\n const index = this.sharedStrings.push(val) - 1;\r\n this.sharedStringLookup.set(lookupKey, index);\r\n return index;\r\n } else {\r\n return target;\r\n }\r\n }\r\n\r\n /**\r\n * @func Workbook._generateXML\r\n * @desc used for testing the Workbook XML generated by the builder\r\n * @return {Promise} resolves with Workbook XML \r\n */\r\n _generateXML() {\r\n return builder.workbookXML(this);\r\n }\r\n}\r\n\r\nmodule.exports = Workbook;"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/workbook/workbook.js"],"names":["_isUndefined","require","deepmerge","fs","utils","Worksheet","Style","Border","Fill","Font","DXFCollection","MediaCollection","ChartsCollection","DefinedNameCollection","types","builder","http","SimpleLogger","workbookDefaultOpts","jszip","compression","defaultFont","dateFormat","Workbook","opts","hasCustomLogger","logger","undefined","hasValidCustomLogger","warn","error","logLevel","Number","isNaN","parseInt","log","author","sheets","sharedStrings","sharedStringLookup","Map","styles","stylesLookup","dxfCollection","mediaCollection","chartsCollection","definedNameCollection","styleData","type","patternType","styleDataLookup","fills","reduce","ret","fill","index","JSON","stringify","toObject","borders","border","createStyle","font","id","forEach","s","sheetId","sheetView","tabSelected","writeToBuffer","fileName","handler","then","buffer","ServerResponse","writeHead","length","encodeURIComponent","end","TypeError","writeFile","err","stat","catch","e","stack","status","setHeader","name","newLength","push","thisStyle","lookupKey","get","set","ids","cellXfs","val","target","workbookXML","module","exports"],"mappings":";;;;;;;;AAAA,IAAMA,eAAeC,QAAQ,oBAAR,CAArB;AACA,IAAMC,YAAYD,QAAQ,WAAR,CAAlB;AACA,IAAME,KAAKF,QAAQ,IAAR,CAAX;AACA,IAAMG,QAAQH,QAAQ,aAAR,CAAd;AACA,IAAMI,YAAYJ,QAAQ,cAAR,CAAlB;AACA,IAAMK,QAAQL,QAAQ,UAAR,CAAd;AACA,IAAMM,SAASN,QAAQ,4BAAR,CAAf;AACA,IAAMO,OAAOP,QAAQ,0BAAR,CAAb;AACA,IAAMQ,OAAOR,QAAQ,uBAAR,CAAb;AACA,IAAMS,gBAAgBT,QAAQ,oBAAR,CAAtB;AACA,IAAMU,kBAAkBV,QAAQ,sBAAR,CAAxB;AACA,IAAMW,mBAAmBX,QAAQ,uBAAR,CAAzB;AACA,IAAMY,wBAAwBZ,QAAQ,qCAAR,CAA9B;AACA,IAAMa,QAAQb,QAAQ,mBAAR,CAAd;AACA,IAAMc,UAAUd,QAAQ,cAAR,CAAhB;AACA,IAAMe,OAAOf,QAAQ,MAAR,CAAb;AACA,IAAMgB,eAAehB,QAAQ,WAAR,CAArB;;AAEA;;;;;;;;;;;;AAYA;AACA,IAAIiB,sBAAsB;AACtBC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,KAAjC;AACA,mBAAO,KAAKd,MAAL,CAAYc,KAAZ,CAAP;AACH;;AAED;;;;;;;;uCAKe0C,G,EAAK;AAChB,gBAAML,YAAY,OAAOK,GAAP,KAAe,QAAf,GAA0BA,GAA1B,GAAgCzC,KAAKC,SAAL,CAAewC,GAAf,CAAlD;AACA,gBAAMC,SAAS,KAAK3D,kBAAL,CAAwBsD,GAAxB,CAA4BD,SAA5B,CAAf;AACA,gBAAI5F,aAAakG,MAAb,CAAJ,EAA0B;AACtB,oBAAM3C,QAAQ,KAAKjB,aAAL,CAAmBoD,IAAnB,CAAwBO,GAAxB,IAA+B,CAA7C;AACA,qBAAK1D,kBAAL,CAAwBuD,GAAxB,CAA4BF,SAA5B,EAAuCrC,KAAvC;AACA,uBAAOA,KAAP;AACH,aAJD,MAIO;AACH,uBAAO2C,MAAP;AACH;AACJ;;AAED;;;;;;;;uCAKe;AACX,mBAAOnF,QAAQoF,WAAR,CAAoB,IAApB,CAAP;AACH;;;;;;AAGLC,OAAOC,OAAP,GAAiB9E,QAAjB","file":"workbook.js","sourcesContent":["const _isUndefined = require('lodash.isundefined');\r\nconst deepmerge = require('deepmerge');\r\nconst fs = require('fs');\r\nconst utils = require('../utils.js');\r\nconst Worksheet = require('../worksheet');\r\nconst Style = require('../style');\r\nconst Border = require('../style/classes/border.js');\r\nconst Fill = require('../style/classes/fill.js');\r\nconst Font = require('../style/classes/font');\r\nconst DXFCollection = require('./dxfCollection.js');\r\nconst MediaCollection = require('./mediaCollection.js');\r\nconst ChartsCollection = require('./chartsCollection.js');\r\nconst DefinedNameCollection = require('../classes/definedNameCollection.js');\r\nconst types = require('../types/index.js');\r\nconst builder = require('./builder.js');\r\nconst http = require('http');\r\nconst SimpleLogger = require('../logger');\r\n\r\n/* Available options for Workbook\r\n{\r\n jszip : {\r\n compression : 'DEFLATE'\r\n },\r\n defaultFont : {\r\n size : 12,\r\n family : 'Calibri',\r\n color : 'FFFFFFFF'\r\n }\r\n}\r\n*/\r\n// Default Options for Workbook\r\nlet workbookDefaultOpts = {\r\n jszip: {\r\n compression: 'DEFLATE'\r\n },\r\n defaultFont: {\r\n 'color': 'FF000000',\r\n 'name': 'Calibri',\r\n 'size': 12,\r\n 'family': 'roman'\r\n },\r\n dateFormat: 'm/d/yy'\r\n};\r\n\r\n\r\nclass Workbook {\r\n\r\n /**\r\n * @class Workbook\r\n * @param {Object} opts Workbook settings\r\n * @param {Object} opts.jszip\r\n * @param {String} opts.jszip.compression JSZip compression type. defaults to 'DEFLATE'\r\n * @param {Object} opts.defaultFont\r\n * @param {String} opts.defaultFont.color HEX value of default font color. defaults to #000000\r\n * @param {String} opts.defaultFont.name Font name. defaults to Calibri\r\n * @param {Number} opts.defaultFont.size Font size. defaults to 12\r\n * @param {String} opts.defaultFont.family Font family. defaults to roman\r\n * @param {String} opts.dataFormat Specifies the format for dates in the Workbook. defaults to 'm/d/yy'\r\n * @param {Number} opts.workbookView.activeTab Specifies an unsignedInt that contains the index to the active sheet in this book view.\r\n * @param {Boolean} opts.workbookView.autoFilterDateGrouping Specifies a boolean value that indicates whether to group dates when presenting the user with filtering options in the user interface.\r\n * @param {Number} opts.workbookView.firstSheet Specifies the index to the first sheet in this book view.\r\n * @param {Boolean} opts.workbookView.minimized Specifies a boolean value that indicates whether the workbook window is minimized.\r\n * @param {Boolean} opts.workbookView.showHorizontalScroll Specifies a boolean value that indicates whether to display the horizontal scroll bar in the user interface.\r\n * @param {Boolean} opts.workbookView.showSheetTabs Specifies a boolean value that indicates whether to display the sheet tabs in the user interface.\r\n * @param {Boolean} opts.workbookView.showVerticalScroll Specifies a boolean value that indicates whether to display the vertical scroll bar.\r\n * @param {Number} opts.workbookView.tabRatio Specifies ratio between the workbook tabs bar and the horizontal scroll bar.\r\n * @param {String} opts.workbookView.visibility Specifies visible state of the workbook window. ('hidden', 'veryHidden', 'visible') (§18.18.89)\r\n * @param {Number} opts.workbookView.windowHeight Specifies the height of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.windowWidth Specifies the width of the workbook window. The unit of measurement for this value is twips..\r\n * @param {Number} opts.workbookView.xWindow Specifies the X coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Number} opts.workbookView.yWindow Specifies the Y coordinate for the upper left corner of the workbook window. The unit of measurement for this value is twips.\r\n * @param {Boolean} opts.workbookView\r\n * @param {Object} opts.logger Logger that supports warn and error method, defaults to console\r\n * @param {String} opts.author Name displayed as document's author\r\n * @returns {Workbook}\r\n */\r\n constructor(opts = {}) {\r\n\r\n const hasCustomLogger = opts.logger !== undefined;\r\n const hasValidCustomLogger = hasCustomLogger && typeof opts.logger.warn === 'function' && typeof opts.logger.error === 'function';\r\n\r\n this.logger = hasValidCustomLogger ? opts.logger : new SimpleLogger({\r\n logLevel: Number.isNaN(parseInt(opts.logLevel)) ? 0 : parseInt(opts.logLevel)\r\n });\r\n if (hasCustomLogger && !hasValidCustomLogger) {\r\n this.logger.log('opts.logger is not a valid logger');\r\n }\r\n\r\n this.opts = deepmerge(workbookDefaultOpts, opts);\r\n this.author = this.opts.author || 'Microsoft Office User';\r\n\r\n this.sheets = [];\r\n this.sharedStrings = [];\r\n this.sharedStringLookup = new Map();\r\n this.styles = [];\r\n this.stylesLookup = new Map();\r\n this.dxfCollection = new DXFCollection(this);\r\n this.mediaCollection = new MediaCollection();\r\n this.chartsCollection = new ChartsCollection();\r\n this.definedNameCollection = new DefinedNameCollection();\r\n this.styleData = {\r\n 'numFmts': [],\r\n 'fonts': [],\r\n 'fills': [new Fill({\r\n type: 'pattern',\r\n patternType: 'none'\r\n }), new Fill({\r\n type: 'pattern',\r\n patternType: 'gray125'\r\n })],\r\n 'borders': [new Border()],\r\n 'cellXfs': [{\r\n 'borderId': null,\r\n 'fillId': null,\r\n 'fontId': 0,\r\n 'numFmtId': null\r\n }]\r\n };\r\n\r\n // Lookups for style components to quickly find existing entries\r\n // - Lookup keys are stringified JSON of a style's toObject result\r\n // - Lookup values are the indexes for the actual entry in the styleData arrays\r\n this.styleDataLookup = {\r\n 'fonts': {},\r\n 'fills': this.styleData.fills.reduce((ret, fill, index) => {\r\n ret[JSON.stringify(fill.toObject())] = index;\r\n return ret;\r\n }, {}),\r\n 'borders': this.styleData.borders.reduce((ret, border, index) => {\r\n ret[JSON.stringify(border.toObject())] = index;\r\n return ret;\r\n }, {})\r\n };\r\n\r\n // Set Default Font and Style\r\n this.createStyle({\r\n font: this.opts.defaultFont\r\n });\r\n }\r\n\r\n /**\r\n * setSelectedTab\r\n * @param {Number} tab number of sheet that should be displayed when workbook opens. tabs are indexed starting with 1\r\n **/\r\n setSelectedTab(id) {\r\n this.sheets.forEach((s) => {\r\n if (s.sheetId === id) {\r\n s.opts.sheetView.tabSelected = 1;\r\n } else {\r\n s.opts.sheetView.tabSelected = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * writeToBuffer\r\n * Writes Excel data to a node Buffer.\r\n */\r\n writeToBuffer() {\r\n return builder.writeToBuffer(this);\r\n }\r\n\r\n /**\r\n * Generate .xlsx file.\r\n * @param {String} fileName Name of Excel workbook with .xslx extension\r\n * @param {http.response | callback} http response object or callback function (optional).\r\n * If http response object is given, file is written to http response. Useful for web applications.\r\n * If callback is given, callback called with (err, fs.Stats) passed\r\n */\r\n write(fileName, handler) {\r\n\r\n builder.writeToBuffer(this)\r\n .then((buffer) => {\r\n switch (typeof handler) {\r\n // handler passed as http response object.\r\n\r\n case 'object':\r\n if (handler instanceof http.ServerResponse) {\r\n handler.writeHead(200, {\r\n 'Content-Length': buffer.length,\r\n 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\r\n 'Content-Disposition': `attachment; filename=\"${encodeURIComponent(fileName)}\"; filename*=utf-8''${encodeURIComponent(fileName)};`,\r\n });\r\n handler.end(buffer);\r\n } else {\r\n throw new TypeError('Unknown object sent to write function.');\r\n }\r\n break;\r\n\r\n // handler passed as callback function\r\n case 'function':\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n handler(err);\r\n } else {\r\n fs.stat(fileName, handler);\r\n }\r\n });\r\n break;\r\n\r\n // no handler passed, write file to FS.\r\n default:\r\n\r\n fs.writeFile(fileName, buffer, function (err) {\r\n if (err) {\r\n throw err;\r\n }\r\n });\r\n break;\r\n }\r\n })\r\n .catch((e) => {\r\n if (handler instanceof http.ServerResponse) {\r\n this.logger.error(e.stack);\r\n handler.status = 500;\r\n handler.setHeader('Content-Type', 'text/plain');\r\n handler.end('500 Server Error');\r\n } else if (typeof handler === 'function') {\r\n handler(e.stack);\r\n } else {\r\n this.logger.error(e.stack);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Add a worksheet to the Workbook\r\n * @param {String} name Name of the Worksheet\r\n * @param {Object} opts Options for Worksheet. See Worksheet class definition\r\n * @returns {Worksheet}\r\n */\r\n addWorksheet(name, opts) {\r\n let newLength = this.sheets.push(new Worksheet(this, name, opts));\r\n return this.sheets[newLength - 1];\r\n }\r\n\r\n /**\r\n * Add a Style to the Workbook\r\n * @param {Object} opts Options for the style. See Style class definition\r\n * @returns {Style}\r\n */\r\n createStyle(opts) {\r\n const thisStyle = new Style(this, opts);\r\n const lookupKey = JSON.stringify(thisStyle.toObject());\r\n\r\n // Use existing style if one exists\r\n if (this.stylesLookup.get(lookupKey)) {\r\n return this.stylesLookup.get(lookupKey);\r\n }\r\n\r\n this.stylesLookup.set(lookupKey, thisStyle);\r\n const index = this.styles.push(thisStyle) - 1;\r\n this.styles[index].ids.cellXfs = index;\r\n return this.styles[index];\r\n }\r\n\r\n /**\r\n * Gets the index of a string from the shared string array if exists and adds the string if it does not and returns the new index\r\n * @param {String} val Text of string\r\n * @returns {Number} index of the string in the shared strings array\r\n */\r\n getStringIndex(val) {\r\n const lookupKey = typeof val === \"string\" ? val : JSON.stringify(val);\r\n const target = this.sharedStringLookup.get(lookupKey);\r\n if (_isUndefined(target)) {\r\n const index = this.sharedStrings.push(val) - 1;\r\n this.sharedStringLookup.set(lookupKey, index);\r\n return index;\r\n } else {\r\n return target;\r\n }\r\n }\r\n\r\n /**\r\n * @func Workbook._generateXML\r\n * @desc used for testing the Workbook XML generated by the builder\r\n * @return {Promise} resolves with Workbook XML \r\n */\r\n _generateXML() {\r\n return builder.workbookXML(this);\r\n }\r\n}\r\n\r\nmodule.exports = Workbook;"]} \ No newline at end of file diff --git a/distribution/lib/worksheet/worksheet.js b/distribution/lib/worksheet/worksheet.js index 9fe80bd0..5b02843c 100644 --- a/distribution/lib/worksheet/worksheet.js +++ b/distribution/lib/worksheet/worksheet.js @@ -271,6 +271,14 @@ var Worksheet = function () { return newImage; } + }, { + key: 'addChart', + value: function addChart(opts) { + var mediaID = this.wb.chartsCollection.add(opts); + var newImage = this.drawingCollection.add(opts); + newImage.id = mediaID; + return newImage; + } /** * @func Worksheet.addPageBreak diff --git a/distribution/lib/worksheet/worksheet.js.map b/distribution/lib/worksheet/worksheet.js.map index afb47bec..dc8545d5 100644 --- a/distribution/lib/worksheet/worksheet.js.map +++ b/distribution/lib/worksheet/worksheet.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/worksheet/worksheet.js"],"names":["deepmerge","require","CfRulesCollection","cellAccessor","rowAccessor","colAccessor","wsDefaultParams","HyperlinkCollection","DataValidation","wsDrawing","xmlBuilder","optsValidator","Worksheet","wb","name","opts","sheetId","sheets","length","localSheetId","hasGroupings","cols","rows","cells","mergedCells","pageBreaks","row","column","printArea","lastUsedRow","lastUsedCol","cfRulesCollection","hyperlinkCollection","dataValidationCollection","DataValidationCollection","drawingCollection","DrawingCollection","legacyDrawingHeaderFooter","comments","author","sqref","options","style","Style","dxf","dxfCollection","add","dxfId","id","newValidation","relsXML","Object","keys","commentsXML","commentsVmlXML","sheetXML","col","mediaID","mediaCollection","path","image","newImage","type","position","logger","warn","indexOf","push","startRow","startCol","endRow","endCol","headerFooterPositions","Error","mediaId","ximg","rels","isEmpty","links","forEach","l","Math","max","apply","bind","module","exports"],"mappings":";;;;;;AAAA,IAAMA,YAAYC,Q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H,aAFD;AAGA,gBAAI,CAAC,KAAK7C,iBAAL,CAAuB0C,OAA5B,EAAqC;AACjCD,qBAAKT,IAAL,CAAU,SAAV;AACH;AACD,gBAAGhB,OAAOC,IAAP,CAAY,KAAKd,QAAjB,EAA2BpB,MAA3B,GAAoC,CAAvC,EAA0C;AACtC0D,qBAAKT,IAAL,CAAU,UAAV;AACAS,qBAAKT,IAAL,CAAU,aAAV;AACH;AACD,mBAAOS,IAAP;AACH;;;4BAEiB;AACd,mBAAOK,KAAKC,GAAL,CAASC,KAAT,CAAeF,IAAf,EAAqB9B,OAAOC,IAAP,CAAY,KAAK/B,IAAjB,CAArB,CAAP;AACH;;;4BAEc;AACX,mBAAO4D,KAAKC,GAAL,CAASC,KAAT,CAAeF,IAAf,EAAqB9B,OAAOC,IAAP,CAAY,KAAK9B,IAAjB,CAArB,CAAP;AACH;;;4BAyEU;AACP,mBAAOnB,aAAaiF,IAAb,CAAkB,IAAlB,CAAP;AACH;;;;;;AA0GLC,OAAOC,OAAP,GAAiB1E,SAAjB","file":"worksheet.js","sourcesContent":["const deepmerge = require('deepmerge');\r\nconst CfRulesCollection = require('./cf/cf_rules_collection');\r\nconst cellAccessor = require('../cell');\r\nconst rowAccessor = require('../row');\r\nconst colAccessor = require('../column');\r\nconst wsDefaultParams = require('./sheet_default_params.js');\r\nconst HyperlinkCollection = require('./classes/hyperlink.js').HyperlinkCollection;\r\nconst DataValidation = require('./classes/dataValidation.js');\r\nconst wsDrawing = require('../drawing/index.js');\r\nconst xmlBuilder = require('./builder.js');\r\nconst optsValidator = require('./optsValidator.js');\r\n\r\n\r\nclass Worksheet {\r\n /**\r\n * Create a Worksheet.\r\n * @class Worksheet\r\n * @param {Workbook} wb Workbook that the Worksheet will belong to\r\n * @param {String} name Name of Worksheet\r\n * @param {Object} opts Worksheet settings\r\n * @param {Object} opts.margins\r\n * @param {Number} opts.margins.bottom Bottom margin in inches\r\n * @param {Number} opts.margins.footer Footer margin in inches\r\n * @param {Number} opts.margins.header Header margin in inches\r\n * @param {Number} opts.margins.left Left margin in inches\r\n * @param {Number} opts.margins.right Right margin in inches\r\n * @param {Number} opts.margins.top Top margin in inches\r\n * @param {Object} opts.printOptions Print Options object\r\n * @param {Boolean} opts.printOptions.centerHorizontal Should data be centered horizontally when printed\r\n * @param {Boolean} opts.printOptions.centerVertical Should data be centered vertically when printed\r\n * @param {Boolean} opts.printOptions.printGridLines Should gridlines by printed\r\n * @param {Boolean} opts.printOptions.printHeadings Should Heading be printed\r\n * @param {String} opts.headerFooter Set Header and Footer strings and options. \r\n * @param {String} opts.headerFooter.evenFooter Even footer text\r\n * @param {String} opts.headerFooter.evenHeader Even header text\r\n * @param {String} opts.headerFooter.firstFooter First footer text\r\n * @param {String} opts.headerFooter.firstHeader First header text\r\n * @param {String} opts.headerFooter.oddFooter Odd footer text\r\n * @param {String} opts.headerFooter.oddHeader Odd header text\r\n * @param {Boolean} opts.headerFooter.alignWithMargins Should header/footer align with margins\r\n * @param {Boolean} opts.headerFooter.differentFirst Should header/footer show a different header/footer on first page\r\n * @param {Boolean} opts.headerFooter.differentOddEven Should header/footer show a different header/footer on odd and even pages\r\n * @param {Boolean} opts.headerFooter.scaleWithDoc Should header/footer scale when doc zoom is changed\r\n * @param {Object} opts.pageSetup\r\n * @param {Boolean} opts.pageSetup.blackAndWhite\r\n * @param {String} opts.pageSetup.cellComments one of 'none', 'asDisplayed', 'atEnd'\r\n * @param {Number} opts.pageSetup.copies How many copies to print\r\n * @param {Boolean} opts.pageSetup.draft Should quality be draft\r\n * @param {String} opts.pageSetup.errors One of 'displayed', 'blank', 'dash', 'NA'\r\n * @param {Number} opts.pageSetup.firstPageNumber Should the page number of the first page be printed\r\n * @param {Number} opts.pageSetup.fitToHeight Number of vertical pages to fit to\r\n * @param {Number} opts.pageSetup.fitToWidth Number of horizontal pages to fit to\r\n * @param {Number} opts.pageSetup.horizontalDpi \r\n * @param {String} opts.pageSetup.orientation One of 'default', 'portrait', 'landscape'\r\n * @param {String} opts.pageSetup.pageOrder One of 'downThenOver', 'overThenDown'\r\n * @param {String} opts.pageSetup.paperHeight Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {String} opts.pageSetup.paperSize see lib/types/paperSize.js for all types and descriptions of types. setting paperSize overrides paperHeight and paperWidth settings\r\n * @param {String} opts.pageSetup.paperWidth Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {Number} opts.pageSetup.scale zoom of worksheet\r\n * @param {Boolean} opts.pageSetup.useFirstPageNumber\r\n * @param {Boolean} opts.pageSetup.usePrinterDefaults\r\n * @param {Number} opts.pageSetup.verticalDpi \r\n * @param {Object} opts.sheetView \r\n * @param {Object} opts.sheetView.pane \r\n * @param {String} opts.sheetView.pane.activePane one of 'bottomLeft', 'bottomRight', 'topLeft', 'topRight'\r\n * @param {String} opts.sheetView.pane.state ne of 'split', 'frozen', 'frozenSplit'\r\n * @param {String} opts.sheetView.pane.topLeftCell Cell Reference i.e. 'A1'\r\n * @param {String} opts.sheetView.pane.xSplit Horizontal position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of columns visible in the top pane.\r\n * @param {String} opts.sheetView.pane.ySplit Vertical position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of rows visible in the left pane.\r\n * @param {Boolean} opts.sheetView.rightToLeft Flag indicating whether the sheet is in 'right to left' display mode. When in this mode, Column A is on the far right, Column B ;is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format.\r\n * @param {Boolean} opts.sheetView.showGridLines Flag indicating whether the sheet should have gridlines enabled or disabled during view.\r\n * @param {Number} opts.sheetView.zoomScale Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScaleNormal Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScalePageLayoutView Defaults to 100\r\n * @param {Object} opts.sheetFormat \r\n * @param {Number} opts.sheetFormat.baseColWidth Defaults to 10. Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.,\r\n * @param {Number} opts.sheetFormat.defaultColWidth\r\n * @param {Number} opts.sheetFormat.defaultRowHeight\r\n * @param {Boolean} opts.sheetFormat.thickBottom 'True' if rows have a thick bottom border by default.\r\n * @param {Boolean} opts.sheetFormat.thickTop 'True' if rows have a thick top border by default.\r\n * @param {Object} opts.sheetProtection same as \"Protect Sheet\" in Review tab of Excel \r\n * @param {Boolean} opts.sheetProtection.autoFilter True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertHyperlinks True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.objects True means that that user will be unable to modify this setting\r\n * @param {String} opts.sheetProtection.password Password used to protect sheet\r\n * @param {Boolean} opts.sheetProtection.pivotTables True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.scenarios True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectLockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectUnlockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sheet True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sort True means that that user will be unable to modify this setting\r\n * @param {Object} opts.outline \r\n * @param {Boolean} opts.outline.summaryBelow Flag indicating whether summary rows appear below detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.outline.summaryRight Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.disableRowSpansOptimization Flag indicated whether to not include a spans attribute to the row definition in the XML. helps with very large documents.\r\n * @param {Boolean} opts.hidden Flag indicating whether to not hide the worksheet within the workbook.\r\n * @returns {Worksheet}\r\n */\r\n constructor(wb, name, opts = {}) {\r\n\r\n this.wb = wb;\r\n this.sheetId = this.wb.sheets.length + 1;\r\n this.localSheetId = this.wb.sheets.length;\r\n this.opts = deepmerge(wsDefaultParams, opts);\r\n optsValidator(opts);\r\n \r\n this.name = name ? name : `Sheet ${this.sheetId}`;\r\n this.hasGroupings = false;\r\n this.cols = {}; // Columns keyed by column, contains column properties\r\n this.rows = {}; // Rows keyed by row, contains row properties and array of cellRefs\r\n this.cells = {}; // Cells keyed by Excel ref\r\n this.mergedCells = [];\r\n this.pageBreaks = {\r\n row: [],\r\n column: [],\r\n };\r\n this.printArea = null;\r\n this.lastUsedRow = 1;\r\n this.lastUsedCol = 1;\r\n\r\n // conditional formatting rules hashed by sqref\r\n this.cfRulesCollection = new CfRulesCollection();\r\n this.hyperlinkCollection = new HyperlinkCollection();\r\n this.dataValidationCollection = new DataValidation.DataValidationCollection();\r\n this.drawingCollection = new wsDrawing.DrawingCollection();\r\n this.legacyDrawingHeaderFooter = new wsDrawing.DrawingCollection();\r\n this.comments = {}; // Comments for cells keyed by excel ref\r\n this.author = this.wb.author;\r\n\r\n }\r\n\r\n get relationships() {\r\n let rels = [];\r\n if(!this.legacyDrawingHeaderFooter.isEmpty){\r\n rels.push('legacyDrawingHeaderFooter')\r\n }\r\n this.hyperlinkCollection.links.forEach((l) => {\r\n rels.push(l);\r\n });\r\n if (!this.drawingCollection.isEmpty) {\r\n rels.push('drawing');\r\n }\r\n if(Object.keys(this.comments).length > 0) {\r\n rels.push('comments');\r\n rels.push('commentsVml');\r\n }\r\n return rels;\r\n }\r\n\r\n get columnCount() {\r\n return Math.max.apply(Math, Object.keys(this.cols));\r\n }\r\n\r\n get rowCount() {\r\n return Math.max.apply(Math, Object.keys(this.rows));\r\n }\r\n\r\n /**\r\n * @func Worksheet.addConditionalFormattingRule\r\n * @param {String} sqref Text represetation of Cell range where the conditional formatting will take effect\r\n * @param {Object} options Options for conditional formatting\r\n * @param {String} options.type Type of conditional formatting\r\n * @param {String} options.priority Priority level for this rule\r\n * @param {String} options.formula Formula that returns nonzero or 0 value. If not 0 then rule will be applied\r\n * @param {Style} options.style Style that should be applied if rule passes\r\n * @returns {Worksheet}\r\n */\r\n addConditionalFormattingRule(sqref, options) {\r\n let style = options.style || this.wb.Style();\r\n let dxf = this.wb.dxfCollection.add(style);\r\n delete options.style;\r\n options.dxfId = dxf.id;\r\n this.cfRulesCollection.add(sqref, options);\r\n return this;\r\n }\r\n /**\r\n * @func Worksheet.addDataValidation\r\n * @desc Add a data validation rule to the Worksheet\r\n * @param {Object} opts Options for Data Validation rule\r\n * @param {String} opts.sqref Required. Specifies range of cells to apply validate. i.e. \"A1:A100\"\r\n * @param {Boolean} opts.allowBlank Allows cells to be empty\r\n * @param {String} opts.errorStyle One of 'stop', 'warning', 'information'. You must specify an error string for this to take effect\r\n * @param {String} opts.error Message to show on error\r\n * @param {String} opts.errorTitle: String Title of message shown on error\r\n * @param {Boolean} opts.showErrorMessage Defaults to true if error or errorTitle is set\r\n * @param {String} opts.imeMode Restricts input to a specific set of characters. One of 'noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul'\r\n * @param {String} opts.operator Must be one of 'between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual'\r\n * @param {String} opts.prompt Message text of input prompt\r\n * @param {String} opts.promptTitle Title of input prompt\r\n * @param {Boolean} opts.showInputMessage Defaults to true if prompt or promptTitle is set\r\n * @param {Boolean} opts.showDropDown A boolean value indicating whether to display a dropdown combo box for a list type data validation.\r\n * @param {String} opts.type One of 'none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom'\r\n * @param {Array.String} opts.formulas Minimum count 1, maximum count 2. Rules for validation\r\n */\r\n addDataValidation(opts) {\r\n let newValidation = this.dataValidationCollection.add(opts);\r\n return newValidation;\r\n }\r\n /**\r\n * @func Worksheet.generateRelsXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet .rels file\r\n */\r\n generateRelsXML() {\r\n return xmlBuilder.relsXML(this);\r\n }\r\n\r\n generateCommentsXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsXML(this);\r\n }\r\n\r\n generateCommentsVmlXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsVmlXML(this);\r\n }\r\n\r\n /**\r\n * @func Worksheet.generateXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet xml file \r\n */\r\n generateXML() {\r\n return xmlBuilder.sheetXML(this);\r\n }\r\n\r\n get cell() {\r\n return cellAccessor.bind(this);\r\n }\r\n\r\n row(row) {\r\n return rowAccessor(this, row);\r\n }\r\n\r\n column(col) {\r\n return colAccessor(this, col);\r\n }\r\n /**\r\n * @func Worksheet.addImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {Object} opts.position Position object for image\r\n * @param {String} opts.position.type Type of positional anchor to use. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor'\r\n * @param {Object} opts.position.from Object containg position of top left corner of image. Used with oneCellAnchor and twoCellAchor types\r\n * @param {Number} opts.position.from.col Left edge of image will align with left edge of this column\r\n * @param {String} opts.position.from.colOff Offset from left edge of column\r\n * @param {Number} opts.position.from.row Top edge of image will align with top edge of this row\r\n * @param {String} opts.position.from.rowOff Offset from top edge of row\r\n * @param {Object} opts.position.to Object containing position of bottom right corner of image\r\n * @param {Number} opts.position.to.col Right edge of image will align with Left edge of this column\r\n * @param {String} opts.position.to.colOff Offset of left edge of column\r\n * @param {Number} opts.position.to.row Bottom edge of image will align with Top edge of this row\r\n * @param {String} opts.position.to.rowOff Offset of top edge of row\r\n * @param {String} opts.position.x X position of top left corner of image. Used with absoluteAchor type\r\n * @param {String} opts.position.y Y position of top left corner of image\r\n */\r\n addImage(opts) {\r\n opts = opts ? opts : {};\r\n let mediaID = this.wb.mediaCollection.add(opts.path || opts.image);\r\n let newImage = this.drawingCollection.add(opts);\r\n newImage.id = mediaID;\r\n\r\n return newImage;\r\n }\r\n\r\n /**\r\n * @func Worksheet.addPageBreak\r\n * @param {string} type \r\n * @param {number} position \r\n * @returns {Worksheet}\r\n */\r\n addPageBreak(type, position) {\r\n if ((type !== 'row' && type !== 'column') || typeof position !== 'number') {\r\n this.wb.logger.warn('invalid option sent to addPageBreak method', type, position);\r\n return;\r\n }\r\n if (this.pageBreaks[type].indexOf(position) < 0) {\r\n this.pageBreaks[type].push(position);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @method Worksheet.addPrintArea\r\n * @param {number} startRow \r\n * @param {number} startCol \r\n * @param {number} endRow \r\n * @param {number} endCol \r\n * @returns {Worksheet}\r\n */\r\n setPrintArea(startRow, startCol, endRow, endCol) {\r\n if (\r\n typeof startRow !== 'number' ||\r\n typeof startCol !== 'number' ||\r\n typeof endRow !== 'number' ||\r\n typeof endCol !== 'number'\r\n ) {\r\n this.wb.logger.warn('invalid option sent to setPrintArea method');\r\n return;\r\n }\r\n this.printArea = {\r\n startRow,\r\n startCol,\r\n endRow,\r\n endCol,\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @func Worksheet.setHeaderFooterImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {String} opts.position Position string for image: ['LF','CF', 'RF', 'LH', 'CH', 'RH'] \r\n */\r\n addHeaderFooterImage(image, position){\r\n const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH'];\r\n if(headerFooterPositions.indexOf(position) < 0){\r\n throw new Error('setHeaderFooterImage: Only allowed positions are LH, CH, RH, LF, CF, RF');\r\n }\r\n if(image.type === 'picture') image.type = 'headerFooterPicture';\r\n var mediaId = this.wb.mediaCollection.add(image);\r\n var ximg = this.legacyDrawingHeaderFooter.add(image)\r\n ximg.position = position;\r\n ximg.id = mediaId;\r\n }\r\n}\r\n\r\nmodule.exports = Worksheet;"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/worksheet/worksheet.js"],"names":["deepmerge","require","CfRulesCollection","cellAccessor","rowAccessor","colAccessor","wsDefaultParams","HyperlinkCollection","DataValidation","wsDrawing","xmlBuilder","optsValidator","Worksheet","wb","name","opts","sheetId","sheets","length","localSheetId","hasGroupings","cols","rows","cells","mergedCells","pageBreaks","row","column","printArea","lastUsedRow","lastUsedCol","cfRulesCollection","hyperlinkCollection","dataValidationCollection","DataValidationCollection","drawingCollection","DrawingCollection","legacyDrawingHeaderFooter","comments","author","sqref","options","style","Style","dxf","dxfCollection","add","dxfId","id","newValidation","relsXML","Object","keys","commentsXML","commentsVmlXML","sheetXML","col","mediaID","mediaCollection","path","image","newImage","chartsCollection","type","position","logger","warn","indexOf","push","startRow","startCol","endRow","endCol","headerFooterPositions","Error","mediaId","ximg","rels","isEmpty","links","forEach","l","Math","max","apply","bind","module","exports"],"mappings":";;;;;;AAAA,IAAMA,YAAYC,QAAQ,WAAR,CAAlB;AACA,IAAMC,oBAAoBD,QAAQ,0BAAR,CAA1B;AACA,IAAME,eAAeF,QAAQ,SAAR,CAArB;AACA,IAAMG,cAAcH,QAAQ,QAAR,CAApB;AACA,IAAMI,cAAcJ,QAAQ,WAAR,CAApB;AACA,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B,CAAuC,UAACC,CAAD,EAAO;AAC1CJ,qBAAKT,IAAL,CAAUa,CAAV;AACH,aAFD;AAGA,gBAAI,CAAC,KAAK9C,iBAAL,CAAuB2C,OAA5B,EAAqC;AACjCD,qBAAKT,IAAL,CAAU,SAAV;AACH;AACD,gBAAGjB,OAAOC,IAAP,CAAY,KAAKd,QAAjB,EAA2BpB,MAA3B,GAAoC,CAAvC,EAA0C;AACtC2D,qBAAKT,IAAL,CAAU,UAAV;AACAS,qBAAKT,IAAL,CAAU,aAAV;AACH;AACD,mBAAOS,IAAP;AACH;;;4BAEiB;AACd,mBAAOK,KAAKC,GAAL,CAASC,KAAT,CAAeF,IAAf,EAAqB/B,OAAOC,IAAP,CAAY,KAAK/B,IAAjB,CAArB,CAAP;AACH;;;4BAEc;AACX,mBAAO6D,KAAKC,GAAL,CAASC,KAAT,CAAeF,IAAf,EAAqB/B,OAAOC,IAAP,CAAY,KAAK9B,IAAjB,CAArB,CAAP;AACH;;;4BAyEU;AACP,mBAAOnB,aAAakF,IAAb,CAAkB,IAAlB,CAAP;AACH;;;;;;AAiHLC,OAAOC,OAAP,GAAiB3E,SAAjB","file":"worksheet.js","sourcesContent":["const deepmerge = require('deepmerge');\r\nconst CfRulesCollection = require('./cf/cf_rules_collection');\r\nconst cellAccessor = require('../cell');\r\nconst rowAccessor = require('../row');\r\nconst colAccessor = require('../column');\r\nconst wsDefaultParams = require('./sheet_default_params.js');\r\nconst HyperlinkCollection = require('./classes/hyperlink.js').HyperlinkCollection;\r\nconst DataValidation = require('./classes/dataValidation.js');\r\nconst wsDrawing = require('../drawing/index.js');\r\nconst xmlBuilder = require('./builder.js');\r\nconst optsValidator = require('./optsValidator.js');\r\n\r\n\r\nclass Worksheet {\r\n /**\r\n * Create a Worksheet.\r\n * @class Worksheet\r\n * @param {Workbook} wb Workbook that the Worksheet will belong to\r\n * @param {String} name Name of Worksheet\r\n * @param {Object} opts Worksheet settings\r\n * @param {Object} opts.margins\r\n * @param {Number} opts.margins.bottom Bottom margin in inches\r\n * @param {Number} opts.margins.footer Footer margin in inches\r\n * @param {Number} opts.margins.header Header margin in inches\r\n * @param {Number} opts.margins.left Left margin in inches\r\n * @param {Number} opts.margins.right Right margin in inches\r\n * @param {Number} opts.margins.top Top margin in inches\r\n * @param {Object} opts.printOptions Print Options object\r\n * @param {Boolean} opts.printOptions.centerHorizontal Should data be centered horizontally when printed\r\n * @param {Boolean} opts.printOptions.centerVertical Should data be centered vertically when printed\r\n * @param {Boolean} opts.printOptions.printGridLines Should gridlines by printed\r\n * @param {Boolean} opts.printOptions.printHeadings Should Heading be printed\r\n * @param {String} opts.headerFooter Set Header and Footer strings and options. \r\n * @param {String} opts.headerFooter.evenFooter Even footer text\r\n * @param {String} opts.headerFooter.evenHeader Even header text\r\n * @param {String} opts.headerFooter.firstFooter First footer text\r\n * @param {String} opts.headerFooter.firstHeader First header text\r\n * @param {String} opts.headerFooter.oddFooter Odd footer text\r\n * @param {String} opts.headerFooter.oddHeader Odd header text\r\n * @param {Boolean} opts.headerFooter.alignWithMargins Should header/footer align with margins\r\n * @param {Boolean} opts.headerFooter.differentFirst Should header/footer show a different header/footer on first page\r\n * @param {Boolean} opts.headerFooter.differentOddEven Should header/footer show a different header/footer on odd and even pages\r\n * @param {Boolean} opts.headerFooter.scaleWithDoc Should header/footer scale when doc zoom is changed\r\n * @param {Object} opts.pageSetup\r\n * @param {Boolean} opts.pageSetup.blackAndWhite\r\n * @param {String} opts.pageSetup.cellComments one of 'none', 'asDisplayed', 'atEnd'\r\n * @param {Number} opts.pageSetup.copies How many copies to print\r\n * @param {Boolean} opts.pageSetup.draft Should quality be draft\r\n * @param {String} opts.pageSetup.errors One of 'displayed', 'blank', 'dash', 'NA'\r\n * @param {Number} opts.pageSetup.firstPageNumber Should the page number of the first page be printed\r\n * @param {Number} opts.pageSetup.fitToHeight Number of vertical pages to fit to\r\n * @param {Number} opts.pageSetup.fitToWidth Number of horizontal pages to fit to\r\n * @param {Number} opts.pageSetup.horizontalDpi \r\n * @param {String} opts.pageSetup.orientation One of 'default', 'portrait', 'landscape'\r\n * @param {String} opts.pageSetup.pageOrder One of 'downThenOver', 'overThenDown'\r\n * @param {String} opts.pageSetup.paperHeight Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {String} opts.pageSetup.paperSize see lib/types/paperSize.js for all types and descriptions of types. setting paperSize overrides paperHeight and paperWidth settings\r\n * @param {String} opts.pageSetup.paperWidth Value must a positive Float immediately followed by unit of measure from list mm, cm, in, pt, pc, pi. i.e. '10.5cm'\r\n * @param {Number} opts.pageSetup.scale zoom of worksheet\r\n * @param {Boolean} opts.pageSetup.useFirstPageNumber\r\n * @param {Boolean} opts.pageSetup.usePrinterDefaults\r\n * @param {Number} opts.pageSetup.verticalDpi \r\n * @param {Object} opts.sheetView \r\n * @param {Object} opts.sheetView.pane \r\n * @param {String} opts.sheetView.pane.activePane one of 'bottomLeft', 'bottomRight', 'topLeft', 'topRight'\r\n * @param {String} opts.sheetView.pane.state ne of 'split', 'frozen', 'frozenSplit'\r\n * @param {String} opts.sheetView.pane.topLeftCell Cell Reference i.e. 'A1'\r\n * @param {String} opts.sheetView.pane.xSplit Horizontal position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of columns visible in the top pane.\r\n * @param {String} opts.sheetView.pane.ySplit Vertical position of the split, in 1/20th of a point; 0 (zero) if none. If the pane is frozen, this value indicates the number of rows visible in the left pane.\r\n * @param {Boolean} opts.sheetView.rightToLeft Flag indicating whether the sheet is in 'right to left' display mode. When in this mode, Column A is on the far right, Column B ;is one column left of Column A, and so on. Also, information in cells is displayed in the Right to Left format.\r\n * @param {Boolean} opts.sheetView.showGridLines Flag indicating whether the sheet should have gridlines enabled or disabled during view.\r\n * @param {Number} opts.sheetView.zoomScale Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScaleNormal Defaults to 100\r\n * @param {Number} opts.sheetView.zoomScalePageLayoutView Defaults to 100\r\n * @param {Object} opts.sheetFormat \r\n * @param {Number} opts.sheetFormat.baseColWidth Defaults to 10. Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.,\r\n * @param {Number} opts.sheetFormat.defaultColWidth\r\n * @param {Number} opts.sheetFormat.defaultRowHeight\r\n * @param {Boolean} opts.sheetFormat.thickBottom 'True' if rows have a thick bottom border by default.\r\n * @param {Boolean} opts.sheetFormat.thickTop 'True' if rows have a thick top border by default.\r\n * @param {Object} opts.sheetProtection same as \"Protect Sheet\" in Review tab of Excel \r\n * @param {Boolean} opts.sheetProtection.autoFilter True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.deleteRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.formatRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertColumns True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertHyperlinks True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.insertRows True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.objects True means that that user will be unable to modify this setting\r\n * @param {String} opts.sheetProtection.password Password used to protect sheet\r\n * @param {Boolean} opts.sheetProtection.pivotTables True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.scenarios True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectLockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.selectUnlockedCells True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sheet True means that that user will be unable to modify this setting\r\n * @param {Boolean} opts.sheetProtection.sort True means that that user will be unable to modify this setting\r\n * @param {Object} opts.outline \r\n * @param {Boolean} opts.outline.summaryBelow Flag indicating whether summary rows appear below detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.outline.summaryRight Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline/grouping.\r\n * @param {Boolean} opts.disableRowSpansOptimization Flag indicated whether to not include a spans attribute to the row definition in the XML. helps with very large documents.\r\n * @param {Boolean} opts.hidden Flag indicating whether to not hide the worksheet within the workbook.\r\n * @returns {Worksheet}\r\n */\r\n constructor(wb, name, opts = {}) {\r\n\r\n this.wb = wb;\r\n this.sheetId = this.wb.sheets.length + 1;\r\n this.localSheetId = this.wb.sheets.length;\r\n this.opts = deepmerge(wsDefaultParams, opts);\r\n optsValidator(opts);\r\n \r\n this.name = name ? name : `Sheet ${this.sheetId}`;\r\n this.hasGroupings = false;\r\n this.cols = {}; // Columns keyed by column, contains column properties\r\n this.rows = {}; // Rows keyed by row, contains row properties and array of cellRefs\r\n this.cells = {}; // Cells keyed by Excel ref\r\n this.mergedCells = [];\r\n this.pageBreaks = {\r\n row: [],\r\n column: [],\r\n };\r\n this.printArea = null;\r\n this.lastUsedRow = 1;\r\n this.lastUsedCol = 1;\r\n\r\n // conditional formatting rules hashed by sqref\r\n this.cfRulesCollection = new CfRulesCollection();\r\n this.hyperlinkCollection = new HyperlinkCollection();\r\n this.dataValidationCollection = new DataValidation.DataValidationCollection();\r\n this.drawingCollection = new wsDrawing.DrawingCollection();\r\n this.legacyDrawingHeaderFooter = new wsDrawing.DrawingCollection();\r\n this.comments = {}; // Comments for cells keyed by excel ref\r\n this.author = this.wb.author;\r\n\r\n }\r\n\r\n get relationships() {\r\n let rels = [];\r\n if(!this.legacyDrawingHeaderFooter.isEmpty){\r\n rels.push('legacyDrawingHeaderFooter')\r\n }\r\n this.hyperlinkCollection.links.forEach((l) => {\r\n rels.push(l);\r\n });\r\n if (!this.drawingCollection.isEmpty) {\r\n rels.push('drawing');\r\n }\r\n if(Object.keys(this.comments).length > 0) {\r\n rels.push('comments');\r\n rels.push('commentsVml');\r\n }\r\n return rels;\r\n }\r\n\r\n get columnCount() {\r\n return Math.max.apply(Math, Object.keys(this.cols));\r\n }\r\n\r\n get rowCount() {\r\n return Math.max.apply(Math, Object.keys(this.rows));\r\n }\r\n\r\n /**\r\n * @func Worksheet.addConditionalFormattingRule\r\n * @param {String} sqref Text represetation of Cell range where the conditional formatting will take effect\r\n * @param {Object} options Options for conditional formatting\r\n * @param {String} options.type Type of conditional formatting\r\n * @param {String} options.priority Priority level for this rule\r\n * @param {String} options.formula Formula that returns nonzero or 0 value. If not 0 then rule will be applied\r\n * @param {Style} options.style Style that should be applied if rule passes\r\n * @returns {Worksheet}\r\n */\r\n addConditionalFormattingRule(sqref, options) {\r\n let style = options.style || this.wb.Style();\r\n let dxf = this.wb.dxfCollection.add(style);\r\n delete options.style;\r\n options.dxfId = dxf.id;\r\n this.cfRulesCollection.add(sqref, options);\r\n return this;\r\n }\r\n /**\r\n * @func Worksheet.addDataValidation\r\n * @desc Add a data validation rule to the Worksheet\r\n * @param {Object} opts Options for Data Validation rule\r\n * @param {String} opts.sqref Required. Specifies range of cells to apply validate. i.e. \"A1:A100\"\r\n * @param {Boolean} opts.allowBlank Allows cells to be empty\r\n * @param {String} opts.errorStyle One of 'stop', 'warning', 'information'. You must specify an error string for this to take effect\r\n * @param {String} opts.error Message to show on error\r\n * @param {String} opts.errorTitle: String Title of message shown on error\r\n * @param {Boolean} opts.showErrorMessage Defaults to true if error or errorTitle is set\r\n * @param {String} opts.imeMode Restricts input to a specific set of characters. One of 'noControl', 'off', 'on', 'disabled', 'hiragana', 'fullKatakana', 'halfKatakana', 'fullAlpha', 'halfAlpha', 'fullHangul', 'halfHangul'\r\n * @param {String} opts.operator Must be one of 'between', 'notBetween', 'equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual'\r\n * @param {String} opts.prompt Message text of input prompt\r\n * @param {String} opts.promptTitle Title of input prompt\r\n * @param {Boolean} opts.showInputMessage Defaults to true if prompt or promptTitle is set\r\n * @param {Boolean} opts.showDropDown A boolean value indicating whether to display a dropdown combo box for a list type data validation.\r\n * @param {String} opts.type One of 'none', 'whole', 'decimal', 'list', 'date', 'time', 'textLength', 'custom'\r\n * @param {Array.String} opts.formulas Minimum count 1, maximum count 2. Rules for validation\r\n */\r\n addDataValidation(opts) {\r\n let newValidation = this.dataValidationCollection.add(opts);\r\n return newValidation;\r\n }\r\n /**\r\n * @func Worksheet.generateRelsXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet .rels file\r\n */\r\n generateRelsXML() {\r\n return xmlBuilder.relsXML(this);\r\n }\r\n\r\n generateCommentsXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsXML(this);\r\n }\r\n\r\n generateCommentsVmlXML() {\r\n if(Object.keys(this.comments).length === 0) {\r\n return;\r\n }\r\n return xmlBuilder.commentsVmlXML(this);\r\n }\r\n\r\n /**\r\n * @func Worksheet.generateXML\r\n * @desc When Workbook is being built, generate the XML that will go into the Worksheet xml file \r\n */\r\n generateXML() {\r\n return xmlBuilder.sheetXML(this);\r\n }\r\n\r\n get cell() {\r\n return cellAccessor.bind(this);\r\n }\r\n\r\n row(row) {\r\n return rowAccessor(this, row);\r\n }\r\n\r\n column(col) {\r\n return colAccessor(this, col);\r\n }\r\n /**\r\n * @func Worksheet.addImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {Object} opts.position Position object for image\r\n * @param {String} opts.position.type Type of positional anchor to use. One of 'absoluteAnchor', 'oneCellAnchor', 'twoCellAnchor'\r\n * @param {Object} opts.position.from Object containg position of top left corner of image. Used with oneCellAnchor and twoCellAchor types\r\n * @param {Number} opts.position.from.col Left edge of image will align with left edge of this column\r\n * @param {String} opts.position.from.colOff Offset from left edge of column\r\n * @param {Number} opts.position.from.row Top edge of image will align with top edge of this row\r\n * @param {String} opts.position.from.rowOff Offset from top edge of row\r\n * @param {Object} opts.position.to Object containing position of bottom right corner of image\r\n * @param {Number} opts.position.to.col Right edge of image will align with Left edge of this column\r\n * @param {String} opts.position.to.colOff Offset of left edge of column\r\n * @param {Number} opts.position.to.row Bottom edge of image will align with Top edge of this row\r\n * @param {String} opts.position.to.rowOff Offset of top edge of row\r\n * @param {String} opts.position.x X position of top left corner of image. Used with absoluteAchor type\r\n * @param {String} opts.position.y Y position of top left corner of image\r\n */\r\n addImage(opts) {\r\n opts = opts ? opts : {};\r\n let mediaID = this.wb.mediaCollection.add(opts.path || opts.image);\r\n let newImage = this.drawingCollection.add(opts);\r\n newImage.id = mediaID;\r\n\r\n return newImage;\r\n }\r\n\r\n addChart(opts){\r\n let mediaID = this.wb.chartsCollection.add(opts);\r\n let newImage = this.drawingCollection.add(opts);\r\n newImage.id = mediaID;\r\n return newImage;\r\n }\r\n\r\n /**\r\n * @func Worksheet.addPageBreak\r\n * @param {string} type \r\n * @param {number} position \r\n * @returns {Worksheet}\r\n */\r\n addPageBreak(type, position) {\r\n if ((type !== 'row' && type !== 'column') || typeof position !== 'number') {\r\n this.wb.logger.warn('invalid option sent to addPageBreak method', type, position);\r\n return;\r\n }\r\n if (this.pageBreaks[type].indexOf(position) < 0) {\r\n this.pageBreaks[type].push(position);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @method Worksheet.addPrintArea\r\n * @param {number} startRow \r\n * @param {number} startCol \r\n * @param {number} endRow \r\n * @param {number} endCol \r\n * @returns {Worksheet}\r\n */\r\n setPrintArea(startRow, startCol, endRow, endCol) {\r\n if (\r\n typeof startRow !== 'number' ||\r\n typeof startCol !== 'number' ||\r\n typeof endRow !== 'number' ||\r\n typeof endCol !== 'number'\r\n ) {\r\n this.wb.logger.warn('invalid option sent to setPrintArea method');\r\n return;\r\n }\r\n this.printArea = {\r\n startRow,\r\n startCol,\r\n endRow,\r\n endCol,\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * @func Worksheet.setHeaderFooterImage\r\n * @param {Object} opts\r\n * @param {String} opts.path File system path of image\r\n * @param {Buffer} opts.image Buffer with image (against read file from opts.path)\r\n * @param {String} opts.name Name of image\r\n * @param {String} opts.type Type of image. Currently only 'picture' is supported\r\n * @param {String} opts.position Position string for image: ['LF','CF', 'RF', 'LH', 'CH', 'RH'] \r\n */\r\n addHeaderFooterImage(image, position){\r\n const headerFooterPositions = ['LF','CF', 'RF', 'LH', 'CH', 'RH'];\r\n if(headerFooterPositions.indexOf(position) < 0){\r\n throw new Error('setHeaderFooterImage: Only allowed positions are LH, CH, RH, LF, CF, RF');\r\n }\r\n if(image.type === 'picture') image.type = 'headerFooterPicture';\r\n var mediaId = this.wb.mediaCollection.add(image);\r\n var ximg = this.legacyDrawingHeaderFooter.add(image)\r\n ximg.position = position;\r\n ximg.id = mediaId;\r\n }\r\n}\r\n\r\nmodule.exports = Worksheet;"]} \ No newline at end of file diff --git a/sample3.js b/sample3.js index afaad6c3..ec36d705 100644 --- a/sample3.js +++ b/sample3.js @@ -85,9 +85,9 @@ var wb = new xl.Workbook({ var wx = wb.addWorksheet("Sheet2", { pageSetup: { - fitToWidth: 1, paperSize: 'A4_PAPER', - orientation: 'portrait' + orientation: 'portrait', + scale: 100, }, sheetView: { 'rightToLeft': true @@ -127,6 +127,14 @@ var sumStyle = { border: borderx }; +var signStyle = { + font: { bold: true, size: 14 }, + alignment: { + horizontal: 'center', + vertical: 'center' + }, +}; + var titleStyle = { font: { bold: true, size: 18 }, alignment: { @@ -171,9 +179,14 @@ var currentRow = 14; var tabNum = 0; let vTitle = ''; +if (!aca_data.HonorsOrGraduates) { + wx.row(currentRow - 1).height = 2; +} + var regStud = aca_data.dataTables.RegStudents; wx.cell(currentRow, 2).string('اولاً: الطلاب النظاميون:').style({ font: { bold: true, size: 16 } }) GenerateACADataTable(wx, currentRow + 1, aca_data, regStud) +genRegStudentsFormulae(wx, currentRow + 3) currentRow += Object.keys(regStud).length + 6; wx.cell(currentRow - 2, 2).string('المجموع').style(sumStyle) wx.cell(currentRow - 2, 3).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 3)}:${xl.getExcelCellRef(currentRow - 3, 3)})`).style(sumStyle) @@ -184,11 +197,16 @@ wx.cell(currentRow - 2, 7).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 7) wx.cell(currentRow - 2, 8).formula(`SUM(${xl.getExcelCellRef(currentRow - 11, 8)}:${xl.getExcelCellRef(currentRow - 3, 8)})`).style(sumStyle) tabNum += 1; +if (!aca_data.HonorsOrGraduates) { + wx.row(currentRow - 1).height = 2; +} + if (aca_data.HonorsOrGraduates) { vTitle = BigLabels[tabNum] + ': ' + 'الحاصلون على مرتبة الشرف (نظاميون)'; var regStudHonours = aca_data.dataTables.RegStudentsHonours; wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) GenerateACADataTable(wx, currentRow + 1, aca_data, regStudHonours) + genHonStudentsFormulae(wx, currentRow + 3) currentRow += Object.keys(regStudHonours).length + 6; var crw = currentRow - 2; wx.cell(crw, 2).string('المجموع').style(sumStyle) @@ -199,12 +217,16 @@ if (aca_data.HonorsOrGraduates) { wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 4, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 4, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) tabNum += 1; + generateSignatures(); + currentRow += 2; + wx.addPageBreak('row', 43) } vTitle = BigLabels[tabNum] + ': ' + 'الممتحنون من الخارج'; var extStud = aca_data.dataTables.ExtStudents; wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) GenerateACADataTable(wx, currentRow + 1, aca_data, extStud) +genExtStudentsFormulae(wx, currentRow + 3) currentRow += Object.keys(extStud).length + 6; var crw = currentRow - 2; wx.cell(crw, 2).string('المجموع').style(sumStyle) @@ -214,14 +236,23 @@ wx.cell(crw, 5).formula(`SUM(${xl.getExcelCellRef(crw - 7, 5)}:${xl.getExcelCell wx.cell(crw, 6).formula(`SUM(${xl.getExcelCellRef(crw - 7, 6)}:${xl.getExcelCellRef(crw - 1, 6)})`).style(sumStyle) wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 7, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 7, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) - tabNum += 1; +if (!aca_data.HonorsOrGraduates) { + generateSignatures() + currentRow += 4 + // wx.addPageBreak('row', currentRow - 2) +} + + if (aca_data.HonorsOrGraduates) { + console.log("Collapse Row", currentRow - 1) + wx.row(currentRow - 1).height = 2.25; vTitle = BigLabels[tabNum] + ': ' + 'الحاصلون على مرتبة الشرف (خارجيون) '; var extStudHonours = aca_data.dataTables.ExtStudentsHonours; wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) GenerateACADataTable(wx, currentRow + 1, aca_data, extStudHonours) + genHonStudentsFormulae(wx, currentRow + 3) currentRow += Object.keys(extStudHonours).length + 6; var crw = currentRow - 2; wx.cell(crw, 2).string('المجموع').style(sumStyle) @@ -231,6 +262,96 @@ if (aca_data.HonorsOrGraduates) { wx.cell(crw, 6).formula(`SUM(${xl.getExcelCellRef(crw - 4, 6)}:${xl.getExcelCellRef(crw - 1, 6)})`).style(sumStyle) wx.cell(crw, 7).formula(`SUM(${xl.getExcelCellRef(crw - 4, 7)}:${xl.getExcelCellRef(crw - 1, 7)})`).style(sumStyle) wx.cell(crw, 8).formula(`SUM(${xl.getExcelCellRef(crw - 4, 8)}:${xl.getExcelCellRef(crw - 1, 8)})`).style(sumStyle) + tabNum += 1; +} + +function generateSignatures() { + wx.cell(crw + 2, 2).string(aca_data.RegistrarName).style(signStyle); + wx.cell(crw + 2, 3, crw + 2, 5, true).string(aca_data.DeputyDeanName).style(signStyle); + wx.cell(crw + 2, 6, crw + 2, 8, true).string(aca_data.DeanName).style(signStyle); + wx.cell(crw + 3, 2).string('المسجل').style(signStyle); + wx.cell(crw + 3, 3, crw + 3, 5, true).string('رئيس لجنة الامتحانات').style(signStyle); + wx.cell(crw + 3, 6, crw + 3, 8, true).string('العميد').style(signStyle); +} + +function genRegStudentsFormulae(ws, srow) { + var xsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'thin', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + bottom: { style: 'thin', color: 'black' } + } + }; + colsx = [4, 6, 8]; + for (cx of colsx) { + var rtot = xl.getExcelCellRef(srow + 1, cx - 1); + var rexam = xl.getExcelCellRef(srow + 2, cx - 1); + + for (let n = 1; n <= 11; n++) { + var r1 = xl.getExcelCellRef(srow + n, cx - 1); + if (n == 2 || n == 9) { + ws.cell(srow + n, cx).formula(`IF(${rtot}=0, 0, ROUND((${r1}/${rtot})*100,2))`).style(xsty) + } else if (n == 1) { + ws.cell(srow + n, cx).style(xsty) + } else { + ws.cell(srow + n, cx).formula(`IF(${rexam}=0, 0, ROUND((${r1}/${rexam})*100,2))`).style(xsty) + } + } + } +} + +function genExtStudentsFormulae(ws, srow) { + var xsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'thin', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + bottom: { style: 'thin', color: 'black' } + } + }; + colsx = [4, 6, 8]; + for (cx of colsx) { + var rtot = xl.getExcelCellRef(srow + 1, cx - 1); + var rexam = xl.getExcelCellRef(srow + 2, cx - 1); + + for (let n = 1; n <= 9; n++) { + var r1 = xl.getExcelCellRef(srow + n, cx - 1); + if (n == 2) { + ws.cell(srow + n, cx).formula(`IF(${rtot}=0, 0, ROUND((${r1}/${rtot})*100,2))`).style(xsty) + } else if (n == 1) { + ws.cell(srow + n, cx).style(xsty) + } else { + ws.cell(srow + n, cx).formula(`IF(${rexam}=0, 0, ROUND((${r1}/${rexam})*100,2))`).style(xsty) + } + } + } +} + +function genHonStudentsFormulae(ws, srow) { + var xsty = { + font: { bold: true }, alignment: { horizontal: 'center', vertical: 'center' }, + border: { + left: { style: 'thin', color: 'black' }, + right: { style: 'medium', color: 'black' }, + top: { style: 'thin', color: 'black' }, + bottom: { style: 'thin', color: 'black' } + } + }; + colsx = [4, 6, 8]; + for (cx of colsx) { + var rtot = xl.getExcelCellRef(srow + 1, cx - 1); + for (let n = 1; n <= 5; n++) { + var r1 = xl.getExcelCellRef(srow + n, cx - 1); + if (n == 1) { + ws.cell(srow + n, cx).style(xsty) + } else { + ws.cell(srow + n, cx).formula(`IF(${rtot}=0, 0, ROUND((${r1}/${rtot})*100,2))`).style(xsty) + } + } + } } function GenerateACADataTable(ws, srow, acd, dtab, tabNum) { @@ -328,11 +449,21 @@ function GenerateACADataTable(ws, srow, acd, dtab, tabNum) { ws.cell(srow + n, 3).number(val[0]).style(xsty) ws.cell(srow + n, 5).number(val[1]).style(xsty) ws.cell(srow + n, 7).number(val[2]).style(xsty) - ws.row(srow + n).height = 17.25; + ws.row(srow + n).height = 16.5; n++; } } +if(!aca_data.HonorsOrGraduates){ + wx.row(currentRow - 1).height = 2; +} +if(aca_data.HonorsOrGraduates){ + console.log("Collapse Row", currentRow-1) + wx.row(currentRow-1).height = 2; +} +vTitle = BigLabels[tabNum] + ': ' + 'الرسوم البيانية'; +wx.cell(currentRow, 2).string(vTitle).style({ font: { bold: true, size: 16 } }) +currentRow += 1 wx.addChart({ type: 'chart', chartType: 'bar', @@ -344,56 +475,100 @@ wx.addChart({ pattern: 'solidDmnd', catRange: "'Sheet2'!$B$18:$B$28" }, { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$18:$F$28", catRange: "'Sheet2'!$B$18:$B$28" }, - { label: 'العام الحالي', pattern: 'wdDnDiag', range: "'Sheet2'!$H$18:$H$28", catRange: "'Sheet2'!$B$18:$B$28" }, + { label: 'العام الأسبق', pattern: 'wdDnDiag', range: "'Sheet2'!$H$18:$H$28", catRange: "'Sheet2'!$B$18:$B$28" }, ], - dataLegend: [ - - ], - catAxisLabels: { - range: "'Sheet2'!$B$18:$B$28" + xlabel: { fontSize: 14, bold: 1, value: 'الوصف' }, + ylabel: { fontSize: 14, bold: 1, value: 'النسبة المئوية' } + }, + position: { + type: 'twoCellAnchor', + from: { + col: 2, row: currentRow, colOff: 0, rowOff: 0 + }, + to: { + col: 8+1, row: currentRow + 12+2, colOff: -96000, rowOff: -96000 } + } +}) +currentRow += 15; +if (aca_data.HonorsOrGraduates) { + var crw = currentRow; + generateSignatures(); + currentRow += 2; + wx.addPageBreak('row', currentRow) + currentRow += 1; + wx.addChart({ + type: 'chart', + chartType: 'bar', + chartData: { + title: 'الحاصلون على مرتبة الشرف (نظاميون)', + dataSeries: [ + { + label: 'العام الحالي', range: "'Sheet2'!$D$35:$D$39", + pattern: 'solidDmnd', catRange: "'Sheet2'!$B$35:$B$39" + }, + { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$35:$F$39", catRange: "'Sheet2'!$B$35:$B$39" }, + { label: 'العام الأسبق', pattern: 'wdDnDiag', range: "'Sheet2'!$H$35:$H$39", catRange: "'Sheet2'!$B$35:$B$39" }, + ], + xlabel: { fontSize: 14, bold: 1, value: 'الوصف' }, + ylabel: { fontSize: 14, bold: 1, value: 'النسبة المئوية' } + }, + position: { + type: 'twoCellAnchor', + from: { + col: 2, row: currentRow, colOff: 0, rowOff: 0 + }, + to: { + col: 8 + 1, row: currentRow + 12 + 1, colOff: -96000, rowOff: -96000 + } + } + }) +} +wx.addChart({ + type: 'chart', + chartType: 'bar', + chartData: { + title: 'الممتحنون من الخارج', + dataSeries: [ + { + label: 'العام الحالي', + range: aca_data.HonorsOrGraduates ? "'Sheet2'!$D$48:$D$56" : "'Sheet2'!$D$35:$D$43", + pattern: 'solidDmnd', + catRange: aca_data.HonorsOrGraduates ? "'Sheet2'!$B$48:$B$56" : "'Sheet2'!$B$35:$B$43" + }, + { + label: 'العام السابق', + pattern: 'smGrid', + range: aca_data.HonorsOrGraduates ? "'Sheet2'!$F$48:$F$56" : "'Sheet2'!$F$35:$F$43", + catRange: aca_data.HonorsOrGraduates ? "'Sheet2'!$B$48:$B$56" : "'Sheet2'!$B$35:$B$43" + }, + { + label: 'العام الأسبق', + pattern: 'wdDnDiag', + range: aca_data.HonorsOrGraduates ? "'Sheet2'!$H$48:$H$56" : "'Sheet2'!$H$35:$H$43", + catRange: aca_data.HonorsOrGraduates ? "'Sheet2'!$B$48:$B$56" : "'Sheet2'!$B$35:$B$43" + }, + ], + xlabel: { fontSize: 14, bold: 1, value: 'الوصف' }, + ylabel: { fontSize: 14, bold: 1, value: 'النسبة المئوية' } }, position: { type: 'twoCellAnchor', from: { - col: 2, row: 69, colOff: 19050, rowOff: 76200 + col: 2, row: currentRow, colOff: 0, rowOff: 0 }, to: { - col: 8, row: 85, colOff: 600075, rowOff: 190500 + col: 8 + 1, row: currentRow + 13 + 1, colOff: -96000, rowOff: -96000 } } }) +currentRow += 15; +if (!aca_data.HonorsOrGraduates) { + var crw = currentRow - 2; + generateSignatures() + currentRow += 4 +} -// wx.addChart({ -// type: 'chart', -// chartType: 'bar', -// chartData: { -// title: 'الطلاب النظاميون', -// dataSeries: [ -// { -// label: 'العام الحالي', range: "'Sheet2'!$D$18:$D$28", -// pattern: 'solidDmnd', catRange: "'Sheet2'!$B$18:$B$28" -// }, -// { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$18:$F$28", catRange: "'Sheet2'!$B$18:$B$28" }, -// { label: 'العام الحالي', pattern: 'wdDnDiag', range: "'Sheet2'!$H$18:$H$28", catRange: "'Sheet2'!$B$18:$B$28" }, -// ], -// dataLegend: [ - -// ], -// catAxisLabels: { -// range: "'Sheet2'!$B$18:$B$28" -// } -// }, -// position: { -// type: 'twoCellAnchor', -// from: { -// col: 10, row: 1, colOff: 19050, rowOff: 76200 -// }, -// to: { -// col: 16, row: 17, colOff: 600075, rowOff: 190500 -// } -// } -// }) wb.write('Excel.xlsx') var dir = require('path').join(__dirname, '/testzip') diff --git a/source/lib/drawing/chart.js b/source/lib/drawing/chart.js index 47247fc1..6d3c7af2 100644 --- a/source/lib/drawing/chart.js +++ b/source/lib/drawing/chart.js @@ -137,7 +137,6 @@ class Chart extends Drawing { } chartPartXML(xmlcx) { - console.log('chartPartXML') xmlcx.ele('c:date1904').att('val', 0); xmlcx.ele('c:lang').att('val', 'en-US'); xmlcx.ele('c:roundedCorners').att('val', 0); @@ -165,10 +164,10 @@ class Chart extends Drawing { ml.ele('c:layoutTarget').att('val', 'inner') ml.ele('c:xMode').att('val', 'edge') ml.ele('c:yMode').att('val', 'edge') - ml.ele('c:x').att('val', 0.1165589095638537) - ml.ele('c:y').att('val', 0.11177904648711365) - ml.ele('c:w').att('val', 0.7404672613266795) - ml.ele('c:h').att('val', 0.66684834207044885) + ml.ele('c:x').att('val', 0.1) + ml.ele('c:y').att('val', 0.1) + ml.ele('c:w').att('val', 0.75) + ml.ele('c:h').att('val', 0.6) let barChart = plotArea.ele("c:barChart") let catAx = plotArea.ele("c:catAx") @@ -193,20 +192,20 @@ class Chart extends Drawing { if (sx.range) { ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range) } - // if (sx.catRange){ - // ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange); - // } + if (sx.catRange) { + ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange); + } // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart') // .att('uri', this.axExtId1) // .ele('c16:uniqueId').att('val', this.axExtId2) } let dLbl = barChart.ele('c:dLbls'); - dLbl.ele('c:showLegendKey').att('val',0) - dLbl.ele('c:showVal').att('val',0) - dLbl.ele('c:showCatName').att('val',0) - dLbl.ele('c:showSerName').att('val',0) - dLbl.ele('c:showPercent').att('val',0) - dLbl.ele('c:showBubbleSize').att('val',0) + dLbl.ele('c:showLegendKey').att('val', 0) + dLbl.ele('c:showVal').att('val', 0) + dLbl.ele('c:showCatName').att('val', 0) + dLbl.ele('c:showSerName').att('val', 0) + dLbl.ele('c:showPercent').att('val', 0) + dLbl.ele('c:showBubbleSize').att('val', 0) barChart.ele('c:gapWidth').att('val', 150) barChart.ele('c:axId').att('val', 361690304) @@ -219,13 +218,14 @@ class Chart extends Drawing { catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0) catAx.ele('c:majorTickMark').att('val', 'out') catAx.ele('c:minorTickMark').att('val', 'none') - catAx.ele('c:tickLblPos').att('val', 'nextTo') - catAx.ele('c:crossAx').att('val', 1) - catAx.ele('c:crosses').att('val', "autoZero") - catAx.ele('c:auto').att('val', 1) - catAx.ele('c:lblAlgn').att('val', "ctr") - catAx.ele('c:lblOffset').att('val', 100) - catAx.ele('c:noMultiLvlLbl').att('val', 0) + catAx.ele('c:tickLblPos').att('val', 'nextTo') + catAx.ele('c:crossAx').att('val', 1) + catAx.ele('c:crosses').att('val', "autoZero") + catAx.ele('c:auto').att('val', 1) + catAx.ele('c:lblAlgn').att('val', "ctr") + catAx.ele('c:lblOffset').att('val', 100) + catAx.ele('c:noMultiLvlLbl').att('val', 0) + genTitleXML(catAx, this.chartData.xlabel) valAx.ele('c:axId').att('val', 1) valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax') @@ -234,10 +234,32 @@ class Chart extends Drawing { valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1) valAx.ele('c:majorTickMark').att('val', 'out') valAx.ele('c:minorTickMark').att('val', 'none') - valAx.ele('c:tickLblPos').att('val', 'nextTo') - valAx.ele('c:crossAx').att('val', 361690304) - valAx.ele('c:crosses').att('val', "autoZero") - valAx.ele('c:crossBetween').att('val', "between") + valAx.ele('c:tickLblPos').att('val', 'nextTo') + valAx.ele('c:crossAx').att('val', 361690304) + valAx.ele('c:crosses').att('val', "autoZero") + valAx.ele('c:crossBetween').att('val', "between") + genTitleXML(valAx, this.chartData.ylabel) + + function genTitleXML(xmlc, txtRun) { + let xz_xlabc = xmlc.ele('c:title') + let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich') + xz_xlab.ele('a:bodyPr') + xz_xlab.ele('a:lstStyle') + let xz_xlabp = xz_xlab.ele('a:p'); + xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100) + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + let xz_xlabpr = xz_xlabp.ele('a:r') + let title_txt = xz_xlabpr.ele("a:rPr").att("sz", txtRun.fontSize * 100).att('lang', 'ar-SA') + title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + if (txtRun.bold) title_txt.att('b', txtRun.bold); + if (txtRun.italic) title_txt.att('i', txtRun.italic); + title_txt.att('baseline', 0) + + xz_xlabpr.ele('a:t', txtRun.value) + xz_xlabp.ele("a:endParaRPr").att("sz", txtRun.fontSize * 100).att('lang', 'en-US') + .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + xz_xlab.ele("c:overlay").att("val", 1) + } let legend = xchart.ele("c:legend"); diff --git a/source/lib/workbook/builder.js b/source/lib/workbook/builder.js index 88eb369b..4fe1dc16 100644 --- a/source/lib/workbook/builder.js +++ b/source/lib/workbook/builder.js @@ -75,7 +75,6 @@ let addRootContentTypesXML = (promiseObj) => { xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml').att('PartName', '/xl/sharedStrings.xml'); xml.ele('Override').att('ContentType', 'application/vnd.openxmlformats-package.core-properties+xml').att('PartName', '/docProps/core.xml'); promiseObj.wb.chartsCollection.items.forEach((s, i) => { - console.log('Charts to Content Types') xml.ele('Override') .att('PartName', `/xl/charts/chart${i + 1}.xml`) .att('ContentType', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml') From 1ed9903e429b9194982f89644261752a1ee506b8 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Tue, 12 Jan 2021 13:47:13 +0300 Subject: [PATCH 10/12] Somehow missed the new charts files in the previous commits --- distribution/lib/drawing/chart.js | 307 ++++++++++++++++++ distribution/lib/drawing/chart.js.map | 1 + distribution/lib/workbook/chartsCollection.js | 35 ++ .../lib/workbook/chartsCollection.js.map | 1 + 4 files changed, 344 insertions(+) create mode 100644 distribution/lib/drawing/chart.js create mode 100644 distribution/lib/drawing/chart.js.map create mode 100644 distribution/lib/workbook/chartsCollection.js create mode 100644 distribution/lib/workbook/chartsCollection.js.map diff --git a/distribution/lib/drawing/chart.js b/distribution/lib/drawing/chart.js new file mode 100644 index 00000000..b9a1be48 --- /dev/null +++ b/distribution/lib/drawing/chart.js @@ -0,0 +1,307 @@ +'use strict'; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Drawing = require('./drawing.js'); +var xmlbuilder = require('xmlbuilder'); +var EMU = require('../classes/emu.js'); + +var _require = require('uuid'), + uuidv4 = _require.v4; + +var Chart = function (_Drawing) { + _inherits(Chart, _Drawing); + + /** + * Element representing an Excel Picture subclass of Drawing + * @property {String} kind Kind of picture + */ + function Chart(opts) { + _classCallCheck(this, Chart); + + var _this = _possibleConstructorReturn(this, (Chart.__proto__ || Object.getPrototypeOf(Chart)).call(this)); + + _this.kind = 'chart'; + _this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart'; + _this._title; + _this.chartData = opts.chartData; + + if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) { + _this.anchor(opts.position.type, opts.position.from, opts.position.to); + } else if (opts.position.type === 'absoluteAnchor') { + _this.position(opts.position.x, opts.position.y); + } else { + throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor'); + } + return _this; + } + + _createClass(Chart, [{ + key: 'addToXMLele', + + + /** + * @alias Picture.addToXMLele + * @desc When generating Workbook output, attaches pictures to the drawings xml file + * @func Picture.addToXMLele + * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module + */ + value: function addToXMLele(ele) { + + var anchorEle = ele.ele('xdr:' + this.anchorType); + + // if (this.editAs !== null) { + // anchorEle.att('editAs', this.editAs); + // } + + if (this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y); + } + + if (this.anchorType !== 'absoluteAnchor') { + var af = this.anchorFrom; + var afEle = anchorEle.ele('xdr:from'); + afEle.ele('xdr:col').text(af.col); + afEle.ele('xdr:colOff').text(af.colOff); + afEle.ele('xdr:row').text(af.row); + afEle.ele('xdr:rowOff').text(af.rowOff); + } + + if (this.anchorTo && this.anchorType === 'twoCellAnchor') { + var at = this.anchorTo; + var atEle = anchorEle.ele('xdr:to'); + atEle.ele('xdr:col').text(at.col); + atEle.ele('xdr:colOff').text(at.colOff); + atEle.ele('xdr:row').text(at.row); + atEle.ele('xdr:rowOff').text(at.rowOff); + } + + if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') { + anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height); + } + + var graphicFrame = anchorEle.ele('xdr:graphicFrame'); + graphicFrame.att("macro", ""); + var nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr'); + var cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att("id", this.id).att("name", "Chart " + this.id); + // this.axExtId1 = uuidv4() + // this.axExtId2 = uuidv4(); + + // let extLst = cNvPrEle.ele("a:extLst") + // let aext = extLst.ele("a:ext").att("uri", this.axExtId1) + // let a16creat = aext.ele("a16:creationId").att("xmlns:a16", "http://schemas.microsoft.com/office/drawing/2014/main") + // a16creat.att("id", this.axExtId2) + nvGraphicFramePr.ele("xdr:cNvGraphicFramePr").ele("a:graphicFrameLocks"); + + var xfrm = graphicFrame.ele("xdr:xfrm"); + xfrm.ele("a:off").att("x", 0).att("y", 0); + xfrm.ele("a:ext").att("cx", 0).att("cy", 0); + + var graphicData = graphicFrame.ele("a:graphic").ele("a:graphicData").att("uri", "http://schemas.openxmlformats.org/drawingml/2006/chart"); + graphicData.ele("c:chart").att("xmlns:c", "http://schemas.openxmlformats.org/drawingml/2006/chart").att("xmlns:r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships").att("r:id", this.rId); + + anchorEle.ele('xdr:clientData'); + } + }, { + key: 'chartPartXML', + value: function chartPartXML(xmlcx) { + xmlcx.ele('c:date1904').att('val', 0); + xmlcx.ele('c:lang').att('val', 'en-US'); + xmlcx.ele('c:roundedCorners').att('val', 0); + var xchart = xmlcx.ele('c:chart'); + var title = xchart.ele('c:title'); + var title_rich = title.ele('c:tx').ele('c:rich'); + title_rich.ele('a:bodyPr'); + title_rich.ele('a:lstStyle'); + var titlep = title_rich.ele('a:p'); + titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400).ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + var titlepr = titlep.ele('a:r'); + titlepr.ele("a:rPr").att("sz", 1400).att('lang', 'ar-SA').ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + titlepr.ele('a:t', this.chartData.title); + titlep.ele("a:endParaRPr").att("sz", 1400).att('lang', 'en-US').ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + title.ele("c:overlay").att("val", 1); + + xchart.ele("c:autoTitleDeleted").att("val", 0); + + var plotArea = xchart.ele("c:plotArea"); + var layout = plotArea.ele("c:layout"); + var ml = layout.ele('c:manualLayout'); + ml.ele('c:layoutTarget').att('val', 'inner'); + ml.ele('c:xMode').att('val', 'edge'); + ml.ele('c:yMode').att('val', 'edge'); + ml.ele('c:x').att('val', 0.1); + ml.ele('c:y').att('val', 0.1); + ml.ele('c:w').att('val', 0.75); + ml.ele('c:h').att('val', 0.6); + + var barChart = plotArea.ele("c:barChart"); + var catAx = plotArea.ele("c:catAx"); + var valAx = plotArea.ele("c:valAx"); + + barChart.ele("c:barDir").att("val", "col"); + barChart.ele("c:grouping").att("val", "clustered"); + barChart.ele("c:varyColors").att("val", 0); + for (var sno in this.chartData.dataSeries) { + var sx = this.chartData.dataSeries[sno]; + // console.log(sno, sx) + var ser = barChart.ele("c:ser"); + ser.ele("c:idx").att("val", sno); + ser.ele("c:order").att("val", sno); + ser.ele('c:tx').ele('c:v', sx.label); + var ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern); + + ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1'); + ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1'); + ser.ele('c:invertIfNegative').att('val', 0); + + if (sx.range) { + ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range); + } + if (sx.catRange) { + ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange); + } + // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart') + // .att('uri', this.axExtId1) + // .ele('c16:uniqueId').att('val', this.axExtId2) + } + var dLbl = barChart.ele('c:dLbls'); + dLbl.ele('c:showLegendKey').att('val', 0); + dLbl.ele('c:showVal').att('val', 0); + dLbl.ele('c:showCatName').att('val', 0); + dLbl.ele('c:showSerName').att('val', 0); + dLbl.ele('c:showPercent').att('val', 0); + dLbl.ele('c:showBubbleSize').att('val', 0); + + barChart.ele('c:gapWidth').att('val', 150); + barChart.ele('c:axId').att('val', 361690304); + barChart.ele('c:axId').att('val', 1); + + catAx.ele('c:axId').att('val', 361690304); + catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax'); + catAx.ele('c:delete').att('val', 0); + catAx.ele('c:axPos').att('val', 'b'); + catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0); + catAx.ele('c:majorTickMark').att('val', 'out'); + catAx.ele('c:minorTickMark').att('val', 'none'); + catAx.ele('c:tickLblPos').att('val', 'nextTo'); + catAx.ele('c:crossAx').att('val', 1); + catAx.ele('c:crosses').att('val', "autoZero"); + catAx.ele('c:auto').att('val', 1); + catAx.ele('c:lblAlgn').att('val', "ctr"); + catAx.ele('c:lblOffset').att('val', 100); + catAx.ele('c:noMultiLvlLbl').att('val', 0); + genTitleXML(catAx, this.chartData.xlabel); + + valAx.ele('c:axId').att('val', 1); + valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax'); + valAx.ele('c:delete').att('val', 0); + valAx.ele('c:axPos').att('val', 'l'); + valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1); + valAx.ele('c:majorTickMark').att('val', 'out'); + valAx.ele('c:minorTickMark').att('val', 'none'); + valAx.ele('c:tickLblPos').att('val', 'nextTo'); + valAx.ele('c:crossAx').att('val', 361690304); + valAx.ele('c:crosses').att('val', "autoZero"); + valAx.ele('c:crossBetween').att('val', "between"); + genTitleXML(valAx, this.chartData.ylabel); + + function genTitleXML(xmlc, txtRun) { + var xz_xlabc = xmlc.ele('c:title'); + var xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich'); + xz_xlab.ele('a:bodyPr'); + xz_xlab.ele('a:lstStyle'); + var xz_xlabp = xz_xlab.ele('a:p'); + xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100).ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + var xz_xlabpr = xz_xlabp.ele('a:r'); + var title_txt = xz_xlabpr.ele("a:rPr").att("sz", txtRun.fontSize * 100).att('lang', 'ar-SA'); + title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + if (txtRun.bold) title_txt.att('b', txtRun.bold); + if (txtRun.italic) title_txt.att('i', txtRun.italic); + title_txt.att('baseline', 0); + + xz_xlabpr.ele('a:t', txtRun.value); + xz_xlabp.ele("a:endParaRPr").att("sz", txtRun.fontSize * 100).att('lang', 'en-US').ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + xz_xlab.ele("c:overlay").att("val", 1); + } + + var legend = xchart.ele("c:legend"); + legend.ele("c:legendPos").att("val", "r"); + legend.ele("c:overlay").att("val", "0"); + var txPr = legend.ele("c:txPr");txPr.ele("a:bodyPr"); + txPr.ele("a:lstStyle"); + var txPrp = txPr.ele("a:p"); + txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200).ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + txPrp.ele("a:endParaRPr").att('lang', 'en-US'); + xchart.ele("c:plotVisOnly").att("val", 1); + xchart.ele("c:dispBlanksAs").att("val", "gap"); + xchart.ele("c:showDLblsOverMax").att("val", 0); + } + }, { + key: 'name', + get: function get() { + return this._name; + }, + set: function set(newName) { + this._name = newName; + } + }, { + key: 'id', + get: function get() { + return this._id; + }, + set: function set(id) { + this._id = id; + } + }, { + key: 'rId', + get: function get() { + return 'rId' + this._id; + } + }, { + key: 'description', + get: function get() { + return this._descr !== null ? this._descr : this._name; + }, + set: function set(desc) { + this._descr = desc; + } + }, { + key: 'title', + get: function get() { + return this._title !== null ? this._title : this._name; + }, + set: function set(title) { + this._title = title; + } + }, { + key: 'extension', + get: function get() { + return this._extension; + } + }, { + key: 'width', + get: function get() { + var inWidth = this._pxWidth / 96; + var emu = new EMU(inWidth + 'in'); + return emu.value; + } + }, { + key: 'height', + get: function get() { + var inHeight = this._pxHeight / 96; + var emu = new EMU(inHeight + 'in'); + return emu.value; + } + }]); + + return Chart; +}(Drawing); + +module.exports = Chart; +//# sourceMappingURL=chart.js.map \ No newline at end of file diff --git a/distribution/lib/drawing/chart.js.map b/distribution/lib/drawing/chart.js.map new file mode 100644 index 00000000..ff8f0e2c --- /dev/null +++ b/distribution/lib/drawing/chart.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/drawing/chart.js"],"names":["Drawing","require","xmlbuilder","EMU","uuidv4","v4","Chart","opts","kind","type","_title","chartData","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","width","height","graphicFrame","nvGraphicFramePr","cNvPrEle","id","xfrm","graphicData","rId","xmlcx","xchart","title","title_rich","titlep","titlepr","plotArea","layout","ml","barChart","catAx","valAx","sno","dataSeries","sx","ser","label","ptrn","pattern","range","catRange","dLbl","genTitleXML","xlabel","ylabel","xmlc","txtRun","xz_xlabc","xz_xlab","xz_xlabp","fontSize","xz_xlabpr","title_txt","bold","italic","value","legend","txPr","txPrp","_name","newName","_id","_descr","desc","_extension","inWidth","_pxWidth","emu","inHeight","_pxHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;AACA,IAAME,MAAMF,QAAQ,mBAAR,CAAZ;;eACuBA,QAAQ,MAAR,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OE,IAAIZ,KAAX;AACH;;;4BAEY;AACT,gBAAIa,WAAW,KAAKC,SAAL,GAAiB,EAAhC;AACA,gBAAIF,MAAM,IAAIzF,GAAJ,CAAQ0F,WAAW,IAAnB,CAAV;AACA,mBAAOD,IAAIZ,KAAX;AACH;;;;EAlEehF,O;;AAkRpB+F,OAAOC,OAAP,GAAiB1F,KAAjB","file":"chart.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst EMU = require('../classes/emu.js')\r\nconst { v4: uuidv4 } = require('uuid');\r\n\r\nclass Chart extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'chart';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';\r\n this._title;\r\n this.chartData = opts.chartData;\r\n\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n // if (this.editAs !== null) {\r\n // anchorEle.att('editAs', this.editAs);\r\n // }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let graphicFrame = anchorEle.ele('xdr:graphicFrame');\r\n graphicFrame.att(\"macro\", \"\");\r\n let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr');\r\n let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att(\"id\", this.id).att(\"name\", \"Chart \" + this.id);\r\n // this.axExtId1 = uuidv4()\r\n // this.axExtId2 = uuidv4();\r\n\r\n // let extLst = cNvPrEle.ele(\"a:extLst\")\r\n // let aext = extLst.ele(\"a:ext\").att(\"uri\", this.axExtId1)\r\n // let a16creat = aext.ele(\"a16:creationId\").att(\"xmlns:a16\", \"http://schemas.microsoft.com/office/drawing/2014/main\")\r\n // a16creat.att(\"id\", this.axExtId2)\r\n nvGraphicFramePr.ele(\"xdr:cNvGraphicFramePr\").ele(\"a:graphicFrameLocks\");\r\n\r\n let xfrm = graphicFrame.ele(\"xdr:xfrm\")\r\n xfrm.ele(\"a:off\").att(\"x\", 0).att(\"y\", 0)\r\n xfrm.ele(\"a:ext\").att(\"cx\", 0).att(\"cy\", 0)\r\n\r\n let graphicData = graphicFrame.ele(\"a:graphic\").ele(\"a:graphicData\").att(\"uri\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n graphicData.ele(\"c:chart\").att(\"xmlns:c\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n .att(\"xmlns:r\", \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\")\r\n .att(\"r:id\", this.rId)\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n\r\n chartPartXML(xmlcx) {\r\n xmlcx.ele('c:date1904').att('val', 0);\r\n xmlcx.ele('c:lang').att('val', 'en-US');\r\n xmlcx.ele('c:roundedCorners').att('val', 0);\r\n let xchart = xmlcx.ele('c:chart');\r\n let title = xchart.ele('c:title');\r\n let title_rich = title.ele('c:tx').ele('c:rich')\r\n title_rich.ele('a:bodyPr')\r\n title_rich.ele('a:lstStyle')\r\n let titlep = title_rich.ele('a:p');\r\n titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let titlepr = titlep.ele('a:r')\r\n titlepr.ele(\"a:rPr\").att(\"sz\", 1400).att('lang', 'ar-SA')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n titlepr.ele('a:t', this.chartData.title)\r\n titlep.ele(\"a:endParaRPr\").att(\"sz\", 1400).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n title.ele(\"c:overlay\").att(\"val\", 1)\r\n\r\n xchart.ele(\"c:autoTitleDeleted\").att(\"val\", 0);\r\n\r\n let plotArea = xchart.ele(\"c:plotArea\")\r\n let layout = plotArea.ele(\"c:layout\")\r\n let ml = layout.ele('c:manualLayout')\r\n ml.ele('c:layoutTarget').att('val', 'inner')\r\n ml.ele('c:xMode').att('val', 'edge')\r\n ml.ele('c:yMode').att('val', 'edge')\r\n ml.ele('c:x').att('val', 0.1)\r\n ml.ele('c:y').att('val', 0.1)\r\n ml.ele('c:w').att('val', 0.75)\r\n ml.ele('c:h').att('val', 0.6)\r\n\r\n let barChart = plotArea.ele(\"c:barChart\")\r\n let catAx = plotArea.ele(\"c:catAx\")\r\n let valAx = plotArea.ele(\"c:valAx\")\r\n\r\n barChart.ele(\"c:barDir\").att(\"val\", \"col\")\r\n barChart.ele(\"c:grouping\").att(\"val\", \"clustered\")\r\n barChart.ele(\"c:varyColors\").att(\"val\", 0)\r\n for (var sno in this.chartData.dataSeries) {\r\n var sx = this.chartData.dataSeries[sno];\r\n // console.log(sno, sx)\r\n let ser = barChart.ele(\"c:ser\")\r\n ser.ele(\"c:idx\").att(\"val\", sno);\r\n ser.ele(\"c:order\").att(\"val\", sno);\r\n ser.ele('c:tx').ele('c:v', sx.label);\r\n let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern);\r\n\r\n ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1');\r\n ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1');\r\n ser.ele('c:invertIfNegative').att('val', 0)\r\n\r\n if (sx.range) {\r\n ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range)\r\n }\r\n if (sx.catRange) {\r\n ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange);\r\n }\r\n // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart')\r\n // .att('uri', this.axExtId1)\r\n // .ele('c16:uniqueId').att('val', this.axExtId2)\r\n }\r\n let dLbl = barChart.ele('c:dLbls');\r\n dLbl.ele('c:showLegendKey').att('val', 0)\r\n dLbl.ele('c:showVal').att('val', 0)\r\n dLbl.ele('c:showCatName').att('val', 0)\r\n dLbl.ele('c:showSerName').att('val', 0)\r\n dLbl.ele('c:showPercent').att('val', 0)\r\n dLbl.ele('c:showBubbleSize').att('val', 0)\r\n\r\n barChart.ele('c:gapWidth').att('val', 150)\r\n barChart.ele('c:axId').att('val', 361690304)\r\n barChart.ele('c:axId').att('val', 1)\r\n\r\n catAx.ele('c:axId').att('val', 361690304)\r\n catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n catAx.ele('c:delete').att('val', 0)\r\n catAx.ele('c:axPos').att('val', 'b')\r\n catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0)\r\n catAx.ele('c:majorTickMark').att('val', 'out')\r\n catAx.ele('c:minorTickMark').att('val', 'none')\r\n catAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n catAx.ele('c:crossAx').att('val', 1)\r\n catAx.ele('c:crosses').att('val', \"autoZero\")\r\n catAx.ele('c:auto').att('val', 1)\r\n catAx.ele('c:lblAlgn').att('val', \"ctr\")\r\n catAx.ele('c:lblOffset').att('val', 100)\r\n catAx.ele('c:noMultiLvlLbl').att('val', 0)\r\n genTitleXML(catAx, this.chartData.xlabel)\r\n\r\n valAx.ele('c:axId').att('val', 1)\r\n valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n valAx.ele('c:delete').att('val', 0)\r\n valAx.ele('c:axPos').att('val', 'l')\r\n valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1)\r\n valAx.ele('c:majorTickMark').att('val', 'out')\r\n valAx.ele('c:minorTickMark').att('val', 'none')\r\n valAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n valAx.ele('c:crossAx').att('val', 361690304)\r\n valAx.ele('c:crosses').att('val', \"autoZero\")\r\n valAx.ele('c:crossBetween').att('val', \"between\")\r\n genTitleXML(valAx, this.chartData.ylabel)\r\n\r\n function genTitleXML(xmlc, txtRun) {\r\n let xz_xlabc = xmlc.ele('c:title')\r\n let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich')\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let xz_xlabpr = xz_xlabp.ele('a:r')\r\n let title_txt = xz_xlabpr.ele(\"a:rPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'ar-SA')\r\n title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) title_txt.att('b', txtRun.bold);\r\n if (txtRun.italic) title_txt.att('i', txtRun.italic);\r\n title_txt.att('baseline', 0)\r\n\r\n xz_xlabpr.ele('a:t', txtRun.value)\r\n xz_xlabp.ele(\"a:endParaRPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n xz_xlab.ele(\"c:overlay\").att(\"val\", 1)\r\n }\r\n\r\n\r\n let legend = xchart.ele(\"c:legend\");\r\n legend.ele(\"c:legendPos\").att(\"val\", \"r\");\r\n legend.ele(\"c:overlay\").att(\"val\", \"0\");\r\n let txPr = legend.ele(\"c:txPr\"); txPr.ele(\"a:bodyPr\");\r\n txPr.ele(\"a:lstStyle\");\r\n let txPrp = txPr.ele(\"a:p\");\r\n txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n txPrp.ele(\"a:endParaRPr\").att('lang', 'en-US')\r\n xchart.ele(\"c:plotVisOnly\").att(\"val\", 1)\r\n xchart.ele(\"c:dispBlanksAs\").att(\"val\", \"gap\")\r\n xchart.ele(\"c:showDLblsOverMax\").att(\"val\", 0)\r\n }\r\n}\r\n\r\nmodule.exports = Chart;"]} \ No newline at end of file diff --git a/distribution/lib/workbook/chartsCollection.js b/distribution/lib/workbook/chartsCollection.js new file mode 100644 index 00000000..8f0da338 --- /dev/null +++ b/distribution/lib/workbook/chartsCollection.js @@ -0,0 +1,35 @@ +"use strict"; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var ChartsCollection = function () { + function ChartsCollection() { + _classCallCheck(this, ChartsCollection); + + this.items = []; + } + + _createClass(ChartsCollection, [{ + key: "add", + value: function add(item) { + this.items.push(item); + return this.items.length; + } + }, { + key: "isEmpty", + get: function get() { + if (this.items.length === 0) { + return true; + } else { + return false; + } + } + }]); + + return ChartsCollection; +}(); + +module.exports = ChartsCollection; +//# sourceMappingURL=chartsCollection.js.map \ No newline at end of file diff --git a/distribution/lib/workbook/chartsCollection.js.map b/distribution/lib/workbook/chartsCollection.js.map new file mode 100644 index 00000000..ab4af478 --- /dev/null +++ b/distribution/lib/workbook/chartsCollection.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../source/lib/workbook/chartsCollection.js"],"names":["ChartsCollection","items","item","push","length","module","exports"],"mappings":";;;;;;IAAMA,gB;AACF,gCAAc;AAAA;;AACV,aAAKC,KAAL,GAAa,EAAb;AACH;;;;4BAEGC,I,EAAM;AACN,iBAAKD,KAAL,CAAWE,IAAX,CAAgBD,IAAhB;AACA,mBAAO,KAAKD,KAAL,CAAWG,MAAlB;AACH;;;4BAEa;AACV,gBAAI,KAAKH,KAAL,CAAWG,MAAX,KAAsB,CAA1B,EAA6B;AACzB,uBAAO,IAAP;AACH,aAFD,MAEO;AACH,uBAAO,KAAP;AACH;AACJ;;;;;;AAGLC,OAAOC,OAAP,GAAiBN,gBAAjB","file":"chartsCollection.js","sourcesContent":["class ChartsCollection {\r\n constructor() {\r\n this.items = [];\r\n }\r\n\r\n add(item) {\r\n this.items.push(item);\r\n return this.items.length;\r\n }\r\n\r\n get isEmpty() {\r\n if (this.items.length === 0) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = ChartsCollection;"]} \ No newline at end of file From 2360578f4d38ac2c20f5ce2090293b937c8b4aa9 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Tue, 12 Jan 2021 17:36:47 +0300 Subject: [PATCH 11/12] Added fonts for xaxis labelling --- distribution/lib/drawing/chart.js | 13 +++++++++++++ distribution/lib/drawing/chart.js.map | 2 +- source/lib/drawing/chart.js | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/distribution/lib/drawing/chart.js b/distribution/lib/drawing/chart.js index b9a1be48..f8c6a357 100644 --- a/distribution/lib/drawing/chart.js +++ b/distribution/lib/drawing/chart.js @@ -190,6 +190,7 @@ var Chart = function (_Drawing) { catAx.ele('c:majorTickMark').att('val', 'out'); catAx.ele('c:minorTickMark').att('val', 'none'); catAx.ele('c:tickLblPos').att('val', 'nextTo'); + if (this.chartData.xlabel.font) genTxPrXML(catAx, this.chart); catAx.ele('c:crossAx').att('val', 1); catAx.ele('c:crosses').att('val', "autoZero"); catAx.ele('c:auto').att('val', 1); @@ -230,6 +231,18 @@ var Chart = function (_Drawing) { xz_xlab.ele("c:overlay").att("val", 1); } + function genTxPrXML(xmlc, txtRun) { + var xz_xlab = xmlc.ele('c:txPr'); + + xz_xlab.ele('a:bodyPr'); + xz_xlab.ele('a:lstStyle'); + var xz_xlabp = xz_xlab.ele('a:p'); + var fx = xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100); + fx.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78'); + if (txtRun.bold) fx.att('b', txtRun.bold); + if (txtRun.italic) fx.att('i', txtRun.italic); + } + var legend = xchart.ele("c:legend"); legend.ele("c:legendPos").att("val", "r"); legend.ele("c:overlay").att("val", "0"); diff --git a/distribution/lib/drawing/chart.js.map b/distribution/lib/drawing/chart.js.map index ff8f0e2c..70f27389 100644 --- a/distribution/lib/drawing/chart.js.map +++ b/distribution/lib/drawing/chart.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/drawing/chart.js"],"names":["Drawing","require","xmlbuilder","EMU","uuidv4","v4","Chart","opts","kind","type","_title","chartData","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","width","height","graphicFrame","nvGraphicFramePr","cNvPrEle","id","xfrm","graphicData","rId","xmlcx","xchart","title","title_rich","titlep","titlepr","plotArea","layout","ml","barChart","catAx","valAx","sno","dataSeries","sx","ser","label","ptrn","pattern","range","catRange","dLbl","genTitleXML","xlabel","ylabel","xmlc","txtRun","xz_xlabc","xz_xlab","xz_xlabp","fontSize","xz_xlabpr","title_txt","bold","italic","value","legend","txPr","txPrp","_name","newName","_id","_descr","desc","_extension","inWidth","_pxWidth","emu","inHeight","_pxHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,aAAaD,QAAQ,YAA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ACA,gBAAIC,MAAM,IAAIzF,GAAJ,CAAQuF,UAAU,IAAlB,CAAV;AACA,mBAAOE,IAAIZ,KAAX;AACH;;;4BAEY;AACT,gBAAIa,WAAW,KAAKC,SAAL,GAAiB,EAAhC;AACA,gBAAIF,MAAM,IAAIzF,GAAJ,CAAQ0F,WAAW,IAAnB,CAAV;AACA,mBAAOD,IAAIZ,KAAX;AACH;;;;EAlEehF,O;;AAkRpB+F,OAAOC,OAAP,GAAiB1F,KAAjB","file":"chart.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst EMU = require('../classes/emu.js')\r\nconst { v4: uuidv4 } = require('uuid');\r\n\r\nclass Chart extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'chart';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';\r\n this._title;\r\n this.chartData = opts.chartData;\r\n\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n // if (this.editAs !== null) {\r\n // anchorEle.att('editAs', this.editAs);\r\n // }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let graphicFrame = anchorEle.ele('xdr:graphicFrame');\r\n graphicFrame.att(\"macro\", \"\");\r\n let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr');\r\n let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att(\"id\", this.id).att(\"name\", \"Chart \" + this.id);\r\n // this.axExtId1 = uuidv4()\r\n // this.axExtId2 = uuidv4();\r\n\r\n // let extLst = cNvPrEle.ele(\"a:extLst\")\r\n // let aext = extLst.ele(\"a:ext\").att(\"uri\", this.axExtId1)\r\n // let a16creat = aext.ele(\"a16:creationId\").att(\"xmlns:a16\", \"http://schemas.microsoft.com/office/drawing/2014/main\")\r\n // a16creat.att(\"id\", this.axExtId2)\r\n nvGraphicFramePr.ele(\"xdr:cNvGraphicFramePr\").ele(\"a:graphicFrameLocks\");\r\n\r\n let xfrm = graphicFrame.ele(\"xdr:xfrm\")\r\n xfrm.ele(\"a:off\").att(\"x\", 0).att(\"y\", 0)\r\n xfrm.ele(\"a:ext\").att(\"cx\", 0).att(\"cy\", 0)\r\n\r\n let graphicData = graphicFrame.ele(\"a:graphic\").ele(\"a:graphicData\").att(\"uri\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n graphicData.ele(\"c:chart\").att(\"xmlns:c\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n .att(\"xmlns:r\", \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\")\r\n .att(\"r:id\", this.rId)\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n\r\n chartPartXML(xmlcx) {\r\n xmlcx.ele('c:date1904').att('val', 0);\r\n xmlcx.ele('c:lang').att('val', 'en-US');\r\n xmlcx.ele('c:roundedCorners').att('val', 0);\r\n let xchart = xmlcx.ele('c:chart');\r\n let title = xchart.ele('c:title');\r\n let title_rich = title.ele('c:tx').ele('c:rich')\r\n title_rich.ele('a:bodyPr')\r\n title_rich.ele('a:lstStyle')\r\n let titlep = title_rich.ele('a:p');\r\n titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let titlepr = titlep.ele('a:r')\r\n titlepr.ele(\"a:rPr\").att(\"sz\", 1400).att('lang', 'ar-SA')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n titlepr.ele('a:t', this.chartData.title)\r\n titlep.ele(\"a:endParaRPr\").att(\"sz\", 1400).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n title.ele(\"c:overlay\").att(\"val\", 1)\r\n\r\n xchart.ele(\"c:autoTitleDeleted\").att(\"val\", 0);\r\n\r\n let plotArea = xchart.ele(\"c:plotArea\")\r\n let layout = plotArea.ele(\"c:layout\")\r\n let ml = layout.ele('c:manualLayout')\r\n ml.ele('c:layoutTarget').att('val', 'inner')\r\n ml.ele('c:xMode').att('val', 'edge')\r\n ml.ele('c:yMode').att('val', 'edge')\r\n ml.ele('c:x').att('val', 0.1)\r\n ml.ele('c:y').att('val', 0.1)\r\n ml.ele('c:w').att('val', 0.75)\r\n ml.ele('c:h').att('val', 0.6)\r\n\r\n let barChart = plotArea.ele(\"c:barChart\")\r\n let catAx = plotArea.ele(\"c:catAx\")\r\n let valAx = plotArea.ele(\"c:valAx\")\r\n\r\n barChart.ele(\"c:barDir\").att(\"val\", \"col\")\r\n barChart.ele(\"c:grouping\").att(\"val\", \"clustered\")\r\n barChart.ele(\"c:varyColors\").att(\"val\", 0)\r\n for (var sno in this.chartData.dataSeries) {\r\n var sx = this.chartData.dataSeries[sno];\r\n // console.log(sno, sx)\r\n let ser = barChart.ele(\"c:ser\")\r\n ser.ele(\"c:idx\").att(\"val\", sno);\r\n ser.ele(\"c:order\").att(\"val\", sno);\r\n ser.ele('c:tx').ele('c:v', sx.label);\r\n let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern);\r\n\r\n ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1');\r\n ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1');\r\n ser.ele('c:invertIfNegative').att('val', 0)\r\n\r\n if (sx.range) {\r\n ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range)\r\n }\r\n if (sx.catRange) {\r\n ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange);\r\n }\r\n // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart')\r\n // .att('uri', this.axExtId1)\r\n // .ele('c16:uniqueId').att('val', this.axExtId2)\r\n }\r\n let dLbl = barChart.ele('c:dLbls');\r\n dLbl.ele('c:showLegendKey').att('val', 0)\r\n dLbl.ele('c:showVal').att('val', 0)\r\n dLbl.ele('c:showCatName').att('val', 0)\r\n dLbl.ele('c:showSerName').att('val', 0)\r\n dLbl.ele('c:showPercent').att('val', 0)\r\n dLbl.ele('c:showBubbleSize').att('val', 0)\r\n\r\n barChart.ele('c:gapWidth').att('val', 150)\r\n barChart.ele('c:axId').att('val', 361690304)\r\n barChart.ele('c:axId').att('val', 1)\r\n\r\n catAx.ele('c:axId').att('val', 361690304)\r\n catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n catAx.ele('c:delete').att('val', 0)\r\n catAx.ele('c:axPos').att('val', 'b')\r\n catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0)\r\n catAx.ele('c:majorTickMark').att('val', 'out')\r\n catAx.ele('c:minorTickMark').att('val', 'none')\r\n catAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n catAx.ele('c:crossAx').att('val', 1)\r\n catAx.ele('c:crosses').att('val', \"autoZero\")\r\n catAx.ele('c:auto').att('val', 1)\r\n catAx.ele('c:lblAlgn').att('val', \"ctr\")\r\n catAx.ele('c:lblOffset').att('val', 100)\r\n catAx.ele('c:noMultiLvlLbl').att('val', 0)\r\n genTitleXML(catAx, this.chartData.xlabel)\r\n\r\n valAx.ele('c:axId').att('val', 1)\r\n valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n valAx.ele('c:delete').att('val', 0)\r\n valAx.ele('c:axPos').att('val', 'l')\r\n valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1)\r\n valAx.ele('c:majorTickMark').att('val', 'out')\r\n valAx.ele('c:minorTickMark').att('val', 'none')\r\n valAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n valAx.ele('c:crossAx').att('val', 361690304)\r\n valAx.ele('c:crosses').att('val', \"autoZero\")\r\n valAx.ele('c:crossBetween').att('val', \"between\")\r\n genTitleXML(valAx, this.chartData.ylabel)\r\n\r\n function genTitleXML(xmlc, txtRun) {\r\n let xz_xlabc = xmlc.ele('c:title')\r\n let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich')\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let xz_xlabpr = xz_xlabp.ele('a:r')\r\n let title_txt = xz_xlabpr.ele(\"a:rPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'ar-SA')\r\n title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) title_txt.att('b', txtRun.bold);\r\n if (txtRun.italic) title_txt.att('i', txtRun.italic);\r\n title_txt.att('baseline', 0)\r\n\r\n xz_xlabpr.ele('a:t', txtRun.value)\r\n xz_xlabp.ele(\"a:endParaRPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n xz_xlab.ele(\"c:overlay\").att(\"val\", 1)\r\n }\r\n\r\n\r\n let legend = xchart.ele(\"c:legend\");\r\n legend.ele(\"c:legendPos\").att(\"val\", \"r\");\r\n legend.ele(\"c:overlay\").att(\"val\", \"0\");\r\n let txPr = legend.ele(\"c:txPr\"); txPr.ele(\"a:bodyPr\");\r\n txPr.ele(\"a:lstStyle\");\r\n let txPrp = txPr.ele(\"a:p\");\r\n txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n txPrp.ele(\"a:endParaRPr\").att('lang', 'en-US')\r\n xchart.ele(\"c:plotVisOnly\").att(\"val\", 1)\r\n xchart.ele(\"c:dispBlanksAs\").att(\"val\", \"gap\")\r\n xchart.ele(\"c:showDLblsOverMax\").att(\"val\", 0)\r\n }\r\n}\r\n\r\nmodule.exports = Chart;"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/drawing/chart.js"],"names":["Drawing","require","xmlbuilder","EMU","uuidv4","v4","Chart","opts","kind","type","_title","chartData","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","width","height","graphicFrame","nvGraphicFramePr","cNvPrEle","id","xfrm","graphicData","rId","xmlcx","xchart","title","title_rich","titlep","titlepr","plotArea","layout","ml","barChart","catAx","valAx","sno","dataSeries","sx","ser","label","ptrn","pattern","range","catRange","dLbl","xlabel","font","genTxPrXML","chart","genTitleXML","ylabel","xmlc","txtRun","xz_xlabc","xz_xlab","xz_xlabp","fontSize","xz_xlabpr","title_txt","bold","italic","value","fx","legend","txPr","txPrp","_name","newName","_id","_descr","desc","_extension","inWidth","_pxWidth","emu","inHeight","_pxHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;AACA,IAAME,MAAMF,QAAQ,mBAAR,CAAZ;;eACuBA,QAAQ,MAAR,C;IAAXG,M,YAAJC,E;;IAEFC,K;;;AACF;;;;AAIA,mBAAYC,IAAZ,EAAkB;AAAA;;AAAA;;AAEd,cAAKC,IAAL,GAAY,OAAZ;AACA,cAAKC,IAAL,GAAY,2EA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BACQC,O,EAAS;AACd,iBAAKD,KAAL,GAAaC,OAAb;AACH;;;4BACQ;AACL,mBAAO,KAAKC,GAAZ;AACH,S;0BACMjD,E,EAAI;AACP,iBAAKiD,GAAL,GAAWjD,EAAX;AACH;;;4BAES;AACN,mBAAO,QAAQ,KAAKiD,GAApB;AACH;;;4BAEiB;AACd,mBAAO,KAAKC,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAKH,KAAjD;AACH,S;0BACeI,I,EAAM;AAClB,iBAAKD,MAAL,GAAcC,IAAd;AACH;;;4BAEW;AACR,mBAAO,KAAKlF,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAK8E,KAAjD;AACH,S;0BACSzC,K,EAAO;AACb,iBAAKrC,MAAL,GAAcqC,KAAd;AACH;;;4BAEe;AACZ,mBAAO,KAAK8C,UAAZ;AACH;;;4BAEW;AACR,gBAAIC,UAAU,KAAKC,QAAL,GAAgB,EAA9B;AACA,gBAAIC,MAAM,IAAI7F,GAAJ,CAAQ2F,UAAU,IAAlB,CAAV;AACA,mBAAOE,IAAIb,KAAX;AACH;;;4BAEY;AACT,gBAAIc,WAAW,KAAKC,SAAL,GAAiB,EAAhC;AACA,gBAAIF,MAAM,IAAI7F,GAAJ,CAAQ8F,WAAW,IAAnB,CAAV;AACA,mBAAOD,IAAIb,KAAX;AACH;;;;EAlEenF,O;;AA+RpBmG,OAAOC,OAAP,GAAiB9F,KAAjB","file":"chart.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst EMU = require('../classes/emu.js')\r\nconst { v4: uuidv4 } = require('uuid');\r\n\r\nclass Chart extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'chart';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';\r\n this._title;\r\n this.chartData = opts.chartData;\r\n\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n // if (this.editAs !== null) {\r\n // anchorEle.att('editAs', this.editAs);\r\n // }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let graphicFrame = anchorEle.ele('xdr:graphicFrame');\r\n graphicFrame.att(\"macro\", \"\");\r\n let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr');\r\n let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att(\"id\", this.id).att(\"name\", \"Chart \" + this.id);\r\n // this.axExtId1 = uuidv4()\r\n // this.axExtId2 = uuidv4();\r\n\r\n // let extLst = cNvPrEle.ele(\"a:extLst\")\r\n // let aext = extLst.ele(\"a:ext\").att(\"uri\", this.axExtId1)\r\n // let a16creat = aext.ele(\"a16:creationId\").att(\"xmlns:a16\", \"http://schemas.microsoft.com/office/drawing/2014/main\")\r\n // a16creat.att(\"id\", this.axExtId2)\r\n nvGraphicFramePr.ele(\"xdr:cNvGraphicFramePr\").ele(\"a:graphicFrameLocks\");\r\n\r\n let xfrm = graphicFrame.ele(\"xdr:xfrm\")\r\n xfrm.ele(\"a:off\").att(\"x\", 0).att(\"y\", 0)\r\n xfrm.ele(\"a:ext\").att(\"cx\", 0).att(\"cy\", 0)\r\n\r\n let graphicData = graphicFrame.ele(\"a:graphic\").ele(\"a:graphicData\").att(\"uri\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n graphicData.ele(\"c:chart\").att(\"xmlns:c\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n .att(\"xmlns:r\", \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\")\r\n .att(\"r:id\", this.rId)\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n\r\n chartPartXML(xmlcx) {\r\n xmlcx.ele('c:date1904').att('val', 0);\r\n xmlcx.ele('c:lang').att('val', 'en-US');\r\n xmlcx.ele('c:roundedCorners').att('val', 0);\r\n let xchart = xmlcx.ele('c:chart');\r\n let title = xchart.ele('c:title');\r\n let title_rich = title.ele('c:tx').ele('c:rich')\r\n title_rich.ele('a:bodyPr')\r\n title_rich.ele('a:lstStyle')\r\n let titlep = title_rich.ele('a:p');\r\n titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let titlepr = titlep.ele('a:r')\r\n titlepr.ele(\"a:rPr\").att(\"sz\", 1400).att('lang', 'ar-SA')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n titlepr.ele('a:t', this.chartData.title)\r\n titlep.ele(\"a:endParaRPr\").att(\"sz\", 1400).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n title.ele(\"c:overlay\").att(\"val\", 1)\r\n\r\n xchart.ele(\"c:autoTitleDeleted\").att(\"val\", 0);\r\n\r\n let plotArea = xchart.ele(\"c:plotArea\")\r\n let layout = plotArea.ele(\"c:layout\")\r\n let ml = layout.ele('c:manualLayout')\r\n ml.ele('c:layoutTarget').att('val', 'inner')\r\n ml.ele('c:xMode').att('val', 'edge')\r\n ml.ele('c:yMode').att('val', 'edge')\r\n ml.ele('c:x').att('val', 0.1)\r\n ml.ele('c:y').att('val', 0.1)\r\n ml.ele('c:w').att('val', 0.75)\r\n ml.ele('c:h').att('val', 0.6)\r\n\r\n let barChart = plotArea.ele(\"c:barChart\")\r\n let catAx = plotArea.ele(\"c:catAx\")\r\n let valAx = plotArea.ele(\"c:valAx\")\r\n\r\n barChart.ele(\"c:barDir\").att(\"val\", \"col\")\r\n barChart.ele(\"c:grouping\").att(\"val\", \"clustered\")\r\n barChart.ele(\"c:varyColors\").att(\"val\", 0)\r\n for (var sno in this.chartData.dataSeries) {\r\n var sx = this.chartData.dataSeries[sno];\r\n // console.log(sno, sx)\r\n let ser = barChart.ele(\"c:ser\")\r\n ser.ele(\"c:idx\").att(\"val\", sno);\r\n ser.ele(\"c:order\").att(\"val\", sno);\r\n ser.ele('c:tx').ele('c:v', sx.label);\r\n let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern);\r\n\r\n ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1');\r\n ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1');\r\n ser.ele('c:invertIfNegative').att('val', 0)\r\n\r\n if (sx.range) {\r\n ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range)\r\n }\r\n if (sx.catRange) {\r\n ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange);\r\n }\r\n // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart')\r\n // .att('uri', this.axExtId1)\r\n // .ele('c16:uniqueId').att('val', this.axExtId2)\r\n }\r\n let dLbl = barChart.ele('c:dLbls');\r\n dLbl.ele('c:showLegendKey').att('val', 0)\r\n dLbl.ele('c:showVal').att('val', 0)\r\n dLbl.ele('c:showCatName').att('val', 0)\r\n dLbl.ele('c:showSerName').att('val', 0)\r\n dLbl.ele('c:showPercent').att('val', 0)\r\n dLbl.ele('c:showBubbleSize').att('val', 0)\r\n\r\n barChart.ele('c:gapWidth').att('val', 150)\r\n barChart.ele('c:axId').att('val', 361690304)\r\n barChart.ele('c:axId').att('val', 1)\r\n\r\n catAx.ele('c:axId').att('val', 361690304)\r\n catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n catAx.ele('c:delete').att('val', 0)\r\n catAx.ele('c:axPos').att('val', 'b')\r\n catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0)\r\n catAx.ele('c:majorTickMark').att('val', 'out')\r\n catAx.ele('c:minorTickMark').att('val', 'none')\r\n catAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chart)\r\n catAx.ele('c:crossAx').att('val', 1)\r\n catAx.ele('c:crosses').att('val', \"autoZero\")\r\n catAx.ele('c:auto').att('val', 1)\r\n catAx.ele('c:lblAlgn').att('val', \"ctr\")\r\n catAx.ele('c:lblOffset').att('val', 100)\r\n catAx.ele('c:noMultiLvlLbl').att('val', 0)\r\n genTitleXML(catAx, this.chartData.xlabel)\r\n\r\n valAx.ele('c:axId').att('val', 1)\r\n valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n valAx.ele('c:delete').att('val', 0)\r\n valAx.ele('c:axPos').att('val', 'l')\r\n valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1)\r\n valAx.ele('c:majorTickMark').att('val', 'out')\r\n valAx.ele('c:minorTickMark').att('val', 'none')\r\n valAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n valAx.ele('c:crossAx').att('val', 361690304)\r\n valAx.ele('c:crosses').att('val', \"autoZero\")\r\n valAx.ele('c:crossBetween').att('val', \"between\")\r\n genTitleXML(valAx, this.chartData.ylabel)\r\n\r\n function genTitleXML(xmlc, txtRun) {\r\n let xz_xlabc = xmlc.ele('c:title')\r\n let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich')\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let xz_xlabpr = xz_xlabp.ele('a:r')\r\n let title_txt = xz_xlabpr.ele(\"a:rPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'ar-SA')\r\n title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) title_txt.att('b', txtRun.bold);\r\n if (txtRun.italic) title_txt.att('i', txtRun.italic);\r\n title_txt.att('baseline', 0)\r\n\r\n xz_xlabpr.ele('a:t', txtRun.value)\r\n xz_xlabp.ele(\"a:endParaRPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n xz_xlab.ele(\"c:overlay\").att(\"val\", 1)\r\n }\r\n\r\n function genTxPrXML(xmlc, txtRun) {\r\n let xz_xlab = xmlc.ele('c:txPr')\r\n\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n let fx = xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n fx.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) fx.att('b', txtRun.bold);\r\n if (txtRun.italic) fx.att('i', txtRun.italic);\r\n }\r\n\r\n\r\n let legend = xchart.ele(\"c:legend\");\r\n legend.ele(\"c:legendPos\").att(\"val\", \"r\");\r\n legend.ele(\"c:overlay\").att(\"val\", \"0\");\r\n let txPr = legend.ele(\"c:txPr\"); txPr.ele(\"a:bodyPr\");\r\n txPr.ele(\"a:lstStyle\");\r\n let txPrp = txPr.ele(\"a:p\");\r\n txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n txPrp.ele(\"a:endParaRPr\").att('lang', 'en-US')\r\n xchart.ele(\"c:plotVisOnly\").att(\"val\", 1)\r\n xchart.ele(\"c:dispBlanksAs\").att(\"val\", \"gap\")\r\n xchart.ele(\"c:showDLblsOverMax\").att(\"val\", 0)\r\n }\r\n}\r\n\r\nmodule.exports = Chart;"]} \ No newline at end of file diff --git a/source/lib/drawing/chart.js b/source/lib/drawing/chart.js index 6d3c7af2..2ea537c7 100644 --- a/source/lib/drawing/chart.js +++ b/source/lib/drawing/chart.js @@ -219,6 +219,7 @@ class Chart extends Drawing { catAx.ele('c:majorTickMark').att('val', 'out') catAx.ele('c:minorTickMark').att('val', 'none') catAx.ele('c:tickLblPos').att('val', 'nextTo') + if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chart) catAx.ele('c:crossAx').att('val', 1) catAx.ele('c:crosses').att('val', "autoZero") catAx.ele('c:auto').att('val', 1) @@ -261,6 +262,18 @@ class Chart extends Drawing { xz_xlab.ele("c:overlay").att("val", 1) } + function genTxPrXML(xmlc, txtRun) { + let xz_xlab = xmlc.ele('c:txPr') + + xz_xlab.ele('a:bodyPr') + xz_xlab.ele('a:lstStyle') + let xz_xlabp = xz_xlab.ele('a:p'); + let fx = xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100) + fx.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78') + if (txtRun.bold) fx.att('b', txtRun.bold); + if (txtRun.italic) fx.att('i', txtRun.italic); + } + let legend = xchart.ele("c:legend"); legend.ele("c:legendPos").att("val", "r"); From efa4b5c334bdb6ec3f8bd98c7e85d3558e5ccc13 Mon Sep 17 00:00:00 2001 From: Mohanad Ahmed Date: Tue, 12 Jan 2021 17:43:02 +0300 Subject: [PATCH 12/12] Oops forgot the correct call in xaxis fonts --- distribution/lib/drawing/chart.js | 2 +- distribution/lib/drawing/chart.js.map | 2 +- sample3.js | 2 +- source/lib/drawing/chart.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distribution/lib/drawing/chart.js b/distribution/lib/drawing/chart.js index f8c6a357..06d4521a 100644 --- a/distribution/lib/drawing/chart.js +++ b/distribution/lib/drawing/chart.js @@ -190,7 +190,7 @@ var Chart = function (_Drawing) { catAx.ele('c:majorTickMark').att('val', 'out'); catAx.ele('c:minorTickMark').att('val', 'none'); catAx.ele('c:tickLblPos').att('val', 'nextTo'); - if (this.chartData.xlabel.font) genTxPrXML(catAx, this.chart); + if (this.chartData.xlabel.font) genTxPrXML(catAx, this.chartData.xlabel.font); catAx.ele('c:crossAx').att('val', 1); catAx.ele('c:crosses').att('val', "autoZero"); catAx.ele('c:auto').att('val', 1); diff --git a/distribution/lib/drawing/chart.js.map b/distribution/lib/drawing/chart.js.map index 70f27389..1b77558d 100644 --- a/distribution/lib/drawing/chart.js.map +++ b/distribution/lib/drawing/chart.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../source/lib/drawing/chart.js"],"names":["Drawing","require","xmlbuilder","EMU","uuidv4","v4","Chart","opts","kind","type","_title","chartData","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","width","height","graphicFrame","nvGraphicFramePr","cNvPrEle","id","xfrm","graphicData","rId","xmlcx","xchart","title","title_rich","titlep","titlepr","plotArea","layout","ml","barChart","catAx","valAx","sno","dataSeries","sx","ser","label","ptrn","pattern","range","catRange","dLbl","xlabel","font","genTxPrXML","chart","genTitleXML","ylabel","xmlc","txtRun","xz_xlabc","xz_xlab","xz_xlabp","fontSize","xz_xlabpr","title_txt","bold","italic","value","fx","legend","txPr","txPrp","_name","newName","_id","_descr","desc","_extension","inWidth","_pxWidth","emu","inHeight","_pxHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;AACA,IAAME,MAAMF,QAAQ,mBAAR,CAAZ;;eACuBA,QAAQ,MAAR,C;IAAXG,M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AxC;AACAuB,mBAAO1B,GAAP,CAAW,oBAAX,EAAiCG,GAAjC,CAAqC,KAArC,EAA4C,CAA5C;AACH;;;4BAvQU;AACP,mBAAO,KAAKiE,KAAZ;AACH,S;0BACQC,O,EAAS;AACd,iBAAKD,KAAL,GAAaC,OAAb;AACH;;;4BACQ;AACL,mBAAO,KAAKC,GAAZ;AACH,S;0BACMjD,E,EAAI;AACP,iBAAKiD,GAAL,GAAWjD,EAAX;AACH;;;4BAES;AACN,mBAAO,QAAQ,KAAKiD,GAApB;AACH;;;4BAEiB;AACd,mBAAO,KAAKC,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAKH,KAAjD;AACH,S;0BACeI,I,EAAM;AAClB,iBAAKD,MAAL,GAAcC,IAAd;AACH;;;4BAEW;AACR,mBAAO,KAAKlF,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAK8E,KAAjD;AACH,S;0BACSzC,K,EAAO;AACb,iBAAKrC,MAAL,GAAcqC,KAAd;AACH;;;4BAEe;AACZ,mBAAO,KAAK8C,UAAZ;AACH;;;4BAEW;AACR,gBAAIC,UAAU,KAAKC,QAAL,GAAgB,EAA9B;AACA,gBAAIC,MAAM,IAAI7F,GAAJ,CAAQ2F,UAAU,IAAlB,CAAV;AACA,mBAAOE,IAAIb,KAAX;AACH;;;4BAEY;AACT,gBAAIc,WAAW,KAAKC,SAAL,GAAiB,EAAhC;AACA,gBAAIF,MAAM,IAAI7F,GAAJ,CAAQ8F,WAAW,IAAnB,CAAV;AACA,mBAAOD,IAAIb,KAAX;AACH;;;;EAlEenF,O;;AA+RpBmG,OAAOC,OAAP,GAAiB9F,KAAjB","file":"chart.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst EMU = require('../classes/emu.js')\r\nconst { v4: uuidv4 } = require('uuid');\r\n\r\nclass Chart extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'chart';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';\r\n this._title;\r\n this.chartData = opts.chartData;\r\n\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n // if (this.editAs !== null) {\r\n // anchorEle.att('editAs', this.editAs);\r\n // }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let graphicFrame = anchorEle.ele('xdr:graphicFrame');\r\n graphicFrame.att(\"macro\", \"\");\r\n let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr');\r\n let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att(\"id\", this.id).att(\"name\", \"Chart \" + this.id);\r\n // this.axExtId1 = uuidv4()\r\n // this.axExtId2 = uuidv4();\r\n\r\n // let extLst = cNvPrEle.ele(\"a:extLst\")\r\n // let aext = extLst.ele(\"a:ext\").att(\"uri\", this.axExtId1)\r\n // let a16creat = aext.ele(\"a16:creationId\").att(\"xmlns:a16\", \"http://schemas.microsoft.com/office/drawing/2014/main\")\r\n // a16creat.att(\"id\", this.axExtId2)\r\n nvGraphicFramePr.ele(\"xdr:cNvGraphicFramePr\").ele(\"a:graphicFrameLocks\");\r\n\r\n let xfrm = graphicFrame.ele(\"xdr:xfrm\")\r\n xfrm.ele(\"a:off\").att(\"x\", 0).att(\"y\", 0)\r\n xfrm.ele(\"a:ext\").att(\"cx\", 0).att(\"cy\", 0)\r\n\r\n let graphicData = graphicFrame.ele(\"a:graphic\").ele(\"a:graphicData\").att(\"uri\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n graphicData.ele(\"c:chart\").att(\"xmlns:c\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n .att(\"xmlns:r\", \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\")\r\n .att(\"r:id\", this.rId)\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n\r\n chartPartXML(xmlcx) {\r\n xmlcx.ele('c:date1904').att('val', 0);\r\n xmlcx.ele('c:lang').att('val', 'en-US');\r\n xmlcx.ele('c:roundedCorners').att('val', 0);\r\n let xchart = xmlcx.ele('c:chart');\r\n let title = xchart.ele('c:title');\r\n let title_rich = title.ele('c:tx').ele('c:rich')\r\n title_rich.ele('a:bodyPr')\r\n title_rich.ele('a:lstStyle')\r\n let titlep = title_rich.ele('a:p');\r\n titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let titlepr = titlep.ele('a:r')\r\n titlepr.ele(\"a:rPr\").att(\"sz\", 1400).att('lang', 'ar-SA')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n titlepr.ele('a:t', this.chartData.title)\r\n titlep.ele(\"a:endParaRPr\").att(\"sz\", 1400).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n title.ele(\"c:overlay\").att(\"val\", 1)\r\n\r\n xchart.ele(\"c:autoTitleDeleted\").att(\"val\", 0);\r\n\r\n let plotArea = xchart.ele(\"c:plotArea\")\r\n let layout = plotArea.ele(\"c:layout\")\r\n let ml = layout.ele('c:manualLayout')\r\n ml.ele('c:layoutTarget').att('val', 'inner')\r\n ml.ele('c:xMode').att('val', 'edge')\r\n ml.ele('c:yMode').att('val', 'edge')\r\n ml.ele('c:x').att('val', 0.1)\r\n ml.ele('c:y').att('val', 0.1)\r\n ml.ele('c:w').att('val', 0.75)\r\n ml.ele('c:h').att('val', 0.6)\r\n\r\n let barChart = plotArea.ele(\"c:barChart\")\r\n let catAx = plotArea.ele(\"c:catAx\")\r\n let valAx = plotArea.ele(\"c:valAx\")\r\n\r\n barChart.ele(\"c:barDir\").att(\"val\", \"col\")\r\n barChart.ele(\"c:grouping\").att(\"val\", \"clustered\")\r\n barChart.ele(\"c:varyColors\").att(\"val\", 0)\r\n for (var sno in this.chartData.dataSeries) {\r\n var sx = this.chartData.dataSeries[sno];\r\n // console.log(sno, sx)\r\n let ser = barChart.ele(\"c:ser\")\r\n ser.ele(\"c:idx\").att(\"val\", sno);\r\n ser.ele(\"c:order\").att(\"val\", sno);\r\n ser.ele('c:tx').ele('c:v', sx.label);\r\n let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern);\r\n\r\n ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1');\r\n ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1');\r\n ser.ele('c:invertIfNegative').att('val', 0)\r\n\r\n if (sx.range) {\r\n ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range)\r\n }\r\n if (sx.catRange) {\r\n ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange);\r\n }\r\n // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart')\r\n // .att('uri', this.axExtId1)\r\n // .ele('c16:uniqueId').att('val', this.axExtId2)\r\n }\r\n let dLbl = barChart.ele('c:dLbls');\r\n dLbl.ele('c:showLegendKey').att('val', 0)\r\n dLbl.ele('c:showVal').att('val', 0)\r\n dLbl.ele('c:showCatName').att('val', 0)\r\n dLbl.ele('c:showSerName').att('val', 0)\r\n dLbl.ele('c:showPercent').att('val', 0)\r\n dLbl.ele('c:showBubbleSize').att('val', 0)\r\n\r\n barChart.ele('c:gapWidth').att('val', 150)\r\n barChart.ele('c:axId').att('val', 361690304)\r\n barChart.ele('c:axId').att('val', 1)\r\n\r\n catAx.ele('c:axId').att('val', 361690304)\r\n catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n catAx.ele('c:delete').att('val', 0)\r\n catAx.ele('c:axPos').att('val', 'b')\r\n catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0)\r\n catAx.ele('c:majorTickMark').att('val', 'out')\r\n catAx.ele('c:minorTickMark').att('val', 'none')\r\n catAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chart)\r\n catAx.ele('c:crossAx').att('val', 1)\r\n catAx.ele('c:crosses').att('val', \"autoZero\")\r\n catAx.ele('c:auto').att('val', 1)\r\n catAx.ele('c:lblAlgn').att('val', \"ctr\")\r\n catAx.ele('c:lblOffset').att('val', 100)\r\n catAx.ele('c:noMultiLvlLbl').att('val', 0)\r\n genTitleXML(catAx, this.chartData.xlabel)\r\n\r\n valAx.ele('c:axId').att('val', 1)\r\n valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n valAx.ele('c:delete').att('val', 0)\r\n valAx.ele('c:axPos').att('val', 'l')\r\n valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1)\r\n valAx.ele('c:majorTickMark').att('val', 'out')\r\n valAx.ele('c:minorTickMark').att('val', 'none')\r\n valAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n valAx.ele('c:crossAx').att('val', 361690304)\r\n valAx.ele('c:crosses').att('val', \"autoZero\")\r\n valAx.ele('c:crossBetween').att('val', \"between\")\r\n genTitleXML(valAx, this.chartData.ylabel)\r\n\r\n function genTitleXML(xmlc, txtRun) {\r\n let xz_xlabc = xmlc.ele('c:title')\r\n let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich')\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let xz_xlabpr = xz_xlabp.ele('a:r')\r\n let title_txt = xz_xlabpr.ele(\"a:rPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'ar-SA')\r\n title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) title_txt.att('b', txtRun.bold);\r\n if (txtRun.italic) title_txt.att('i', txtRun.italic);\r\n title_txt.att('baseline', 0)\r\n\r\n xz_xlabpr.ele('a:t', txtRun.value)\r\n xz_xlabp.ele(\"a:endParaRPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n xz_xlab.ele(\"c:overlay\").att(\"val\", 1)\r\n }\r\n\r\n function genTxPrXML(xmlc, txtRun) {\r\n let xz_xlab = xmlc.ele('c:txPr')\r\n\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n let fx = xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n fx.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) fx.att('b', txtRun.bold);\r\n if (txtRun.italic) fx.att('i', txtRun.italic);\r\n }\r\n\r\n\r\n let legend = xchart.ele(\"c:legend\");\r\n legend.ele(\"c:legendPos\").att(\"val\", \"r\");\r\n legend.ele(\"c:overlay\").att(\"val\", \"0\");\r\n let txPr = legend.ele(\"c:txPr\"); txPr.ele(\"a:bodyPr\");\r\n txPr.ele(\"a:lstStyle\");\r\n let txPrp = txPr.ele(\"a:p\");\r\n txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n txPrp.ele(\"a:endParaRPr\").att('lang', 'en-US')\r\n xchart.ele(\"c:plotVisOnly\").att(\"val\", 1)\r\n xchart.ele(\"c:dispBlanksAs\").att(\"val\", \"gap\")\r\n xchart.ele(\"c:showDLblsOverMax\").att(\"val\", 0)\r\n }\r\n}\r\n\r\nmodule.exports = Chart;"]} \ No newline at end of file +{"version":3,"sources":["../../../source/lib/drawing/chart.js"],"names":["Drawing","require","xmlbuilder","EMU","uuidv4","v4","Chart","opts","kind","type","_title","chartData","indexOf","position","anchor","from","to","x","y","TypeError","ele","anchorEle","anchorType","att","_position","af","anchorFrom","afEle","text","col","colOff","row","rowOff","anchorTo","at","atEle","width","height","graphicFrame","nvGraphicFramePr","cNvPrEle","id","xfrm","graphicData","rId","xmlcx","xchart","title","title_rich","titlep","titlepr","plotArea","layout","ml","barChart","catAx","valAx","sno","dataSeries","sx","ser","label","ptrn","pattern","range","catRange","dLbl","xlabel","font","genTxPrXML","genTitleXML","ylabel","xmlc","txtRun","xz_xlabc","xz_xlab","xz_xlabp","fontSize","xz_xlabpr","title_txt","bold","italic","value","fx","legend","txPr","txPrp","_name","newName","_id","_descr","desc","_extension","inWidth","_pxWidth","emu","inHeight","_pxHeight","module","exports"],"mappings":";;;;;;;;;;AAAA,IAAMA,UAAUC,QAAQ,cAAR,CAAhB;AACA,IAAMC,aAAaD,QAAQ,YAAR,CAAnB;AACA,IAAME,MAAMF,QAAQ,mBAAR,CAAZ;;eACuBA,QAAQ,MAAR,C;IAAXG,M,YAAJC,E;;IAEFC,K;;;AACF;;;;AAIA,mBAAYC,IAAZ,EAAkB;AAAA;;AAAA;;AAEd,cAAKC,IAAL,GAAY,OAAZ;AACA,cAAKC,IAAL,GAAY,2EAAZ;AACA,cAAKC,MAAL;AACA,cAAKC,SAAL,GAAiBJ,KAAKI,SAAtB;;AAEA,YAAI,CAAC,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;4BACQ;AACL,mBAAO,KAAKC,GAAZ;AACH,S;0BACMhD,E,EAAI;AACP,iBAAKgD,GAAL,GAAWhD,EAAX;AACH;;;4BAES;AACN,mBAAO,QAAQ,KAAKgD,GAApB;AACH;;;4BAEiB;AACd,mBAAO,KAAKC,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAKH,KAAjD;AACH,S;0BACeI,I,EAAM;AAClB,iBAAKD,MAAL,GAAcC,IAAd;AACH;;;4BAEW;AACR,mBAAO,KAAKjF,MAAL,KAAgB,IAAhB,GAAuB,KAAKA,MAA5B,GAAqC,KAAK6E,KAAjD;AACH,S;0BACSxC,K,EAAO;AACb,iBAAKrC,MAAL,GAAcqC,KAAd;AACH;;;4BAEe;AACZ,mBAAO,KAAK6C,UAAZ;AACH;;;4BAEW;AACR,gBAAIC,UAAU,KAAKC,QAAL,GAAgB,EAA9B;AACA,gBAAIC,MAAM,IAAI5F,GAAJ,CAAQ0F,UAAU,IAAlB,CAAV;AACA,mBAAOE,IAAIb,KAAX;AACH;;;4BAEY;AACT,gBAAIc,WAAW,KAAKC,SAAL,GAAiB,EAAhC;AACA,gBAAIF,MAAM,IAAI5F,GAAJ,CAAQ6F,WAAW,IAAnB,CAAV;AACA,mBAAOD,IAAIb,KAAX;AACH;;;;EAlEelF,O;;AA+RpBkG,OAAOC,OAAP,GAAiB7F,KAAjB","file":"chart.js","sourcesContent":["const Drawing = require('./drawing.js');\r\nconst xmlbuilder = require('xmlbuilder');\r\nconst EMU = require('../classes/emu.js')\r\nconst { v4: uuidv4 } = require('uuid');\r\n\r\nclass Chart extends Drawing {\r\n /**\r\n * Element representing an Excel Picture subclass of Drawing\r\n * @property {String} kind Kind of picture\r\n */\r\n constructor(opts) {\r\n super();\r\n this.kind = 'chart';\r\n this.type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart';\r\n this._title;\r\n this.chartData = opts.chartData;\r\n\r\n if (['oneCellAnchor', 'twoCellAnchor'].indexOf(opts.position.type) >= 0) {\r\n this.anchor(opts.position.type, opts.position.from, opts.position.to);\r\n } else if (opts.position.type === 'absoluteAnchor') {\r\n this.position(opts.position.x, opts.position.y);\r\n } else {\r\n throw new TypeError('Invalid option for anchor type. anchorType must be one of oneCellAnchor, twoCellAnchor, or absoluteAnchor');\r\n }\r\n }\r\n\r\n get name() {\r\n return this._name;\r\n }\r\n set name(newName) {\r\n this._name = newName;\r\n }\r\n get id() {\r\n return this._id;\r\n }\r\n set id(id) {\r\n this._id = id;\r\n }\r\n\r\n get rId() {\r\n return 'rId' + this._id;\r\n }\r\n\r\n get description() {\r\n return this._descr !== null ? this._descr : this._name;\r\n }\r\n set description(desc) {\r\n this._descr = desc;\r\n }\r\n\r\n get title() {\r\n return this._title !== null ? this._title : this._name;\r\n }\r\n set title(title) {\r\n this._title = title;\r\n }\r\n\r\n get extension() {\r\n return this._extension;\r\n }\r\n\r\n get width() {\r\n let inWidth = this._pxWidth / 96;\r\n let emu = new EMU(inWidth + 'in');\r\n return emu.value;\r\n }\r\n\r\n get height() {\r\n let inHeight = this._pxHeight / 96;\r\n let emu = new EMU(inHeight + 'in');\r\n return emu.value;\r\n }\r\n\r\n /**\r\n * @alias Picture.addToXMLele\r\n * @desc When generating Workbook output, attaches pictures to the drawings xml file\r\n * @func Picture.addToXMLele\r\n * @param {xmlbuilder.Element} ele Element object of the xmlbuilder module\r\n */\r\n addToXMLele(ele) {\r\n\r\n let anchorEle = ele.ele('xdr:' + this.anchorType);\r\n\r\n // if (this.editAs !== null) {\r\n // anchorEle.att('editAs', this.editAs);\r\n // }\r\n\r\n if (this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:pos').att('x', this._position.x).att('y', this._position.y);\r\n }\r\n\r\n if (this.anchorType !== 'absoluteAnchor') {\r\n let af = this.anchorFrom;\r\n let afEle = anchorEle.ele('xdr:from');\r\n afEle.ele('xdr:col').text(af.col);\r\n afEle.ele('xdr:colOff').text(af.colOff);\r\n afEle.ele('xdr:row').text(af.row);\r\n afEle.ele('xdr:rowOff').text(af.rowOff);\r\n }\r\n\r\n if (this.anchorTo && this.anchorType === 'twoCellAnchor') {\r\n let at = this.anchorTo;\r\n let atEle = anchorEle.ele('xdr:to');\r\n atEle.ele('xdr:col').text(at.col);\r\n atEle.ele('xdr:colOff').text(at.colOff);\r\n atEle.ele('xdr:row').text(at.row);\r\n atEle.ele('xdr:rowOff').text(at.rowOff);\r\n }\r\n\r\n if (this.anchorType === 'oneCellAnchor' || this.anchorType === 'absoluteAnchor') {\r\n anchorEle.ele('xdr:ext').att('cx', this.width).att('cy', this.height);\r\n }\r\n\r\n let graphicFrame = anchorEle.ele('xdr:graphicFrame');\r\n graphicFrame.att(\"macro\", \"\");\r\n let nvGraphicFramePr = graphicFrame.ele('xdr:nvGraphicFramePr');\r\n let cNvPrEle = nvGraphicFramePr.ele('xdr:cNvPr').att(\"id\", this.id).att(\"name\", \"Chart \" + this.id);\r\n // this.axExtId1 = uuidv4()\r\n // this.axExtId2 = uuidv4();\r\n\r\n // let extLst = cNvPrEle.ele(\"a:extLst\")\r\n // let aext = extLst.ele(\"a:ext\").att(\"uri\", this.axExtId1)\r\n // let a16creat = aext.ele(\"a16:creationId\").att(\"xmlns:a16\", \"http://schemas.microsoft.com/office/drawing/2014/main\")\r\n // a16creat.att(\"id\", this.axExtId2)\r\n nvGraphicFramePr.ele(\"xdr:cNvGraphicFramePr\").ele(\"a:graphicFrameLocks\");\r\n\r\n let xfrm = graphicFrame.ele(\"xdr:xfrm\")\r\n xfrm.ele(\"a:off\").att(\"x\", 0).att(\"y\", 0)\r\n xfrm.ele(\"a:ext\").att(\"cx\", 0).att(\"cy\", 0)\r\n\r\n let graphicData = graphicFrame.ele(\"a:graphic\").ele(\"a:graphicData\").att(\"uri\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n graphicData.ele(\"c:chart\").att(\"xmlns:c\", \"http://schemas.openxmlformats.org/drawingml/2006/chart\")\r\n .att(\"xmlns:r\", \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\")\r\n .att(\"r:id\", this.rId)\r\n\r\n anchorEle.ele('xdr:clientData');\r\n }\r\n\r\n chartPartXML(xmlcx) {\r\n xmlcx.ele('c:date1904').att('val', 0);\r\n xmlcx.ele('c:lang').att('val', 'en-US');\r\n xmlcx.ele('c:roundedCorners').att('val', 0);\r\n let xchart = xmlcx.ele('c:chart');\r\n let title = xchart.ele('c:title');\r\n let title_rich = title.ele('c:tx').ele('c:rich')\r\n title_rich.ele('a:bodyPr')\r\n title_rich.ele('a:lstStyle')\r\n let titlep = title_rich.ele('a:p');\r\n titlep.ele('a:pPr').ele('a:defRPr').att('sz', 1400)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let titlepr = titlep.ele('a:r')\r\n titlepr.ele(\"a:rPr\").att(\"sz\", 1400).att('lang', 'ar-SA')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n titlepr.ele('a:t', this.chartData.title)\r\n titlep.ele(\"a:endParaRPr\").att(\"sz\", 1400).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n title.ele(\"c:overlay\").att(\"val\", 1)\r\n\r\n xchart.ele(\"c:autoTitleDeleted\").att(\"val\", 0);\r\n\r\n let plotArea = xchart.ele(\"c:plotArea\")\r\n let layout = plotArea.ele(\"c:layout\")\r\n let ml = layout.ele('c:manualLayout')\r\n ml.ele('c:layoutTarget').att('val', 'inner')\r\n ml.ele('c:xMode').att('val', 'edge')\r\n ml.ele('c:yMode').att('val', 'edge')\r\n ml.ele('c:x').att('val', 0.1)\r\n ml.ele('c:y').att('val', 0.1)\r\n ml.ele('c:w').att('val', 0.75)\r\n ml.ele('c:h').att('val', 0.6)\r\n\r\n let barChart = plotArea.ele(\"c:barChart\")\r\n let catAx = plotArea.ele(\"c:catAx\")\r\n let valAx = plotArea.ele(\"c:valAx\")\r\n\r\n barChart.ele(\"c:barDir\").att(\"val\", \"col\")\r\n barChart.ele(\"c:grouping\").att(\"val\", \"clustered\")\r\n barChart.ele(\"c:varyColors\").att(\"val\", 0)\r\n for (var sno in this.chartData.dataSeries) {\r\n var sx = this.chartData.dataSeries[sno];\r\n // console.log(sno, sx)\r\n let ser = barChart.ele(\"c:ser\")\r\n ser.ele(\"c:idx\").att(\"val\", sno);\r\n ser.ele(\"c:order\").att(\"val\", sno);\r\n ser.ele('c:tx').ele('c:v', sx.label);\r\n let ptrn = ser.ele('c:spPr').ele('a:pattFill').att('prst', sx.pattern);\r\n\r\n ptrn.ele('a:fgClr').ele('a:schemeClr').att('val', 'tx1');\r\n ptrn.ele('a:bgClr').ele('a:schemeClr').att('val', 'bg1');\r\n ser.ele('c:invertIfNegative').att('val', 0)\r\n\r\n if (sx.range) {\r\n ser.ele('c:val').ele('c:numRef').ele('c:f', sx.range)\r\n }\r\n if (sx.catRange) {\r\n ser.ele('c:cat').ele('c:strRef').ele('c:f', sx.catRange);\r\n }\r\n // ser.ele('c:extLst').ele('xmlns:c16', 'http://schemas.microsoft.com/office/drawing/2014/chart')\r\n // .att('uri', this.axExtId1)\r\n // .ele('c16:uniqueId').att('val', this.axExtId2)\r\n }\r\n let dLbl = barChart.ele('c:dLbls');\r\n dLbl.ele('c:showLegendKey').att('val', 0)\r\n dLbl.ele('c:showVal').att('val', 0)\r\n dLbl.ele('c:showCatName').att('val', 0)\r\n dLbl.ele('c:showSerName').att('val', 0)\r\n dLbl.ele('c:showPercent').att('val', 0)\r\n dLbl.ele('c:showBubbleSize').att('val', 0)\r\n\r\n barChart.ele('c:gapWidth').att('val', 150)\r\n barChart.ele('c:axId').att('val', 361690304)\r\n barChart.ele('c:axId').att('val', 1)\r\n\r\n catAx.ele('c:axId').att('val', 361690304)\r\n catAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n catAx.ele('c:delete').att('val', 0)\r\n catAx.ele('c:axPos').att('val', 'b')\r\n catAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 0)\r\n catAx.ele('c:majorTickMark').att('val', 'out')\r\n catAx.ele('c:minorTickMark').att('val', 'none')\r\n catAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chartData.xlabel.font)\r\n catAx.ele('c:crossAx').att('val', 1)\r\n catAx.ele('c:crosses').att('val', \"autoZero\")\r\n catAx.ele('c:auto').att('val', 1)\r\n catAx.ele('c:lblAlgn').att('val', \"ctr\")\r\n catAx.ele('c:lblOffset').att('val', 100)\r\n catAx.ele('c:noMultiLvlLbl').att('val', 0)\r\n genTitleXML(catAx, this.chartData.xlabel)\r\n\r\n valAx.ele('c:axId').att('val', 1)\r\n valAx.ele('c:scaling').ele('c:orientation').att('val', 'minMax')\r\n valAx.ele('c:delete').att('val', 0)\r\n valAx.ele('c:axPos').att('val', 'l')\r\n valAx.ele('c:numFmt').att('formatCode', 'General').att('sourceLinked', 1)\r\n valAx.ele('c:majorTickMark').att('val', 'out')\r\n valAx.ele('c:minorTickMark').att('val', 'none')\r\n valAx.ele('c:tickLblPos').att('val', 'nextTo')\r\n valAx.ele('c:crossAx').att('val', 361690304)\r\n valAx.ele('c:crosses').att('val', \"autoZero\")\r\n valAx.ele('c:crossBetween').att('val', \"between\")\r\n genTitleXML(valAx, this.chartData.ylabel)\r\n\r\n function genTitleXML(xmlc, txtRun) {\r\n let xz_xlabc = xmlc.ele('c:title')\r\n let xz_xlab = xz_xlabc.ele('c:tx').ele('c:rich')\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n let xz_xlabpr = xz_xlabp.ele('a:r')\r\n let title_txt = xz_xlabpr.ele(\"a:rPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'ar-SA')\r\n title_txt.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) title_txt.att('b', txtRun.bold);\r\n if (txtRun.italic) title_txt.att('i', txtRun.italic);\r\n title_txt.att('baseline', 0)\r\n\r\n xz_xlabpr.ele('a:t', txtRun.value)\r\n xz_xlabp.ele(\"a:endParaRPr\").att(\"sz\", txtRun.fontSize * 100).att('lang', 'en-US')\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n xz_xlab.ele(\"c:overlay\").att(\"val\", 1)\r\n }\r\n\r\n function genTxPrXML(xmlc, txtRun) {\r\n let xz_xlab = xmlc.ele('c:txPr')\r\n\r\n xz_xlab.ele('a:bodyPr')\r\n xz_xlab.ele('a:lstStyle')\r\n let xz_xlabp = xz_xlab.ele('a:p');\r\n let fx = xz_xlabp.ele('a:pPr').ele('a:defRPr').att('sz', txtRun.fontSize * 100)\r\n fx.ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n if (txtRun.bold) fx.att('b', txtRun.bold);\r\n if (txtRun.italic) fx.att('i', txtRun.italic);\r\n }\r\n\r\n\r\n let legend = xchart.ele(\"c:legend\");\r\n legend.ele(\"c:legendPos\").att(\"val\", \"r\");\r\n legend.ele(\"c:overlay\").att(\"val\", \"0\");\r\n let txPr = legend.ele(\"c:txPr\"); txPr.ele(\"a:bodyPr\");\r\n txPr.ele(\"a:lstStyle\");\r\n let txPrp = txPr.ele(\"a:p\");\r\n txPrp.ele('a:pPr').ele('a:defRPr').att('sz', 1200)\r\n .ele('a:cs').att('typeface', 'Sakkal Majalla').att('pitchFamily', 2).att('charset', '-78')\r\n txPrp.ele(\"a:endParaRPr\").att('lang', 'en-US')\r\n xchart.ele(\"c:plotVisOnly\").att(\"val\", 1)\r\n xchart.ele(\"c:dispBlanksAs\").att(\"val\", \"gap\")\r\n xchart.ele(\"c:showDLblsOverMax\").att(\"val\", 0)\r\n }\r\n}\r\n\r\nmodule.exports = Chart;"]} \ No newline at end of file diff --git a/sample3.js b/sample3.js index ec36d705..7cb8ef32 100644 --- a/sample3.js +++ b/sample3.js @@ -510,7 +510,7 @@ if (aca_data.HonorsOrGraduates) { { label: 'العام السابق', pattern: 'smGrid', range: "'Sheet2'!$F$35:$F$39", catRange: "'Sheet2'!$B$35:$B$39" }, { label: 'العام الأسبق', pattern: 'wdDnDiag', range: "'Sheet2'!$H$35:$H$39", catRange: "'Sheet2'!$B$35:$B$39" }, ], - xlabel: { fontSize: 14, bold: 1, value: 'الوصف' }, + xlabel: { fontSize: 14, bold: 1, value: 'الوصف', font: {fontSize: 12, bold: 1} }, ylabel: { fontSize: 14, bold: 1, value: 'النسبة المئوية' } }, position: { diff --git a/source/lib/drawing/chart.js b/source/lib/drawing/chart.js index 2ea537c7..9def5255 100644 --- a/source/lib/drawing/chart.js +++ b/source/lib/drawing/chart.js @@ -219,7 +219,7 @@ class Chart extends Drawing { catAx.ele('c:majorTickMark').att('val', 'out') catAx.ele('c:minorTickMark').att('val', 'none') catAx.ele('c:tickLblPos').att('val', 'nextTo') - if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chart) + if(this.chartData.xlabel.font) genTxPrXML(catAx, this.chartData.xlabel.font) catAx.ele('c:crossAx').att('val', 1) catAx.ele('c:crosses').att('val', "autoZero") catAx.ele('c:auto').att('val', 1)