Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to pad the fields with spaces being exported to excel

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

I have a requirement to export data to excel. This is all fine.

But the problem is it should of fixed lenght excel lines and if the respective data from Ax is less than the intended length it should be padded with spaces to reach the length.

Can anyone help on this.

I am able to create a field with all spaces and export to excel. But coudld'nt get this padding of spaces work.

Thanks

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pad the fields with spaces being exported to excel

    In this scenario, it can not be a excel import.

    you need to create a fixed width text file

    so you sould consider AsciiIO class for this purpose

    and for each column you need to check and see it the field is having space and Zeros padded

    Please find more details about AsciiIo class in following link

    msdn.microsoft.com/.../asciiio.aspx

    please verify and let us know with your findings

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pad the fields with spaces being exported to excel

    Hi All,

    Thanks for your responses.

    I am exporting the data from AX to import into another system for data integration.

    To import this into the other application the excel need to satisfy the below criteria -

    "Each line in the interface file has a fixed length of 307 characters. Any fields not populated or not using all allocated characters must be padded with spaces (if defined as character fields) or zeroes (if defined as numeric).   "

    So each column is already allocated fixed space. If the data from Ax falls short of this I need to get this padded with spaces.

    I am using SysExcelApplication to create the output excel file.

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to pad the fields with spaces being exported to excel

    What is the purpose of this requirement

    are you looking to manage the width of excel cell this padding of spaces?

    if yes then its not possible this way...

    for this purpose while exporting values to excel cell, you need to set the width of the excel cell

    Please verify and update us with more details.

  • Denis Macchinetti Profile Picture
    Denis Macchinetti 16,444 on at
    RE: How to pad the fields with spaces being exported to excel

    Hi

    What do you use for create the XLS file?

    COM Classes?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans