北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |
以下的代码在那里是修改行与行之间的距离
Option Compare Database
Option Explicit
Public Function ReportSheet(rpt As Report, _
LeftControl As Control, _
RightControl As Control, _
Optional RowsOfPage As Integer, _
Optional Style As Integer = 0, _
Optional HasColumnHeader As Boolean = True)
On Error Resume Next
Dim intI As Integer
Dim lngTop As Long '表格上边距,即报表页眉的高度
Dim lngBottom As Long '表格下边距,报表页眉的高度 +主体节高度×每页要显示的记录数
Dim lngLeft As Long '表格左边距,第一个控件的左边距
Dim lngRight As Long '表格右边距,最后一个控件的左边距+最后一个控件的宽度
Dim lngRowHeight As Long '行高,即主体节高度
Dim lngRows As Long
Dim lngRowTop As Long
Dim lngBottomMax As Long
Dim ctl As Control
With rpt
lngRowHeight = .Section(acDetail).Height ' 行高:主体节高度
lngTop = .Section(acPageHeader).Height ' 设上边距为页面页眉高度,为防止报表没有页面页眉所以代码单独一行
If .Page = 1 Then lngTop = lngTop + .Section(acHeader).Height ' 第一页再加上报表页眉高度,为防止报表没有报表页眉所以代码单独一行
lngBottomMax = .Section(acPageFooter).Height ' 页面页脚高度,为防止报表没有页面页脚所以代码单独一行
lngBottomMax = .ScaleHeight - lngBottomMax ' 报表高度减去页面页脚高度得到最大允许的下边距
End With
lngRows = Int((lngBottomMax - lngTop) / lngRowHeight) ' 当前页面能容纳的行数
If RowsOfPage > 0 Then
If RowsOfPage < lngRows Then lngRows = RowsOfPage ' 如果指定的行数不超过能容纳的行数,取指定行数
End If
lngBottom = lngTop + lngRowHeight * lngRows ' 根据行数计算表格下边距
If HasColumnHeader Then
lngRows = lngRows + 1
lngTop = lngTop - lngRowHeight
End If
lngLeft = rpt.ScaleWidth
For Each ctl In rpt.Section(acDetail).Controls
If lngLeft > ctl.Left Then lngLeft = ctl.Left ' 表格左边距
If lngRight < ctl.Left + ctl.Width Then lngRight = ctl.Left + ctl.Width ' 表格右边距
' If Style <> 1 Then rpt.Line (ctl.Left, lngTop)-(ctl.Left, lngBottom) ' 画竖线
Next
' If Style <> 1 Then rpt.Line (lngRight, lngTop)-(lngRight, lngBottom) ' 在最右边画竖线
'画横线
If Style <> 2 Then
For intI = 0 To lngRows
rpt.Line (lngLeft, lngTop + lngRowHeight * intI)-(lngRight, lngTop + lngRowHeight * intI)
Next
End If
End Function