| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 941 人关注过本帖, 2 人收藏
标题:报表输出至pdf,html,xml
只看楼主 加入收藏
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:806
专家分:1231
注 册:2021-10-13
结帖率:96.83%
收藏(2)
已结贴  问题点数:20 回复次数:10 
报表输出至pdf,html,xml
上次说自己写个pdf解析器,哈哈,一直没有时间。

不过今天查看过去下载的文件,发现电脑里还有vfp前辈们写的现成的类,分享给大家。记得之前还下载了个foxypreviewer,非常实用,现在找不到了。。。

下载包:
export.rar (42.1 KB)


输出表单截图:
图片附件: 游客没有浏览图片的权限,请 登录注册

搜索更多相关主题的帖子: 报表 xml 输出 html pdf 
2023-08-27 21:42
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:806
专家分:1231
注 册:2021-10-13
收藏
得分:0 
摘选其中的报表到pdf的核心代码:

DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,STRING cOperation,STRING cFileName,STRING cParameters,STRING cDirectory,INTEGER nShowWindow
LOCAL lcFile,loCol,lcField,lcField2,lnField,lnField2,laField[1],lni,lcS,cCursor,lnPagNo,lnPagNoCur,lnLeng[10],lnRowCur,lnLengField,lnFieldV,laFieldV[1],lnHeadV,laHeadV[1],lnj
IF VARTYPE(This.grid)="O" AND !ISNULL(This.grid)
  IF LOWER(This.grid.baseclass)!="grid"
    RETURN
  ENDIF
  lcFile=PUTFILE("Alegeti fisierul",IIF(VARTYPE(This.label)="O" AND !ISNULL(This.label),This.label.caption+"_","")+TTOC(DATETIME(),1)+".pdf","PDF")
  cCursor=This.grid.RecordSource
  IF !EMPTY(lcFile) AND USED(This.grid.RecordSource)
    lnPagNo=CEILING((1+RECCOUNT(cCursor))/60)
    DIMENSION lnLeng[7+3*lnPagNo]
    lcS=[%PDF-1.2]+CHR(13)+[%]+CHR(226)+CHR(227)+CHR(207)+CHR(211)+CHR(13)
    lnLeng[1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[1 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Author ]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/CreationDate ]+CHR(40)+[D:]+TTOC(DATETIME(),1)+CHR(41)+CHR(13)
    lcS=lcS+[/Creator]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Producer]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Title]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Subject]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Keywords]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[4]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[4 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Font]+CHR(13)
    lcS=lcS+[/Subtype /Font1]+CHR(13)
    lcS=lcS+[/Name /F1]+CHR(13)
    lcS=lcS+[/Encoding 5 0 R]+CHR(13)
    lcS=lcS+[/BaseFont /Courier]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[5]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[5 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Encoding]+CHR(13)
    lcS=lcS+[/BaseEncoding /WinAnsiEncoding]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[6 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[  /Font << /F1 4 0 R >>]+CHR(13)
    lcS=lcS+"  /ProcSet [ /PDF /Text ]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    *
    lnPagNoCur=1
    *
    lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Page]+CHR(13)
    lcS=lcS+[/Parent 3 0 R]+CHR(13)
    lcS=lcS+[/Resources 6 0 R]+CHR(13)
    lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
    lcS=lcS+[/Rotate 0]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
    lcS=lcS+[BT]+CHR(13)
    lnLeng1=LEN(lcS)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
    lcS=lcS+[12 TL]+CHR(13)
    lcS=lcS+[T* ]+CHR(40)
    lnField2=AFIELDS(laField,cCursor)
    lnField=0
    FOR EACH loCol IN This.grid.Columns
      IF !loCol.Visible
        LOOP
      ENDIF
      lcField=loCol.ControlSource
      lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
      lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
      IF lni>0
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        IF laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(laField[lni,1]),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(laField[lni,1]),lnLengField-1)+SPACE(1)
        ENDIF
      ELSE
        lnLengField=254
        IF VARTYPE(&lcField)="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(lcField2),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(lcField2),lnLengField-1)+SPACE(1)
        ENDIF
      ENDIF
      lnField=lnField+1
    NEXT
    lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
    lnRowCur=0
    SELECT (cCursor)
    SCAN
      lnRowCur=lnRowCur+1
      IF MOD(lnRowCur,60)=0
        lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
        lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lnLeng2=LEN(lcS)
        lcS=lcS+[ET]+CHR(13)
        lcS=lcS+[endstream]+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
        lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnPagNoCur=lnPagNoCur+1
        *
        lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Type /Page]+CHR(13)
        lcS=lcS+[/Parent 3 0 R]+CHR(13)
        lcS=lcS+[/Resources 6 0 R]+CHR(13)
        lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
        lcS=lcS+[/Rotate 0]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
        lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
        lcS=lcS+[BT]+CHR(13)
        lnLeng1=LEN(lcS)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
        lcS=lcS+[12 TL]+CHR(13)
      ENDIF
      lcS=lcS+[T* ]+CHR(40)
    lnField2=AFIELDS(laField,cCursor)
    lnField=0
    FOR EACH loCol IN This.grid.Columns
      IF !loCol.Visible
        LOOP
      ENDIF
      lcField=loCol.ControlSource
      lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
      lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
      IF lni>0
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        lcField=laField[lni,1]
        DO CASE
        CASE laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
        CASE laField[lni,2]="N"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="I"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="D"
          lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="T"
          lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
        CASE laField[lni,2]="L"
          lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
        ENDCASE  
      ELSE
        DO CASE
        CASE VARTYPE(&lcField)="C"
          lnLengField=254
          lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
        CASE VARTYPE(&lcField)="N"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),30-1)+SPACE(1)
        CASE VARTYPE(&lcField)="I"
          lcS=lcS+PADL(ALLTRIM(STR(&lcField)),30-1)+SPACE(1)
        CASE VARTYPE(&lcField)="D"
          lcS=lcS+PADL(DTOC(&lcField),12-1)+SPACE(1)
        CASE VARTYPE(&lcField)="T"
          lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),22-1)+SPACE(1)
        CASE VARTYPE(&lcField)="L"
          lcS=lcS+PADL(IIF(&lcField,"X","-"),3-1)+SPACE(1)
        ENDCASE  
      ENDIF
      lnField=lnField+1
    NEXT
      lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
      SELECT (cCursor)
    ENDSCAN
    lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
    lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lnLeng2=LEN(lcS)
    lcS=lcS+[ET]+CHR(13)
    lcS=lcS+[endstream]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
    lcS=lcS+[endobj]+CHR(13)

    lnLeng[2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[2 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Catalog]+CHR(13)
    lcS=lcS+[/Pages 3 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[3]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[3 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Pages]+CHR(13)
    lcS=lcS+[/Count ]+ALLTRIM(STR(lnPagNo))+CHR(13)
    lcS=lcS+"/MediaBox [ 0 0 1008 792 ]"+CHR(13)
    lcS=lcS+"/Kids [ "
    FOR lni=1 TO lnPagNo
      lcS=lcS+ALLTRIM(STR(6+3*(lni-1)+1))+" 0 R "
    NEXT
    lcS=lcS+"]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[7+3*lnPagNo]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[0 ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[0000000000 65535 f]+CHR(13)
    FOR lni=1 TO 7+3*lnPagNo
      lcS=lcS+PADL(ALLTRIM(STR(lnLeng[lni])),10,"0")+[ 00000 n]+CHR(13)
    NEXT
    lcS=lcS+[trailer]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Size ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[/Root 2 0 R]+CHR(13)
    lcS=lcS+[/Info 1 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[startxref]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng[7+3*lnPagNo]))+CHR(13)
    lcS=lcS+[%%EOF]+CHR(13)
    STRTOFILE(lcS,lcFile)
    ShellExecute(0,"Open",lcFile,"","",1)
  ENDIF
ENDIF

IF VARTYPE(This.grid)="C" AND !EMPTY(This.grid)
  lcFile=PUTFILE("Alegeti fisierul",IIF(VARTYPE(This.label)="O" AND !ISNULL(This.label),This.label.caption+"_","")+TTOC(DATETIME(),1)+".pdf","PDF")
  cCursor=This.grid
  IF !EMPTY(lcFile) AND USED(This.grid)
    STORE 0 TO lnHeadV,lnFieldV
    IF !EMPTY(This.cHeaders)
      lnHeadV=ALINES(laHeadV,This.cHeaders,.T.,",")
    ENDIF
    IF !EMPTY(This.cFields)
      lnFieldV=ALINES(laFieldV,This.cFields,.T.,",")
    ENDIF

    lnPagNo=CEILING((1+RECCOUNT(cCursor))/60)
    DIMENSION lnLeng[7+3*lnPagNo]
    lcS=[%PDF-1.2]+CHR(13)+[%]+CHR(226)+CHR(227)+CHR(207)+CHR(211)+CHR(13)
    lnLeng[1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[1 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Author ]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/CreationDate ]+CHR(40)+[D:]+TTOC(DATETIME(),1)+CHR(41)+CHR(13)
    lcS=lcS+[/Creator]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Producer]+CHR(40)+[Praisach Vilhelm-Ion]+CHR(41)+CHR(13)
    lcS=lcS+[/Title]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Subject]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[/Keywords]+CHR(40)+CHR(41)+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[4]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[4 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Font]+CHR(13)
    lcS=lcS+[/Subtype /Font1]+CHR(13)
    lcS=lcS+[/Name /F1]+CHR(13)
    lcS=lcS+[/Encoding 5 0 R]+CHR(13)
    lcS=lcS+[/BaseFont /Courier]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[5]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[5 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Encoding]+CHR(13)
    lcS=lcS+[/BaseEncoding /WinAnsiEncoding]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[6 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[  /Font << /F1 4 0 R >>]+CHR(13)
    lcS=lcS+"  /ProcSet [ /PDF /Text ]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    *
    lnPagNoCur=1
    *
    lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Type /Page]+CHR(13)
    lcS=lcS+[/Parent 3 0 R]+CHR(13)
    lcS=lcS+[/Resources 6 0 R]+CHR(13)
    lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
    lcS=lcS+[/Rotate 0]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
    lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
    lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
    lcS=lcS+[BT]+CHR(13)
    lnLeng1=LEN(lcS)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
    lcS=lcS+[12 TL]+CHR(13)
    lcS=lcS+[T* ]+CHR(40)
    lnField=AFIELDS(laField,cCursor)
    lcField=""
    IF lnFieldV=0
      FOR lni=1 TO lnField
        lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
        IF laField[lni,2]="C"
          lcS=lcS+SPACE(1)+PADR(PROPER(laField[lni,1]),lnLengField-1)
        ELSE
          lcS=lcS+PADL(PROPER(laField[lni,1]),lnLengField-1)+SPACE(1)
        ENDIF
      NEXT
    ELSE
      FOR lnj=1 TO lnFieldV
        lcField=laFieldV[lnj]
        lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
        lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
        IF lni>0
          lnLengField=MAX(laField[lni,3],LEN(IIF(lnHeadV=lnFieldV,laHeadV[lnj],laField[lni,1])))+1
          IF laField[lni,2]="C"
            lcS=lcS+SPACE(1)+PADR(IIF(lnHeadV=lnFieldV,laHeadV[lnj],PROPER(laField[lni,1])),lnLengField-1)
          ELSE
            lcS=lcS+PADL(IIF(lnHeadV=lnFieldV,laHeadV[lnj],PROPER(laField[lni,1])),lnLengField-1)+SPACE(1)
          ENDIF
        ELSE
          lnLengField=254
          IF VARTYPE(&lcField)="C"
            lcS=lcS+SPACE(1)+PADR(PROPER(lcField2),lnLengField-1)
          ELSE
            lcS=lcS+PADL(PROPER(lcField2),lnLengField-1)+SPACE(1)
          ENDIF
        ENDIF
      NEXT
    ENDIF
    lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
    lnRowCur=0
    SELECT (cCursor)
    SCAN
      lnRowCur=lnRowCur+1
      IF MOD(lnRowCur,60)=0
        lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
        lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lnLeng2=LEN(lcS)
        lcS=lcS+[ET]+CHR(13)
        lcS=lcS+[endstream]+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
        lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
        lcS=lcS+[endobj]+CHR(13)
        lnPagNoCur=lnPagNoCur+1
        *
        lnLeng[6+3*(lnPagNoCur-1)+1]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+1))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Type /Page]+CHR(13)
        lcS=lcS+[/Parent 3 0 R]+CHR(13)
        lcS=lcS+[/Resources 6 0 R]+CHR(13)
        lcS=lcS+[/Contents ]+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 R]+CHR(13)
        lcS=lcS+[/Rotate 0]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[endobj]+CHR(13)
        lnLeng[6+3*(lnPagNoCur-1)+2]=LEN(lcS)-OCCURS(CHR(13),lcS)
        lcS=lcS+ALLTRIM(STR(6+3*(lnPagNoCur-1)+2))+[ 0 obj]+CHR(13)+[<<]+CHR(13)
        lcS=lcS+[/Length ]+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 R]+CHR(13)
        lcS=lcS+[>>]+CHR(13)+[stream]+CHR(13)
        lcS=lcS+[BT]+CHR(13) && begin text
        lnLeng1=LEN(lcS)
        lcS=lcS+[/F1 10 Tf]+CHR(13)
        lcS=lcS+[1 0 0 1 50 752 Tm]+CHR(13)
        lcS=lcS+[12 TL]+CHR(13)
      ENDIF
      lcS=lcS+[T* ]+CHR(40)
      IF lnFieldV=0
        FOR lni=1 TO lnField
          lnLengField=MAX(laField[lni,3],LEN(laField[lni,1]))+1
          lcField=laField[lni,1]
          DO CASE
          CASE laField[lni,2]="C"
            lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
          CASE laField[lni,2]="N"
            lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="I"
            lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="D"
            IF EMPTY(&lcField)
              lcS=lcS+PADL("",lnLengField-1)+SPACE(1)
            ELSE
              lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
            ENDIF
          CASE laField[lni,2]="T"
            lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
          CASE laField[lni,2]="L"
            lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
          ENDCASE  
        NEXT
      ELSE
        FOR lnj=1 TO lnFieldV
          lcField=laFieldV[lnj]
          lcField2=IIF(RAT(".",lcField)=0,lcField,SUBSTR(lcField,RAT(".",lcField)+1))
          lni=ASCAN(laField,lcField2,-1,-1,1,1+6+8)
          IF lni>0
            lnLengField=MAX(laField[lni,3],LEN(IIF(lnHeadV=lnFieldV,laHeadV[lnj],laField[lni,1])))+1
          ELSE
            lnLengField=254
          ENDIF
          DO CASE
          CASE VARTYPE(&lcField)="C"
            lcS=lcS+SPACE(1)+PADR(ALLTRIM(&lcField),lnLengField-1)
          CASE VARTYPE(&lcField)="N"
            IF lni>0
              DO CASE
              CASE laField[lni,2]="N"
                lcS=lcS+PADL(ALLTRIM(STR(&lcField,laField[lni,3],laField[lni,4])),lnLengField-1)+SPACE(1)
              CASE laField[lni,2]="I"
                lcS=lcS+PADL(ALLTRIM(STR(&lcField)),lnLengField-1)+SPACE(1)
              OTHERWISE
                lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),lnLengField-1)+SPACE(1)
              ENDCASE
            ELSE
              lcS=lcS+PADL(ALLTRIM(STR(&lcField,30,3)),lnLengField-1)+SPACE(1)
            ENDIF
          CASE VARTYPE(&lcField)="D"
            IF EMPTY(&lcField)
              lcS=lcS+PADL("",lnLengField-1)+SPACE(1)
            ELSE
              lcS=lcS+PADL(DTOC(&lcField),lnLengField-1)+SPACE(1)
            ENDIF
          CASE VARTYPE(&lcField)="T"
            lcS=lcS+PADL(DTOC(TTOD(&lcField))+" "+TTOC(&lcField,2),lnLengField-1)+SPACE(1)
          CASE VARTYPE(&lcField)="L"
            lcS=lcS+PADL(IIF(&lcField,"X","-"),lnLengField-1)+SPACE(1)
          ENDCASE  
        NEXT
      ENDIF
      lcS=lcS+CHR(13)+CHR(10)+CHR(41)+[ Tj]+CHR(13)
      SELECT (cCursor)
    ENDSCAN
    lcS=lcS+[1 0 0 1 504 25 Tm]+CHR(13)
    lcS=lcS+CHR(40)+ALLTRIM(STR(lnPagNoCur))+CHR(41)+[ Tj]+CHR(13)
    lcS=lcS+[/F1 10 Tf]+CHR(13)
    lnLeng2=LEN(lcS)
    lcS=lcS+[ET]+CHR(13) && end text
    lcS=lcS+[endstream]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[6+3*lnPagNoCur]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+ALLTRIM(STR(6+3*lnPagNoCur))+[ 0 obj]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng2-lnLeng1))+CHR(13)
    lcS=lcS+[endobj]+CHR(13)

    lnLeng[2]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[2 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Catalog]+CHR(13)
    lcS=lcS+[/Pages 3 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[3]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[3 0 obj]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Type /Pages]+CHR(13)
    lcS=lcS+[/Count ]+ALLTRIM(STR(lnPagNo))+CHR(13)
    lcS=lcS+"/MediaBox [ 0 0 1008 792 ]"+CHR(13)
    lcS=lcS+"/Kids [ "
    FOR lni=1 TO lnPagNo
      lcS=lcS+ALLTRIM(STR(6+3*(lni-1)+1))+" 0 R "
    NEXT
    lcS=lcS+"]"+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[endobj]+CHR(13)
    lnLeng[7+3*lnPagNo]=LEN(lcS)-OCCURS(CHR(13),lcS)
    lcS=lcS+[0 ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[0000000000 65535 f]+CHR(13)
    FOR lni=1 TO 7+3*lnPagNo
      lcS=lcS+PADL(ALLTRIM(STR(lnLeng[lni])),10,"0")+[ 00000 n]+CHR(13)
    NEXT
    lcS=lcS+[trailer]+CHR(13)
    lcS=lcS+[<<]+CHR(13)
    lcS=lcS+[/Size ]+ALLTRIM(STR(7+3*lnPagNo))+CHR(13)
    lcS=lcS+[/Root 2 0 R]+CHR(13)
    lcS=lcS+[/Info 1 0 R]+CHR(13)
    lcS=lcS+[>>]+CHR(13)
    lcS=lcS+[startxref]+CHR(13)
    lcS=lcS+ALLTRIM(STR(lnLeng[7+3*lnPagNo]))+CHR(13)
    lcS=lcS+[%%EOF]+CHR(13)
    STRTOFILE(lcS,lcFile)
    ShellExecute(0,"Open",lcFile,"","",1)
  ENDIF
ENDIF
2023-08-27 21:44
xinjie
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:19
帖 子:277
专家分:520
注 册:2007-8-11
收藏
得分:5 
2023-08-28 05:05
gxouyuan
Rank: 2
等 级:论坛游民
帖 子:15
专家分:37
注 册:2021-3-17
收藏
得分:5 
感谢大佬们分享
2023-08-28 08:13
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1790
专家分:3389
注 册:2012-2-29
收藏
得分:5 
谢谢分享!
2023-08-28 08:58
easyppt
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:1
帖 子:309
专家分:711
注 册:2021-11-24
收藏
得分:5 
LZ, 是  FRX 直接到  PDF 吗,支持自定义字体吗
2023-08-28 11:38
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:806
专家分:1231
注 册:2021-10-13
收藏
得分:0 
回复 6楼 easyppt
可以自己设置。
2023-08-28 12:24
老去的流星雨
Rank: 2
等 级:论坛游民
帖 子:24
专家分:57
注 册:2023-9-9
收藏
得分:0 
到PDF可以用WINDOWS自身的Microsoft Print to PDF虚拟打印机,完美转换,以下是关键代码
APRINTERS(prt)
        lcPrintName = ""
        FOR i = 1 TO ALEN(prt,1)
            IF 'PDF'$prt(i,1)
                lcPrintName = prt(i,1)
            ENDIF
        ENDFOR
        SET PRINTER TO NAME (lcPrintName)
REPORT FORM (lcFrxName) NOWAIT
2023-09-09 18:00
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:806
专家分:1231
注 册:2021-10-13
收藏
得分:0 
回复 8楼 老去的流星雨
我的windows怎么没有自带啊?
2023-09-09 20:16
老去的流星雨
Rank: 2
等 级:论坛游民
帖 子:24
专家分:57
注 册:2023-9-9
收藏
得分:0 
回复 9楼 sam_jiang
可以安装一下
2023-09-10 10:30
快速回复:报表输出至pdf,html,xml
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029417 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved