web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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 364

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

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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

  • Venkatdax0 Profile Picture
    364 on at

    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.

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    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

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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("@");

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 467 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans