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, ...
Suggested Answer

Import from Excel to a table using x++

(0) ShareShare
ReportReport
Posted on by 10

Good day! I am new to x++ and I need to implement importing data from an Excel file (xlsx) to my own table. Data Management is not an option neither is Excel Add-in since I need to implement it within my own form. I have tried this guide: https://dynamicsaxtechnicalstuff.blogspot.com/2018/07/import-upload-data-in-d365ax7-using.html but this didn't quite work out for me.

- Firstly, the FileUpload I added within my form design doesn't appear when I open the environment in my browser but it does appear on the preview within Visual Studio. Any idea what could the problem be here? I have built, synced and refreshed my environment over a dozen times already.


- Second, when I override the "clicked" method of the "OKButton" as stated in the said tutorial/guide, the dialog does not load at all and gets stuck loading once I click the menu item that points to it. 

What I currently have in my form is a button that supposedly pops up a dialog wherein I can upload my Excel file then once done uploading, data from the Excel file must be present in the table where it is supposed to be.

Any suggestions or useful references? Any help would be much appreciated. Thank you!

I have the same question (0)
  • Mariano Gracia Profile Picture
    on at

    If DMF is not an option, then I'd recommend you to use ClosedXML you'll have to compile it and add it to Dynamics 365 as a reference, then you can use a SysOperation class to upload the file, read it as an stream and  use ClosedXML to read that stream. I've use it to read or create Excel sheets with rich format with satisfactory results.

    The code should be something like that:

    private void processData()
    {        
        ClosedXMLReadExcel   closedXMLReadExcel;
        ItemId                  itemIdField;
        transDate               transDateField;
        Price                   priceField;
        FileUploadTemporaryStorageResult    fileUpload = dataContract.parmFileUploadResult();
    
        System.IO.Stream stream     = fileUpload.openResult();
        closedXMLReadExcel          = GVCClosedXMLReadExcel::construct(stream);
    
        closedXMLReadExcel.setWorkSheetByName(workSheetName, rowNumber);
    
        while (closedXMLReadExcel.readNextRow())
        {
            [itemIdField, transDateField, priceField] = closedXMLReadExcel.getValuesFromCurrentRow(3);
    
            //do something
        }
    }

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,158 Super User 2025 Season 2 on at

    Hi Boost,

    Can you tell why you are not able to use the standard options? Probably, you have a custom table. In that case, you can create new data entities which would enable your table to be accessed by data management and the Excel add-in.

    I haven't implemented the example myself, so not sure what might be wrong in your environment. I would suggest to look at places where Dynamics 365 has options to upload files, like the task recorder and data management. Then you can reverse-engineer how Microsoft created the file upload dialogs.

  • boost Profile Picture
    10 on at

    Appreciate it man. Will take a look on this. Thanks!

  • boost Profile Picture
    10 on at

    Hi!! Thanks for you reply. I do have a custom table. The thing is, I really need to implement it within the a custom form that displays the contents of the said custom table and not on another workspace/module.

    Also, I literally have tried to copy and paste the design of the upload dialog from Data Management into my own while making sure each property was the same (except for the data sources and other things related to the Data Management Form). It showed every element in the design... except for the file upload! How frustrating!

    Thanks for mentioning the task recorder by the way, I will look into that too. And maybe I will also try creating another project to test the same things out, maybe something really is broken in my environment/project.

  • André Arnaud de Calavon Profile Picture
    301,158 Super User 2025 Season 2 on at

    Hi boost,

    I wanted to check if you made some progress? Can you provide us with an update? Did you find a solution or do you still need some more help from the community?

  • Suggested answer
    WillWU Profile Picture
    22,363 on at

    Hi boost,

    Do you still not see the control in the form? Can you get any error message?

    Please provide more details about your operation.

    And please check Martin's blog:

    dev.goshoom.net/.../

  • boost Profile Picture
    10 on at

    Hi. Sorry I wasn't able to update on this post. All of a sudden the dialog appeared okay once I pulled an updated version from me and my colleague's repo in Azure DevOps. However, my colleague just updated some code that is unrelated to this dialog but it did had some errors before. Maybe the errors present in his code had an effect with our project being built and compiled properly. Thank you all for your inputs, I very much appreciate it!

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... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans