Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Excel
* @author Satoshi Haga
* @date 2016/03/27
*/
const Promise = require('bluebird');
const xml2js = require('xml2js');
const parseString = Promise.promisify(xml2js.parseString);
const builder = new xml2js.Builder();
const _ = require('underscore');
require('./underscore');
const config = require('./Config');
let Excel = require('jszip');
_.extend(Excel.prototype, {
//read as encoded strings
sharedStrings: function() {
return this.file(config.EXCEL_FILES.FILE_SHARED_STRINGS).asText();
},
parseSharedStrings: function() {
return this.parseFile(config.EXCEL_FILES.FILE_SHARED_STRINGS);
},
//save with xml-encoding
setSharedStrings: function(obj) {
if(obj) {
this.file(config.EXCEL_FILES.FILE_SHARED_STRINGS, builder.buildObject(obj));
}
return this;