Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Exporting data into excel file

(0) ShareShare
ReportReport
Posted on by 2,474

Hi All,

I am exporting data into excel.

The execution time to export data is lengthy. so, it is throwing errors or closing AX client abruptly.

Is there any work around for this issue.

Sometimes, It is throwing error as follows though code is correct.

"The number of arguments provided is different from the number of arguments accepted by the method."

Thanks,

Raziq.Ali

*This post is locked for comments

  • Verified answer
    Anton Venter Profile Picture
    19,614 Super User 2025 Season 1 on at
    RE: Exporting data into excel file

    That's exactly what I mean. The data is exported to a CSV file. When the data export is finished, convert the CSV file to XLS. See code below, it converts XLS to CSV but you can modify it to convert CSV to XLS.

    //avent use the Windows Region List Separator value
    public client static void convertXLS2CSV(FileName   _fileNameXLS,
                                             Filename   _fileNameCSV)
    {
        #File
        #Excel
    
        SysExcelApplication excel;
        SysExcelWorkBooks   books;
    
        if (strLen(_fileNameXLS) == 0)
            throw error("Excel file name parameter is invalid.");
    
        if (WinAPI::fileExists(_fileNameXLS) == false)
            throw error(strFmt("The file '%1' already exists.", _fileNameXLS));
    
        if (WinAPI::fileExists(_fileNameCSV))
            WinAPI::copyFile(_fileNameCSV, strFmt('%1~', _fileNameCSV), true);
    
        excel = SysExcelApplication::construct();
        excel.displayAlerts(false);
    
        books = excel.workbooks();
        books.open(_fileNameXLS);
    
        books.item(1).saveAs(_fileNameCSV, #xlCSV);
        excel.quit();
    
        excel = null;
        books = null;
    }
  • Verified answer
    Martin Dráb Profile Picture
    233,258 Most Valuable Professional on at
    RE: Exporting data into excel file

    Yes, these classes use COM objects. It's a useful tool for manipulating Excel spreadsheets at runtime, but a poor choice for large data exports.

  • Mohammad Raziq Ali Profile Picture
    2,474 on at
    RE: Exporting data into excel file

    As you said, If I export into csv format then excel.

    can you elaborate "convert the text file to a real Excel file at the end"?

    I want data to be separated by column wise but not by comma.

    Thanks,

    Raziq.Ali

  • Mohammad Raziq Ali Profile Picture
    2,474 on at
    RE: Exporting data into excel file

    I am exporting table data into excel using SysExcelXXX classes.

  • Anton Venter Profile Picture
    19,614 Super User 2025 Season 1 on at
    RE: Exporting data into excel file

    Hi, I assume you are using the SysExcelXXX classes to export the data. If you export the data to a text file and convert the text file to a real Excel file at the end, it will be a lot faster. This can be done exporting to CSV.

  • Martin Dráb Profile Picture
    233,258 Most Valuable Professional on at
    RE: Exporting data into excel file

    How are you exporting data to Excel?

    Based on the error, I guess you're using using COM objects, which indeed isn't very efficient solution. You'll get much better performance from the Data Import Export Framework.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 46

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans