zoukankan      html  css  js  c++  java
  • AX2012导入导出excel

    void export()
    {
    SysExcelApplication excel;
    SysExcelWorkbooks books;
    SysExcelWorkbook book;
    SysExcelWorksheets sheets;
    SysExcelWorksheet sheet;
    SysExcelCells cells;

    SysExcelStyles styles;
    SysExcelStyle style;
    SysExcelFont font;

    COM comObject;

    ARV_ParmBillingListLine_HZI m_billingLine;
    ARV_TransportOrderTable_HZI m_ordertable;
    PurchTable m_purchTable;
    PurchLine m_purchLine;

    int Excelrow = 1;
    ;

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

    books = excel.workbooks();
    book = books.add();

    styles = book.styles();
    style = styles.add('bold');
    font = style.font();
    font.bold(true);

    sheets= book.worksheets();
    sheet = sheets.itemFromNum(1);
    sheet.name('业务明细');
    cells = sheet.cells();

    this.createHead(sheet);

    while select m_billingLine
    where m_billingLine.BillingListId == g_billingList.BillingListId
    {
    m_purchTable = PurchTable::find(m_billingLine.SalesPurchOrderNum);

    while select m_purchLine
    where m_purchLine.PurchId == m_purchTable.PurchId
    {
    Excelrow++;
    this.createBody(sheet, Excelrow, m_purchLine, m_billingLine);
    }
    }

    Excelrow++;
    this.createSum(sheet, Excelrow);

    sheet.cells().range('A1:Y1').horizontalAlignment(3); //居中
    sheet.cells().range('A1:Y1').style('bold');
    sheet.cells().range('A1:Y1').comObject().AutoFormat();
    sheet.cells().range('A1:Y1').formatConditions();
    //sheet.cells().range('A1:Y1').comObject().AutoFilter();
    sheet.columns().autoFit();
    //comObject.AutoFormat();
    //comObject.AutoFilter();
    //book.saveAs(@'C:UsersgeorgeDesktopXPOSpecial Delivery Order.xlsx');
    //excel.quit();
    }

    ---------------------------------------------------------------------------------------------------

    static void TPS_updateSDO_jay(Args _args)
    {
    str file;
    FileNameFilter filter=["07-10",'*.xlsx',"97-02",'*.xls'];
    COMVariant m_comvariant;

    SysExcelApplication m_application;
    SysExcelWorkbooks m_workbooks;
    SysExcelWorkbook m_workbook;
    SysExcelWorksheets m_worksheets;
    SysExcelWorksheet m_worksheet;
    SysExcelCells m_cells;
    COMVariantType m_type; // Gets the COM object

    int m_row;


    Name m_instructionId;
    ARV_TransportOrderTable_HZI m_order;
    SalesLine m_salesLine;

    ;
    try
    {

    file = Winapi::getOpenFileName(0, filter, '', "Open Excel Files");
    m_comvariant = new COMVariant();
    m_comvariant.bStr(file);


    m_application = SysExcelApplication::construct();
    m_workbooks = m_application.Workbooks();


    m_workbook = m_workbooks.Add(m_comvariant);
    m_worksheets = m_workbook.worksheets();
    m_worksheet = m_worksheets.itemFromNum(1);
    m_cells = m_worksheet.Cells();

    m_type = m_cells.item(m_row+1, 1).value().variantType();
    m_row = 1;


    while (m_type != COMVariantType::VT_EMPTY)
    {
    m_row++;

    m_type = m_cells.item(m_row+1, 1).value().variantType(); //when COMVariantType::VT_EMPTY ,this is the end

    m_instructionId = m_cells.item(m_row, 1).value().bStr();

    try
    {

    ttsBegin;
    m_order = ARV_TransportOrderTable_HZI::find(m_instructionId, true);
    m_order.TPS_IsSDO_JAY = NoYes::Yes;
    m_order.doUpdate();

    select firstOnly forUpdate m_salesLine
    where m_salesLine.ARV_InstructionId_HZI == m_instructionId;
    if(m_salesLine)
    {
    m_order.TPS_IsSDO_JAY = NoYes::Yes;
    m_order.doUpdate();
    }
    ttsCommit;

    }
    catch
    {}
    }


    }
    catch
    {
    info("Nothing");
    }

    //m_application.quit();

    info(int2str(m_row));
    }

  • 相关阅读:
    多个手机号逗号分开
    字符转码
    短信发送AZDG加密算法
    判断手机所属三大运营商 移动、联通、电信
    MD5加密 时间差 流水号等方法
    VS2012的创建单元测试功能
    Oracle数据库操作类及连接方法
    python生成器,函数,数组
    javascript的单线程
    linux下/var/run目录下.pid文件的作用
  • 原文地址:https://www.cnblogs.com/xiangliqi/p/4585049.html
Copyright © 2011-2022 走看看