zoukankan      html  css  js  c++  java
  • Export to Excel/Word COMInterface

    Export to Excel/Word - COM-Interface

    Axapta has subset of classes which can be used for exporting data into Excel via COM in your own way. You can find them in the AOT ( Application Object Tree ), they have 'SysExcel' prefix.

    These classes are simply wrappers around COM class.

    The following simple example shows how output data about employees into already prepared Excel template.

    static void ExcelAPITestJob(Args _args)
    {
        SysExcelApplication     excelApp = SysExcelApplication::construct();
        SysExcelWorkSheet       excelWorksheet;
        SysExcelRange           excelRange;
        SysExcelCells           excelCells;
        SysExcelCell            excelCell;
        ComVariant              cellValue = new ComVariant() ;
        EmplTable               empTable;
        int                     i;   // Open our template file
        excelApp.workbooks().open( 'c:\\tmp\\empl_rep.xlt' );
        // Obtain first worksheet
        excelWorksheet = excelApp.worksheets().itemFromNum( 1 );
        // Obtain cells on that worksheet
        excelCells = excelWorksheet.cells();   // select data from employee's table and output EmplId and Name into our template
        while select empTable
        {
            excelCells.item( 5 + i, 2 ).value( cellValue.bStr( empTable.EmplId ) );
            excelCells.item( 5 + i, 3 ).value( cellValue.bStr( empTable.Name ) );
            i++;
        }   excelApp.visible( true );
    }

    The example above uses Excel template, you should download it before running that code. To download template file click here (WARNING!!!. You have to replace 'xpo' extension with 'xlt' after downloading it.)

    See also SysExcelTemplateWizard

  • 相关阅读:
    threading学习
    Python基础-5
    BS4
    requests基础
    Python基础-4
    Python基础-3
    Python基础-2
    Python基础-1
    DevOps
    nginx配置ssl证书实现https
  • 原文地址:https://www.cnblogs.com/perock/p/2353001.html
Copyright © 2011-2022 走看看