Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to handle number formatting for credit card number when exporting to excel in AX 2012

(0) ShareShare
ReportReport
Posted on by 362

Hello all,

I am trying to export the customer credit card number to excel and facing the below number formatting issue,

The value i should be exporting is - Credit card number: 5432000000000076, but when i see the exported value in excel, it is changed to 5432000000000000.

In the troubleshooting i found that as the credit card number field is of type String, the value is changed in the excel. And to handle this i have first converted the value to int64 / num(using str2int64() / str2num()) and provided the number formatting as shown below.

creditCardNumber = str2int64(creditCardCustNumber.CreditCardNumber);

xlsRange = xlsWorkSheet.get_Range(F1,F1);
xlsRange.set_NumberFormat("0000000000000000");
this.assignCellValue(xlsWorksheet,row,6,creditCardNumber);

Still i am not able to achieve the expected results and the value is exported as  5432000000000070. Request you all to help me in resolving this issue.

Also am afraid to fix the length in the number formatting and let me know if their are any alternative. Thank you!!

Regards,

Venkat

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to handle number formatting for credit card number when exporting to excel in AX 2012

    Hi Venkat,

    Can you change cell format from x++? If yes, try to pass value '@' to NumberFormat, it should set cell format to text

    xlsRange.set_NumberFormat("@");

  • Suggested answer
    vinitgoyal2005 Profile Picture
    vinitgoyal2005 6,330 on at
    RE: How to handle number formatting for credit card number when exporting to excel in AX 2012

    HI Venkat,

    You can use simple str int2Str(int integer) function to convert number to strring. Please check all the conversions on docs.microsoft.com/.../xpp-conversion-run-time-functions

  • Venkatdax0 Profile Picture
    Venkatdax0 362 on at
    RE: How to handle number formatting for credit card number when exporting to excel in AX 2012

    Hi Sergei,

    Thank you for your reply, cant we text format the field value using code while we are exporting the value to excel.

    In the article we are formatting the cell values in the excel and am restricted to do it.

    Please help me with a sample code to text format the String field which has numbers. Thank you.

    Venkat.

  • Verified answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to handle number formatting for credit card number when exporting to excel in AX 2012

    Hi Vendkatdax0,

    You need to use text format instead of number format (check section about card number in the article below)

    support.microsoft.com/.../keeping-leading-zeros-and-large-numbers-1bf7b935-36e1-4985-842f-5dfa51f85fe7

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans