Option Explicit
' flag to indicate we're printing the main table
Dim bPrintingTable%Private Sub Form_Load()
Dim n1, m1, m2, n2, m22, row, row1, L1, jj, i, j As Integer    '读数据库数据
                        With VSPrinter1
                                .Orientation = orPortrait ' = orLandscape '设置纵向打印
                                     .TableBorder = tbAll
                                '设置页面四边的边距
                                     .MarginTop = 1200
                                .MarginBottom = 900
                                .MarginLeft = 1000
                                .MarginRight = 1000
                                .PhysicalPage = True
                                '.Footer = "|%z|page %d"
                                .Footer = "打印日期:" & Format$(Date$, "YYYY-MM-DD") & " " & Format$(Time$, "HH:MM:SS") & Page %d
 ‘=====================这里我想在页脚添加打印日期,可是不知道该怎样写
            '*************************************开始打印文档的内容*************************************            .StartDoc
                            .StartDoc
                                RenderHeader
                                .MarginLeft = 1000
                                .StartTable
                                    .TableCell(tcCols) = m1 + m2
                                    .TableCell(tcRows) = n1
                                    .TableCell(tcRowHeight) = 300
                                    .TableCell(tcColWidth, , 1) = 800 '列宽
                                         .TableCell(tcColWidth, , 2) = 800
                                    .TableCell(tcColWidth, , 3) = 900
                                    .TableCell(tcColWidth, , 4) = 1000
                                    .TableCell(tcColWidth, , 5) = 1500
                                    .TableCell(tcColWidth, , 6) = 1000
                                    .TableCell(tcColWidth, , 7) = 1000
                                    .TableCell(tcColWidth, , 8) = 1000
                                    .TableCell(tcColWidth, , 9) = 1300
                                     For i = 1 To m1 + m2
                                    .TableCell(tcColAlign, , i) = taCenterMiddle
                                    Next
            '*************************************向每一页面添加数据*************************************
                                    Dim r%, c%
                                    For r = 1 To n1 '行
                                        For c = 1 To m1 + m2 ' 列
                                            .TableCell(tcText, r, c) = SW(r, c)
                                        Next c
                                    Next r
                                    bPrintingTable = True
                                .EndTable
                                    ’.Paragraph = "打印日期:" & Format$(Date$, "YYYY-MM-DD") & " " & Format$(Time$, "HH:MM:SS")
                                 bPrintingTable = False
                            .EndDoc
                        End WithEnd SubPrivate Sub VSPrinter1_NewPage()
    If bPrintingTable Then RenderHeader
End SubPrivate Sub RenderHeader()
                    With VSPrinter1
                        .MarginLeft = .Width / 3 - 200
                        .FontSize = 14
                        '.TableCell(tcRowHeight) = 400
                        .Paragraph = Form211.Label1.Caption & vbCrLf
                        .FontSize = 11
                        .MarginLeft = 1000
                        .FontBold = True
                        .TextColor = 0
                        .AddTable "^800|^800|^900|^1000|^1500|^1000|^1000|^2300", "", "序号|日|时分|水尺编号|水尺零点高程|水尺读数|水位|水温"
                        .TextColor = 0
                        .AddTable "^800|^800|^900|^1000|^1500|^1000|^1000|^1000|^1300", "", "|||||||读数|水温订正后"
‘===========这里的表头是需要合并单元格的,可是我只能写成这样的,谁能帮我看看怎样纵向合并单元格??
                        .FontBold = False
                    End With
End Sub在这段代码中,我把表头和表格分开写了,我不知道这样写对不对?我用了vsprint控件做打印预览
我遇到的问题是:
1、怎样在每页的表尾处加上打印日期
2、怎样纵向合并表头的单元格?如果大家有别的写表头的好的代码可以告诉我哦!谁能帮我解决我的问题??