AX_SysExcel

时间:2023-03-09 04:58:29
AX_SysExcel
void KTL_CPeng_ImportCustStamp() 

    str                 file; 
    FileNameFilter      filter = ["@SYS57521",'*.xlsx', "@SYS101541",'*.xls']; 
    COMVariant          COMVariant1; 
    SysExcelApplication app; 
    SysExcelWorkbooks   Workbooks; 
    SysExcelWorkbook    Workbook; 
    SysExcelWorksheets  Worksheets; 
    SysExcelWorksheet   Worksheet; 
    SysExcelCells       Cells; 
    SysExcelCell        RCell1, RCell2, RCell3,RCell4,RCell5,RCell6,RCell7, RCell8; 
    int                 i, j; 
    #excel 
    ; 
 
    try 
    { 
        ttsbegin; 
        file        = Winapi::getOpenFileName(, filter, '', "Open Excel Files"); 
        app         = SysExcelApplication::construct(); 
        Workbooks   = app.Workbooks(); 
        COMVariant1 = new COMVariant(); 
        COMVariant1.bStr(file); 
        Workbook    = Workbooks.Add(COMVariant1); 
        Worksheets  = Workbook.worksheets(); 
        Worksheet = Worksheets.itemFromName("sheet1"); 
        //Worksheet   = worksheets.itemFromNum(1); 
        Cells       = Worksheet.Cells(); 
 
        i = ; // first line is a title, start line 2 
        RCell1 = Cells.Item(i, ); 
        RCell2 = Cells.Item(i, ); 
        RCell3 = Cells.Item(i, ); 
        RCell4 = Cells.Item(i, ); 
        RCell5 = Cells.Item(i, ); 
        RCell6 = Cells.Item(i, ); 
        RCell7 = Cells.Item(i, ); 
        RCell8 = Cells.Item(i, ); 
 
        while (RCell1.value().bStr() != "") 
        { 
            print Cells.item(i, ).value().bStr(); 
            // add code 
            i++; 
            RCell1 = Cells.item(i, ); 
            RCell2 = Cells.Item(i, ); 
            RCell3 = Cells.Item(i, ); 
            RCell4 = Cells.Item(i, ); 
            RCell5 = Cells.Item(i, ); 
            RCell6 = Cells.Item(i, ); 
            RCell7 = Cells.Item(i, ); 
            RCell8 = Cells.Item(i, ); 
        } 
        ttscommit; 
 
        info(strfmt("%1 %2 %3", "Update Complete", i-, curext())); 
    } 
    catch 
    { 
        info("Nothing Uploaded"); 
    } 
}