Exporting to excel

mike_espinamike_espina Member Posts: 55
edited 2006-03-02 in Dynamics AX
Hi experts,

Is there a functionality in AXAPTA 3.0 that you can export directly the data from the tables in excel. And can you select some fields in the table and not all fields.

Tnx

Mike

Comments

  • lemxlemx Member Posts: 4
    Hi Mike,

    Currently, Axapta only exports to two kinds of files: Binary and CSV.
    There are some options which you should consider:
    1) if you just want to copy the data from an Axapta grid to Excel, you could select the records you want to copy and Copy and Paste to Excel cells.
    2) You could import to CSV and load that file into Excel. If it is ok, then you have your solution.

    However, it is not difficult to create code that exports data to Excel, considering that Axapta can access Excel through COM.

    You could create a job like the following example (by Khue Trinh), replacing custTable with any table, and the fields Account num and Name with the desired fields.

    static void Excel(Args _args)
    {

    SysExcelApplication ExcelApplication;
    SysExcelWorkBooks ExcelWorkBooks;
    SysExcelWorkBook ExcelWorkBook;
    SysExcelWorkSheets ExcelWorkSheets;
    SysExcelWorkSheet ExcelWorkSheet;
    SysExcelRange ExcelRange;
    CustTable custTable;
    int row = 1;
    ;

    ExcelApplication = SysExcelApplication::construct();
    ExcelApplication.visible(true);

    ExcelWorkBooks = ExcelApplication.workbooks();
    ExcelWorkBook = ExcelWorkBooks.add();
    ExcelWorkSheets = ExcelWorkBook.worksheets();
    ExcelWorkSheet = ExcelWorkSheets.itemFromNum(1);

    ExcelWorkSheet.cells().item(row,1).value('Account num');
    ExcelWorkSheet.cells().item(row,2).value('Name');

    row++;

    while select custTable
    {
    ExcelWorkSheet.cells().item(row,1).value(custTable.AccountNum);
    ExcelWorkSheet.cells().item(row,2).value(custTable.Name);
    row++;
    }

    ExcelApplication.finalize();
    }
  • mike_espinamike_espina Member Posts: 55
    hi.. thanks for the reply.. It was very helpfull to me..
Sign In or Register to comment.