rikkertkoppes / json2xls

canonically transform json to an excel document
278 stars 85 forks source link

Problem with downloaded file #18

Open swinston100 opened 8 years ago

swinston100 commented 8 years ago

When I try to read a file downloaded using your module (using the npm package XLXS and specifically XLSX.utils.sheet_to_json) there is is no data read. However if I make a change to the file, undo the change and then save the file the data is read correctly. I noticed the file size changed so I looked at the xlsx package a little closer and I see that:

1) The Bad File has a path and a file at package/services/metadata/core-properties where the Working file does not.

2) The Bad file has no docprops/core.xml and the good file does.

3) _rels.rels are different

Bad

<?xml version="1.0" encoding="UTF-8"?>

-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">

<Relationship Id="R4aa22b31a1a74291" Target="/xl/workbook.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"/>

<Relationship Id="rId1" Target="/docProps/app.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"/>

<Relationship Id="Ref487c3e0c744a87" Target="/package/services/metadata/core-properties/ecfdd3143f21489095a44c71115b723b.psmdcp" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"/>

</Relationships>

Good

 <?xml version="1.0" encoding="UTF-8" standalone="true"?>

-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">

<Relationship Target="docProps/app.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Id="rId3"/>

<Relationship Target="docProps/core.xml" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Id="rId2"/>

<Relationship Target="xl/workbook.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Id="rId1"/>

</Relationships>

4) app.xml is also different and there may also be more differences but at the point maybe I'm best just sending you the files??

Hope this makes sense and thanks so much!

Steven

rikkertkoppes commented 8 years ago

json2xls uses https://github.com/functionscope/Node-Excel-Export and adds very little excel options of its own, so I think the problem would be there.

Can you try recreating it in steps to see where it fails (this is basically what json2xls does under the hood):

First create the Node-Excel-Export config:

var conf = json2xls.prepareJson(json)

Then put that in Node-Excel-Export

var nodeExcel = require('excel-export');
var result = nodeExcel.execute(conf);

Could you post the conf that has been generated in this way?

swinston100 commented 8 years ago

Hi @rikkertkoppes Sorry for the delay! Here is a copy of the conf (strigified so I could write to file)

{"cols":[{"caption":"Date","type":"number"},{"caption":"Account Name","type":"string"},{"caption":"Sold Imps","type":"number"},{"caption":"Total Imps","type":"number"},{"caption":"Revenue (Pub)","type":"string"}],"rows":[[42554,"HeightsMedia US",49046,1634110,"20.511736"],[42555,"HeightsMedia US",24459,1412446,"12.07332"],[42556,"HeightsMedia US",5280,188523,"2.0369999999999995"],[42557,"HeightsMedia US",9584,493658,"5.248712"],[42558,"HeightsMedia US",2,55,"0"],[42559,"HeightsMedia US",1303,40447,"0.8827839999999999"],[42560,"HeightsMedia US",23309,387501,"5.602239999999999"],[42561,"HeightsMedia US",37910,523017,"8.668295999999998"],[42562,"HeightsMedia US",22684,584438,"6.860112"],[42563,"HeightsMedia US",18651,1172451,"9.040639999999998"],[42564,"HeightsMedia US",28389,722026,"10.986023999999999"],[42565,"HeightsMedia US",2031,67438,"0.680176"],[42566,"HeightsMedia US",29143,347158,"4.413976"],[42567,"HeightsMedia US",39857,753044,"14.862568"],[42568,"HeightsMedia US",48260,616365,"17.181136"],[42569,"HeightsMedia US",24481,1094087,"9.572807999999998"],[42570,"HeightsMedia US",86326,1212199,"29.162951999999994"],[42571,"HeightsMedia US",16064,209628,"5.180783999999999"],[42572,"HeightsMedia US",178764,2114376,"65.179016"],[42573,"HeightsMedia US",45262,619349,"15.144471999999999"],[42574,"HeightsMedia US",182901,830129,"69.724256"],[42575,"HeightsMedia US",70571,291284,"30.168823999999997"],[42576,"HeightsMedia US",3153,7098,"0.23828000000000002"],[42577,"HeightsMedia US",19040,31386,"1.0562159999999998"],[42552,"HeightsMedia US",8793,502652,"5.101656"],[42553,"HeightsMedia US",33217,1550103,"12.922"]]}

Thanks!

PS - Is it possible to transpose the contents of a sheet so instead of creating a table of columns it would make a table of rows???