Skip to content

Instantly share code, notes, and snippets.

@natergj
Created February 21, 2018 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natergj/f6a039a268436a783870be322f835804 to your computer and use it in GitHub Desktop.
Save natergj/f6a039a268436a783870be322f835804 to your computer and use it in GitHub Desktop.
display currency in Indian format in excel4node
var xl = require('excel4node');
var wb = new xl.Workbook();
var ws = wb.addWorksheet('test');
var indianCurrency = wb.createStyle({
numberFormat: '[>=10000000]"RS "##\\,##\\,##\\,##0;[>=100000]"RS "\\ ##\\,##\\,##0;"RS "##,##0',
});
ws.column(1).setWidth(15);
ws.cell(1,1).number(12.34).style(indianCurrency); // displays as "RS 12"
ws.cell(2,1).number(1234.56).style(indianCurrency); // displays as "RS 1,235"
ws.cell(3,1).number(12345.67).style(indianCurrency); // displays as "RS 12,346"
ws.cell(4,1).number(1234567.89).style(indianCurrency); // displays as "RS 12,34,568"
ws.cell(5,1).number(123456789.01).style(indianCurrency); // displays as "RS 12,34,56,789"
wb.write('NumFormat.xlsx');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment