Big number is showing exponential value after upload to CSV using Angular2Csv library

143 views
Skip to first unread message

vishnu siddareddy

unread,
Aug 8, 2018, 7:27:26 AM8/8/18
to Angular and AngularJS discussion

I am using Angular2Csv library for upload JSON data to CSV form. But the big number is showing in exponential format in excel sheet.

Number 3530123456789010 becomes like, 3.53012E+15

Is there any solution to avoid that?


exportToCSV = function (dataobj) {    
const options = {
          fieldSeparator: ',',
          quoteStrings: '"',
          decimalseparator: '.',
          showLabels: true,
          showTitle: true,
          headers: Object.keys(dataobj.data[0])
        };
       // console.log(JSON.stringify(data));
       new Angular2Csv(dataobj.data, 'My Report', options);
}



abhay dhar

unread,
Aug 8, 2018, 7:35:07 AM8/8/18
to Angular and AngularJS discussion
Thats a normal issue i ncsv/excel. Try opening a blank document in excel and put the number 3530123456789010  it will change to Exp format

I think you should check if you can specify the type of column or cell type , so that csv can properly format and hold the data

Charul Chavda

unread,
Aug 8, 2018, 10:12:27 AM8/8/18
to ang...@googlegroups.com
Hi,

Change data type of your big number as string and not number, should resolve the issue 

Regards,
Charul
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Lucas Lacroix

unread,
Aug 8, 2018, 10:16:48 AM8/8/18
to ang...@googlegroups.com
I just want to say:
This is not an issue with Angular but a limitation of Javascript. Javascript uses double floating point numbers internally which means you're limited to that formats precision for integer:

This is a limitation of the standard and not specific to Angular or any plugin/addon.


On Wed, Aug 8, 2018 at 10:12 AM Charul Chavda <charu...@gmail.com> wrote:
Hi,

Change data type of your big number as string and not number, should resolve the issue 

Regards,
Charul

On Wednesday, August 8, 2018, vishnu siddareddy <vishnu...@gmail.com> wrote:

I am using Angular2Csv library for upload JSON data to CSV form. But the big number is showing in exponential format in excel sheet.

Number 3530123456789010 becomes like, 3.53012E+15

Is there any solution to avoid that?


exportToCSV = function (dataobj) {    
const options = {
          fieldSeparator: ',',
          quoteStrings: '"',
          decimalseparator: '.',
          showLabels: true,
          showTitle: true,
          headers: Object.keys(dataobj.data[0])
        };
       // console.log(JSON.stringify(data));
       new Angular2Csv(dataobj.data, 'My Report', options);
}



--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
--
Lucas Lacroix
Computer Scientist
Advanced Technology Division, MEDITECH

                
Subscribe to receive emails from MEDITECH or to change email preferences.

vishnu siddareddy

unread,
Aug 8, 2018, 10:27:13 AM8/8/18
to ang...@googlegroups.com
But the value is coming from server. Can u please tell where I can able change the type?

On Wed, Aug 8, 2018, 7:42 PM Charul Chavda <charu...@gmail.com> wrote:
Hi,

Change data type of your big number as string and not number, should resolve the issue 

Regards,
Charul

On Wednesday, August 8, 2018, vishnu siddareddy <vishnu...@gmail.com> wrote:

I am using Angular2Csv library for upload JSON data to CSV form. But the big number is showing in exponential format in excel sheet.

Number 3530123456789010 becomes like, 3.53012E+15

Is there any solution to avoid that?


exportToCSV = function (dataobj) {    
const options = {
          fieldSeparator: ',',
          quoteStrings: '"',
          decimalseparator: '.',
          showLabels: true,
          showTitle: true,
          headers: Object.keys(dataobj.data[0])
        };
       // console.log(JSON.stringify(data));
       new Angular2Csv(dataobj.data, 'My Report', options);
}



--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Charul Chavda

unread,
Aug 9, 2018, 12:41:39 AM8/9/18
to ang...@googlegroups.com
U need to ask ur backend to give it u as astring as this is js limitation. I did the same long back.

Regards,
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

vishnu siddareddy

unread,
Aug 9, 2018, 12:43:42 AM8/9/18
to ang...@googlegroups.com
Thanks, I will ask them to give as string.

To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages