Skip to content

Instantly share code, notes, and snippets.

@natergj
Created February 13, 2018 00:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natergj/8089af76e795a09e20e04619f2447414 to your computer and use it in GitHub Desktop.
Save natergj/8089af76e795a09e20e04619f2447414 to your computer and use it in GitHub Desktop.
display cells as percentage in excel4node
var xl = require('excel4node');
var wb = new xl.Workbook();
var ws = wb.addWorksheet('test');
// Create a reusable style
var style = wb.createStyle({
numberFormat: '#.00%; -#.00%; -'
});
ws.cell(1,1).number(10).style(style); // displays as 1000.00%
ws.cell(2,1).number(1).style(style); // displays as 100.00%
ws.cell(3,1).number(.1).style(style); // displays as 10.00%
ws.cell(4,1).number(.001).style(style); // displays as .10%
wb.write('NumFormat.xlsx');
@matthijn
Copy link

Gracias

@gal664
Copy link

gal664 commented Nov 15, 2018

nice! helped me there

@caiomoura1994
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment