protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
826 stars 416 forks source link

it is not keeping styles... #12

Closed almottier closed 8 years ago

almottier commented 8 years ago

I don't understand, i installed using : npm install xlsx-style

my nodejs script is as simple as this :

var xlsx = require('xlsx-style'); var workbook = xlsx.readFile('template.xlsx'); xlsx.writeFile(workbook, 'out.xlsx'); console.log('Finished');

But all the styles disappeared. Am I missing something ? Thanks

VincentGuinaudeau commented 8 years ago

yes, that something i run into a month ago.

I'm not sure that my solution is the best, but i workaround this by turing on the cellStyles attribute on the parsing.

var xlsx = require('xlsx-style');
var workbook = xlsx.readFile('template.xlsx', {cellStyles: true});
xlsx.writeFile(workbook, 'out.xlsx');
console.log('Finished');

By doing this, all the style will by insert in the cell, instead of being list in another part of the workbook.

pietersv commented 8 years ago

Exactly, {cellStyles: true} is right. That's inherited from the parent project.