Hi All,
Is it possible to format an excel cell to 'Text' before exporting data to excel by x++ code?
For example, a String field value stored in AX as 000011 should be exported to excel without omitting 0's.
Below code only exports 11 to the excel cell without the 0's.
xlsWorkSheet.cells().item(row,1).value(xxxx.abc);
Any help is much appreciated.
Thank you
Hi Raghavendra,
Actually when you export data to excel, text will remain text, numbers will remain numbers, you could open the excel with text to check.
Did you try to change the format of the cells to text?
Thanks Will. But any idea how we could go about this when the field length is not fixed?
Hi Raghavendra,
Is the length of your field fixed?
You could try to set the format like this in Excel.
Hi Will,
Thanks for your response.
Yes the field mentioned is a String field in AX. Let's say the field has data like 000123, 000011, XYZ etc.
I have below concerns:
1. Formatting the cell to TEXT in excel after data is exported won't bring back the 0's.
2. I have referred to the link you shared above. It mainly focuses on number formatting and other type conversions used to extract the data needed to file.
In my case, I don't need any type conversion as the field is STRING.
Please help me if you know how to format the column to TEXT by x++ code before extracting data?
xlsWorkSheet.cells().range(strFmt("H%1:H%1",row)).numberFormat("00000000000000");
Can the above be somehow applied to TEXT formatting? I tried but to no avail.
Thanks
Hi Raghavendra,
What's type of the field "xxxx.abc"?
If it is a string field, you just need to set the format of the column in Excel.
https://community.dynamics.com/ax/b/hellodax/posts/formating-cells-when-export-to-excel-example-code
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156