UNPKG

hy_excelize

Version:

买菜用。感谢:https://github.com/zurmokeeper/excelize.git

75 lines (64 loc) 2.19 kB
const BaseXform = require('../base-xform'); const EtcCellImageXform = require('./etc-cellImage-xform'); const XmlStream = require('../../../utils/xml-stream'); class EtcCellImagesXform extends BaseXform { constructor() { super(); this.map = { 'etc:cellImage': new EtcCellImageXform(), }; } render(xmlStream, model) { xmlStream.openXml(XmlStream.StdDocAttributes); xmlStream.openNode('etc:cellImages', EtcCellImagesXform.CELLIMAGES_ATTRIBUTES); model.forEach(cellImage => { this.map['etc:cellImage'].render(xmlStream, cellImage); }); xmlStream.closeNode(); } parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case 'etc:cellImages': this.model = []; return true; default: this.parser = this.map[node.name]; if (this.parser) { this.parser.parseOpen(node); return true; } throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`); } } parseText(text) { if (this.parser) { this.parser.parseText(text); } } parseClose(name) { if (this.parser) { if (!this.parser.parseClose(name)) { this.model.push(this.parser.model); this.parser = undefined; } return true; } switch (name) { case 'etc:cellImages': return false; default: throw new Error(`Unexpected xml node in parseClose: ${name}`); } } } EtcCellImagesXform.CELLIMAGES_ATTRIBUTES = { 'xmlns:a': 'http://schemas.openxmlformats.org/drawingml/2006/main', 'xmlns:etc': 'http://www.wps.cn/officeDocument/2017/etCustomData', 'xmlns:r': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', 'xmlns:xdr': 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing' }; module.exports = EtcCellImagesXform;