0

I have a code like below (using XLSX javascript ) where I need Cell numeric value have right alignment, magnitude commas and 2 decimals. Its working for magnitude commas and 2 decimals, but I am facing issue for cell value right alignment, Can any one help me on this.

var xls1_name = 'xlsheet_'+(new Date()).toLocaleDateString('en-us').replace(/[\-\:\.]/g, "")+'_'+(new Date()).toLocaleTimeString().replace(/[\-\:\.]/g, "")+'.xlsx';

            var xls1 = XLSX.utils.table_to_book(document.getElementById('xls1'), {sheet:"xlsheet"});

            var ws = xls1.Sheets.xlsheet;
            let range = XLSX.utils.decode_range(ws['!ref']);
            var cellNumberFormat = '#,##0.00';
            var colsFmt = ['H','I','J','K','L','M','O','Q','S','N','T','U','V','W'];

            if( range.e.r > 1) {

                for ( let i = 3; i <= range.e.r+1; i++) {

                    for ( var idx = 0; idx < colsFmt.length; idx++)  {
                        ws[colsFmt[idx]+i].z = cellNumberFormat;
                    }

                }
            }

            return XLSX.writeFile(xls1, xls1_name);

1 Answers1

0

Some of the features are not available in open sources. please read below articles

articles:

https://github.com/SheetJS/sheetjs/issues/1050

https://gist.github.com/SheetJSDev/24b8acd317d01999d721b38de7c53021