电竞比分网-中国电竞赛事及体育赛事平台

分享

DBFtoEXCEL

 lygcw9603 2012-02-12

 Lparameters dbfname
    *    RPTSHEET=Getobject('','excel.sheet')
    RPTSHEET=Createobject("excel.application")
    RPTSHEET.Visible=.F.
    XLAPP=RPTSHEET.Application
    XLAPP.WORKBOOKS.Add()
    XLSHEET=XLAPP.ACTIVESHEET
    RPTSHEET.Caption=dbfname+"_xzs"

    *!* 20.設(shè)置頁腳、頂邊距、底邊距、左邊距、右邊距
    With RPTSHEET.ACTIVESHEET.PageSetup
        .CenterFooter="第&P頁"
        .TopMargin=1/0.035
        .BottomMargin=2/0.035
        .LeftMargin=1/0.035
        .RightMargin=1/0.035
    Endwith

    Select &dbfname
    ** 創(chuàng)建報(bào)表頭
    gnFieldcount = Afields(gaMyArray)  && 創(chuàng)建數(shù)組。
    For nCount = 1 To gnFieldcount
        XLAPP.CELLS(1,nCount).Value=gaMyArray(nCount,1)
        If Vartype(gaMyArray(nCount,1))='C'
            RPTSHEET.Columns(nCount).Select
            RPTSHEET.Selection.NumberFormatLocal = "@"  &&設(shè)置列格式為字符型
        Else
            RPTSHEET.Columns(nCount).Select
            RPTSHEET.Selection.HorizontalAlignment=4    &&其它類型右對(duì)齊
        Endif
        RPTSHEET.ACTIVESHEET.Columns(nCount).Font.Size=9
    Endfor

    Select &dbfname
    Go Top
    lccont=2 && 數(shù)據(jù)從第二行開始
    Scan
        For nCount = 1 To gnFieldcount
            &&判斷單元格里是否為字符型,如果是則去掉前后空格 排版需要。
            &&上面是判斷字段類型,這次判斷 字段值類型
            If Vartype(&gaMyArray(nCount,1))='C'
                XLAPP.CELLS(lccont,nCount).Value=Alltrim(&gaMyArray(nCount,1))
            Else
                XLAPP.CELLS(lccont,nCount).Value=&gaMyArray(nCount,1)
            Endif
        Endfor
        lccont=lccont+1
    Endscan
    RPTSHEET.CELLS.EntireColumn.AutoFit  && 自動(dòng)寬度
    *    WAIT CHR(gnFieldcount+64)+ALLTRIM(STR(lccont)) windows
    **   設(shè)置表格邊線
    With RPTSHEET.ACTIVESHEET.Range("a1:"+Chr(gnFieldcount+64)+Alltrim(Str(lccont-1)))
        *        .BorderS(2).LineStyle=9
        .BorderS(1).Weight=2
        .BorderS(2).Weight=2
        .BorderS(3).Weight=2
        .BorderS(4).Weight=2
    Endwith
    RPTSHEET.Visible=.T.
    RPTSHEET.Cells(1,1).Select

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多