Created
January 5, 2018 06:39
-
-
Save engalar/02aef290034fb180d866d721bbac9658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jszip = require('xlsx/jszip'); | |
const fs = require('fs'); | |
const XmlDocument = require('xmldoc').XmlDocument; | |
function get_rels_path(file) { | |
var n = file.lastIndexOf("/"); | |
return file.substr(0,n+1) + '_rels/' + file.substr(n+1) + ".rels"; | |
} | |
const filename = 'C:\\Users\\Administrator\\Desktop\\Book1.xlsx'; | |
const zip = new jszip(fs.readFileSync(filename)); | |
const xmlDocumentSheet = new XmlDocument(zip.files["xl/worksheets/sheet1.xml"].asBinary()); | |
const xmlDocumentRel = new XmlDocument(zip.files[get_rels_path("xl/worksheets/sheet1.xml")].asBinary()); | |
const attr = xmlDocumentSheet.childNamed('drawing').attr["r:id"]; | |
const attr2 = xmlDocumentRel.childNamed('Relationship').attr["Id"]; | |
const attr3 = xmlDocumentRel.childNamed('Relationship').attr["Target"]; | |
const xmlDocumentDraw = new XmlDocument(zip.files[attr3.replace('..','xl')].asBinary()); | |
const map = xmlDocumentDraw.children.map(v=>v.childNamed('xdr:from').childNamed('xdr:row').val); | |
console.log(map); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment