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 :
Microsoft Dynamics AX (Archived)

Exporting data into excel file

(0) ShareShare
ReportReport
Posted on by 2,486

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

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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.

  • Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    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.

  • Mohammad Raziq Ali Profile Picture
    2,486 on at

    I am exporting table data into excel using SysExcelXXX classes.

  • Mohammad Raziq Ali Profile Picture
    2,486 on at

    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

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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.

  • Verified answer
    Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    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;
    }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans