zoaoo

博客园 首页 新随笔 联系 订阅 管理
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(0, 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 2// first line is a title, start line 2 
        RCell1 = Cells.Item(i, 1); 
        RCell2 = Cells.Item(i, 2); 
        RCell3 = Cells.Item(i, 3); 
        RCell4 = Cells.Item(i, 4); 
        RCell5 = Cells.Item(i, 5); 
        RCell6 = Cells.Item(i, 6); 
        RCell7 = Cells.Item(i, 7); 
        RCell8 = Cells.Item(i, 8); 
 
        while (RCell1.value().bStr() != "") 
        { 
            print Cells.item(i, 1).value().bStr(); 
            // add code 
            i++; 
            RCell1 = Cells.item(i, 1); 
            RCell2 = Cells.Item(i, 2); 
            RCell3 = Cells.Item(i, 3); 
            RCell4 = Cells.Item(i, 4); 
            RCell5 = Cells.Item(i, 5); 
            RCell6 = Cells.Item(i, 6); 
            RCell7 = Cells.Item(i, 7); 
            RCell8 = Cells.Item(i, 8); 
        } 
        ttscommit; 
 
        info(strfmt("%1 %2 %3""Update Complete", i-2, curext())); 
    } 
    catch 
    { 
        info("Nothing Uploaded"); 
    } 
}

 

posted on 2017-04-25 15:10  zoaoo  阅读(185)  评论(0编辑  收藏  举报