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)

Update data from Excel

(0) ShareShare
ReportReport
Posted on by 282

Hi,

    I am trying to update table data from Excel using X++ code... So n1 have experienced on that..

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    5400 Profile Picture
    7,162 on at

    Please find the link. Do you have any specific question.

    erpdax.wordpress.com/.../importing-multiple-salesorders-multiple-saleslins-from-excel

    http://axpedia.blogspot.in/2013/02/import-from-excel-file-using-x-in-ax.html

  • Amol@ Profile Picture
    282 on at

    Thanks frnd...

  • Amol@ Profile Picture
    282 on at

    But i want only update field in Table  from Excel..means In table i added new field and insert data in that field into excel..

    in Table

    InvoiceId       ItemId    NewField

    123                321

    456                654

    in Excel

    invoiceId       ItemId     NewField

    123                 321          xyz

    456                 654          abc

    So i want only update this field (NewField into Table)...bt related to their InvoiceId and ItemId...

    Replay is appreiciated..

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Amol,

    Find below a sample:

    tinyurl.com/npelqyw

    You can search the specific data and update by modifying the code.

  • 5400 Profile Picture
    7,162 on at

    Please create one excel with primary key value and read the new field value from excel and update table.

    What complexity is there or you can create one custom entity by DIXF and update the data from excel.

  • Amol@ Profile Picture
    282 on at

    hi Bhaskar....thanks for replay....i am using Ax 2009 ....tell me that Is it possible to import data using Excel Add-ins in Ax 2009..

  • 5400 Profile Picture
    7,162 on at

    Yes, It is possible, you have to write custom code.

  • NabD59 Profile Picture
    20 on at

    Hi Amol@,

    Like someone said before, you have to write some custom code, the field already exist so you must do  some reading over your excel file then find your record you wanna update then use AxBC class to update your data.

    Kind regards,

    Alfonzo

  • Amol@ Profile Picture
    282 on at

    hello experts,

                         I am creating x++ code for updating specific data in table from excel...bt it gives error...my code as follows..

    static void TableUpdate(Args _args)

    {

       AsciiIO asciiIO;

       Filename filename;

       NoYesId skipFirstLine;

       Container line;

       Dialog dialog;

       DialogField dialogFileName, dialogSkipFirstLine;

       SysExcelApplication application;

       SysExcelWorkbooks workbooks;

       SysExcelWorkbook workbook;

       SysExcelWorksheets worksheets;

       SysExcelWorksheet worksheet;

       SysExcelCells cells;

       COMVariantType type;

       Name name;

       ProjInvoiceItem    projInvoiceItem;

       //ProjInvoiceId      _ProjInvoiceId;

       //ItemId             _ItemId;

       int row;

       str _ITNO;

       str _ProjInvoiceId;

       str _ItemId;

       ;

       dialog = new Dialog("Import file");

       dialogFileName = dialog.addField(TypeId(Filenameopen), "File name");

       dialog.run();

       if (dialog.run())

       {

           filename = dialogFileName.value();

       }

       asciiIO = new AsciiIO(filename, 'R');

       if (!asciiIO || asciiIO.status() != IO_Status::Ok )

       {

           throw error (strfmt("No Path Specified",filename));

       }

       ttsbegin;

       asciiIO.inRecordDelimiter('\r\n');

       asciiIO.inFieldDelimiter(',');

       while (asciiIO.status() == IO_status::Ok)

       {

           line = asciiIO.read();

           application = SysExcelApplication::construct();

           workbooks = application.workbooks();

           //specify the file path that you want to read

           filename = dialogFileName.value();

           try

           {

               workbooks.open(filename);

           }

           catch (Exception::Error)

           {

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

           }

           workbook = workbooks.item(1);

           worksheets = workbook.worksheets();

           worksheet = worksheets.itemFromNum(1); //worksheet Number

           cells = worksheet.cells();

           do

           {

               row++;

                _ProjInvoiceId = any2str(cells.item(row, 1).value().toString());

                _ItemId =  any2str(cells.item(row, 2).value().toString());

                _ITNO = cells.item(row, 3).value().bStr();

             //   select forupdate projInvoiceItem where projInvoiceItem.ProjInvoiceId == ProjInvoiceId

               //                && projInvoiceItem.ItemId == ItemId;

               projInvoiceItem.ProjInvoiceId = _ProjInvoiceId;

               projInvoiceItem.ItemId        = _ItemId;

               projInvoiceItem.ITNO          = _ITNO;

               projInvoiceItem.update();

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

       }

       while (type != COMVariantType::VT_EMPTY);

       application.quit();

      }

       ttscommit;

      }

  • Amol@ Profile Picture
    282 on at

    So plz tell me what wrongs in code...

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
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans