|
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
|