web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Importing the data of Excel into a specific table through X++

(0) ShareShare
ReportReport
Posted on by

Hi,

sir please give a details brief coding of how to enter the data of Excel into Specific table that are customized table or the live table of Dynamics AX 2012 R2.

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    304,508 Super User 2026 Season 1 on at

    Hi Jamil,

    What is the exact business requirement here? It would be possible to use Data Import/Export Framework to import data from Excel if you have created a target data entity for your custom(ized) table or modified an existing entity in case there is already an entity and you have added new fields.

  • Suggested answer
    BrandonSA Profile Picture
    1,673 on at
  • Community Member Profile Picture
    on at

    Sir actually the requirements are this, that Import the data that are in the excel file into AX.

  • André Arnaud de Calavon Profile Picture
    304,508 Super User 2026 Season 1 on at

    Hi Jamil,

    You can use above mentioned options (from Brandon and me) to import data from Excel. If it is related to a certain process which should be run by a user, the solution might be a bit different, depending on the needs. But I haven't seen such requirement in your answer.

  • Community Member Profile Picture
    on at

    How to import excel data in the table having allow duplicate property "NO".

    Like CustTable

  • Community Member Profile Picture
    on at

    I have an error of

    Cannot create a record in Customers (CustTable).

    The record already exists.

    but the feild is also empty but the data is not entering into the field of CustTable.

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hello Jamil,

    Can you describe what has been done exactly and share details of the error message?

    Many thanks

    Ludwig

  • Community Member Profile Picture
    on at

    Actually the data is not importing in the custTable as I Have Info also but the result is not Okie

    Code Is

    Public void  JamilsJob(Args _args)

       {

       dialog          dialog;

       Filename        filename;

       DialogField     dialogFilename;

       //Excel variables

       SysExcelApplication application;

       SysExcelWorkbooks   workbooks;

       SysExcelWorkbook    workbook;

       SysExcelWorksheets  worksheets;

       SysExcelWorksheet   worksheet;

       SysExcelCells             cells;

       COMVariantType      type;

           //Common Variables

           int             row;

           CustTable       Cust;

          // str             BankCentralBankPurposeText;

           //str             IdentificationNumber;

            str         CustGroupName ;

           str             BankAccountNumber;

       dialog = new Dialog("Excel Upoad");

       dialogFilename = dialog.addField(extendedTypeStr(FileNameOpen));

       dialog.filenameLookupTitle("Upload from Excel");

       dialog.caption("Excel Upload");

       dialogFilename.value(filename);

       if(!dialog.run())

       return;

       filename = dialogFilename.value();

       application = SysExcelApplication::construct();

       workbooks = application.workbooks();

       try

       {

           workbooks.open(filename);

       }

       catch (Exception::Error)

       {

           throw error("File cannot be opened.");

       }

       workbook = workbooks.item(1);

       worksheets = workbook.worksheets();

       worksheet = worksheets.itemFromNum(1); //Here 1 is the worksheet Number

       cells = worksheet.cells();

           do

       {

           row++;

           CustGroupName      = cells.item(row, 1).value().bStr();

           BankAccountNumber  = cells.item(row, 2).value().bStr();

           Cust.BankCentralBankPurposeText  = CustGroupName;

           Cust.IdentificationNumber = BankAccountNumber;

           info(strFmt("%1 - %2 - Desc",Cust.BankCentralBankPurposeText,Cust.IdentificationNumber));

           Cust.insert();

           type = cells.item(row+1, 1).value().variantType();

           //info(strFmt("%1 - %2 - Desc",cells.item(row, 2).value().bStr(),Cust.BankCentralBankPurposeText));

       }

       while (type != COMVariantType::VT_EMPTY);

       application.quit();

       info('Done');

    }

    and the Reult come after running this

    Info also mot Giving me the result

    CustGroupName - BankAccountNumber - Desc

  • Suggested answer
    BrandonSA Profile Picture
    1,673 on at

    HI Jamil

    That means that your Excel code is probably working correctly.

    What's NOT working is the way that CustTable is being populated. You're trying to create a CustTable record that already exists.

    Have a look at the unique indexes on CustTable to see what keys are unique, and then use the debugger to find out which one of them is being duplicated.

    Also, is the AccountNum being populated correct?

    Before you populate your custTable record with anything, call cust.initvalue(); as well.

  • André Arnaud de Calavon Profile Picture
    304,508 Super User 2026 Season 1 on at

    Like Brandon mentioned, the AccountNum should get a unique value, but also the Party field should have a unique value which corresponds with a DirPartyTable record.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans