| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 92 人关注过本帖
标题:当word表格不满一页时,原页脚内容自动上移到表格下面
只看楼主 加入收藏
王咸美
Rank: 1
等 级:新手上路
帖 子:759
专家分:3
注 册:2018-1-4
结帖率:97.81%
收藏
 问题点数:20 回复次数:3 
当word表格不满一页时,原页脚内容自动上移到表格下面
当word表格不满一页时,原页脚内容自动上移到表格下面,下列代码如何修改,请高手赐教,万分感谢!!!
图片附件: 游客没有浏览图片的权限,请 登录注册

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


附VFP代码(待修改)
CLOSE DATABASES
CLEAR ALL
SET TALK OFF
SET SAFETY OFF
SET MARK TO "-"
SET CENTURY on
SET COMPATIBLE off
FN=GETFILE("dbf")
USE &FN

WAIT "正在访问word软件..." WINDOW nowait
wordApp=CREATEOBJECT("word.Application")

WAIT "正在生成表格......" WINDOW nowait
wordApp.Visible=.t.
wordApp.Documents.Add
wordApp.ActiveDocument.PageSetup.LinesPage=35
wordApp.Documents(1).Range.Text=ALIAS()+"一览表"
wordApp.Documents(1).Range.Font.Size=15
wordApp.Documents(1).Range.Font.Name="黑体"
wordApp.Documents(1).Range.Paragraphs.Alignment=1
 
# define NUM_AFIELDS 16
PUBLIC aWizFList
DIMENSION aWizFList[1]
=AFIELDS(aWizFList)

LOCAL mytextzhi
GO top
myfcount=FCOUNT()
FOR i=1 TO  FCOUNT()
  IF INLIST(aWizFList[i,2],"G","M")
     myfcount=myfcount-1
     LOOP
   ENDIF
ENDFOR
wordAppRang=wordApp.Documents(1).Range(LENC(wordApp.Documents(1).Range.Text)-1,LENC(wordApp.Documents(1).Range.Text)-1)
wordTable=wordApp.Documents(1).Tables.Add(wordAppRang,RECCOUNT()+1,myfcount)
wordTable.Range.Paragraphs.Alignment=0
wordTable.Range.Font.Name="宋体"
wordTable.Range.Font.Size=10
wordTable.Borders.Enable=1
wordTable.Borders(1).LineWidth=12
wordTable.Borders(2).LineWidth=12
wordTable.Borders(3).LineWidth=12
wordTable.Borders(4).LineWidth=12
wordTable.Rows(1).Borders(3).LineWidth=12
wordTable.Rows(1).Range.Font.Bold=.t.
wordTable.Rows(1).Cells.VerticalAlignment=1
wordTable.Rows(1).Range.Paragraphs.Alignment=4
wordTable.Rows(1).HeadingFormat=.t.

FOR j=1 TO RECCOUNT()
  k=0
  FOR i=1 TO FCOUNT()
   IF INLIST(aWizFList[i,2],"G","M")
     k=k+1
     LOOP
   ELSE
     myzdm=aWizFList[i,1]
     mytextzhi=EVALUATE(myzdm)
     IF EMPTY(mytextzhi) OR ISNULL(mytextzhi)
       mytextzhi=" "
     ELSE
       DO case
          CASE INLIST(aWizFList[i,2],"C")
             mytextzhi=ALLTRIM(mytextzhi)
          CASE INLIST(aWizFList[i,2],"M")
             mytextzhi=TRIM(mytextzhi)
             mytextzhi=STRTRAN(mytextzhi,CHR(13),' ')
          CASE INLIST(aWizFList[i,2],"N")
             myWidth=aWizFList[i,3]
             mydWidth=aWizFList[i,4]
             mytextzhi=ALLTRIM(STR(mytextzhi,myWidth,mydWidth))
          CASE INLIST(aWizFList[i,2],"Y")
             mytextzhi=ALLTRIM(STR(mytextzhi,20,4))
          CASE INLIST(aWizFList[i,2],"I","B","F")
             mytextzhi=ALLTRIM(STR(mytextzhi))
          CASE aWizFList[i,2]="D"
             mytextzhi=DTOC(mytextzhi)
          CASE aWizFList[i,2]="T"
             mytextzhi=TTOC(mytextzhi)
          CASE aWizFList[i,2]="L"
            IF mytextzhi=.T.
              mytextzhi="是"
            ELSE
              mytextzhi="否"
            ENDIF
          other=" "
       ENDCASE
       IF EMPTY(mytextzhi) OR ISNULL("mytextzhi")
         mytextzhi=" "
       ENDIF
       wordTable.cell(1,i-k).range.Text=aWizFList[i,1]
       wordTable.Rows(j+1).cells(i-k).range.insertafter(mytextzhi)
     ENDIF
   ENDIF
  NEXT i
  SKIP 1
NEXT j
wordTable.Columns().AutoFit

* 下面为页面设置
wordApp.ActiveDocument.PageSetup.PaperSize=7
wordApp.ActiveDocument.PageSetup.Orientation=0
wordApp.ActiveDocument.PageSetup.TopMargin=22.0*2.835
wordApp.ActiveDocument.PageSetup.BottomMargin=22.0*2.835
wordApp.ActiveDocument.PageSetup.LeftMargin=19.0*2.835
wordApp.ActiveDocument.PageSetup.RightMargin=19.0*2.835
wordApp.ActiveDocument.PageSetup.VerticalAlignment=0
wordApp.ActiveDocument.PageSetup.FooterDistance=19.0*2.835
wordApp.Documents(1).Sections(1).Footers(1).Range.Paragraphs.Alignment=2
wordApp.Documents(1).Sections(1).Footers(1).Range.select
wordApp.Selection.InsertAfter("第")
wordApp.Selection.Start=wordApp.Selection.End
wordApp.Selection.InsertFormula("PAGE")
wordApp.Selection.Start=wordApp.Selection.End
wordApp.Selection.InsertBefore("页/共")
wordApp.Selection.Start=wordApp.Selection.End
wordApp.Selection.InsertFormula("NUMPAGES")
wordApp.Selection.Start=wordApp.Selection.End
wordApp.Selection.InsertAfter("页")
wordApp.Selection.Range.Paragraphs.Alignment=1
wordTable.Rows(1).HeadingFormat=.t.
wordTable.Columns().AutoFit
wordApp.Documents(1).SaveAs("E:\"+ALIAS()+".doc")
wordApp.Quit
RELEASE wordApp
WAIT clear
MESSAGEBOX("生成word文件完毕,文件位置E:\"+ALIAS()+".doc!",64,"完毕")
RETURN








[此贴子已经被作者于2025-5-27 17:27编辑过]

搜索更多相关主题的帖子: word Documents 表格 case Selection 
3 天前 16:12
schtg
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:Usa
等 级:贵宾
威 望:67
帖 子:2046
专家分:4180
注 册:2012-2-29
收藏
得分:0 
页脚,应该在页面下面页脚本身所处的位置,咋会不够一页时就跑到了表格的下面。若是这样的话,那么设置的就不是页脚吧
3 天前 17:45
王咸美
Rank: 1
等 级:新手上路
帖 子:759
专家分:3
注 册:2018-1-4
收藏
得分:0 
不设置页脚,在每页表格下面写上 第x页/共y页 如何做到?望指点!
3 天前 18:27
王咸美
Rank: 1
等 级:新手上路
帖 子:759
专家分:3
注 册:2018-1-4
收藏
得分:0 
假设毎页打印35条记录,有没有办法在每页表格下面插入页码,请高手指点,谢谢!
7 分钟前
快速回复:当word表格不满一页时,原页脚内容自动上移到表格下面
数据加载中...
 
   



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

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019416 second(s), 10 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved