哪一位大哥用过datareport打印工资条,请进

giggspig 2003-01-16 11:50:41
哪一位大哥用过datareport打印工资条,格式是:一条是表格的字段,下面一条是记录。然后再下面一条是表格字段,再下去是记录
...全文
44 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bruce tao88 2003-01-17
  • 打赏
  • 举报
回复
用EXCEL可以解决,思路是先声明Excel.application
设置不可见,然后打印,
watt 2003-01-17
  • 打赏
  • 举报
回复
I thing you ought use other control or object. such excel ,then coustomer can define the form easily.
BenBenBoy 2003-01-17
  • 打赏
  • 举报
回复
一条是表格的字段
表格的字段是固定的吧?只是一些名称吧?
那么用rptLabel写倒 Detail Section里面,就放在那些rptTextBox上面!
YanJieBing 2003-01-17
  • 打赏
  • 举报
回复

以上各位思路都挺不错的

我不是用DataReport的,而是自己编写了一个打印控件,效果还不错的!

请参见拙作: Http://YanJieBing.3322.Net

里面有工资报表的示例及控件使用说明。
morris2008 2003-01-17
  • 打赏
  • 举报
回复
这是我以前用过的一段!
Private Sub showtable() '显示工资条的
'On Error Resume Next
Dim Irow, Icol As Integer
Dim Irowcount, Icolcount As Integer

Dim strSource, strDestination As String
strSource = App.path & "\RegisterFee.xlt"
'‘RegisterFee.xls就是一个模版文件
strDestination = App.path & "\Temp.xls"
FileCopy strSource, strDestination
'‘将模版文件拷贝到一个临时文件

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
' xlApp.Visible = False ‘隐藏EXCEL应用程序窗口
Set xlBook = xlApp.Workbooks.Open(strDestination)
'‘打开工作簿,strDestination为一个EXCEL报表文件

' Set xlBook = xlApp.Workbooks.Add(App.Path & "\book1.xlt")
Set xlSheet = xlBook.Worksheets(1)
Dim Fieldlen1 As Integer

If rs.RecordCount < 1 Then
MsgBox ("Error 没有记录!")

Exit Sub
End If

Irowcount = rs.RecordCount '"记录总数
Icolcount = rs.Fields.count '"字段总数

ReDim Fieldlen(Icolcount)
Dim bb As Integer
Dim yy As Integer

For Icol = 1 To Icolcount
bb = LenB(rs.Fields(Icol - 1).Name)
yy = yy + bb
Next
' xlSheet.Columns((Icolcount / 2) + 1).ColumnWidth = yy
xlSheet.Cells(1, (Icolcount / 2) + 1).Value = "工资条"
'xlSheet.Columns(1).ColumnWidth = yy
'xlSheet.Cells(2, (Icolcount / 2) + 1).Value = ""
With rs
For Irow = 2 To Irowcount * 3 + 1
For Icol = 1 To Icolcount
Select Case Irow Mod 3
Case 0
xlSheet.Columns(Icol).ColumnWidth = LenB(.Fields(Icol - 1).Name) '自己加的
xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1).Name
Case 2
xlSheet.Cells(Irow, Icol).Value = ""
Case 1
xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1)
End Select
Next
If (Irow Mod 3) = 1 Then
If Not .EOF Then .MoveNext
End If
' Case 3 '"在Excel中的第一行加标题
'
' xlSheet.Columns(Icol).ColumnWidth = LenB(.Fields(Icol - 1).Name) '自己加的
' xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1).Name
' Case Else
'
' xlSheet.Cells(Irow, Icol).Value = .Fields(Icol - 1)
' End Select
' Next
' If Irow <> 1 And Irow <> 2 And Irow <> 3 Then
' If Not .EOF Then .MoveNext
'
' End If
Next
With xlSheet
.Range(.Cells(1, 1), .Cells(1, Icol - 1)).Font.Name = "宋体"
' "设标题为黑体字
.Range(.Cells(1, 1), .Cells(1, Icol - 1)).Font.Bold = False
' "标题字体加粗
For Irow = 2 To Irowcount * 3
If (Irow Mod 3) = 0 Then
.Range(.Cells(Irow, 1), .Cells(Irow + 1, Icol - 1)).Borders.LineStyle = xlContinuous
End If
Next
' .Range(.Cells(3, 1), .Cells(Irow, Icol - 1)).Borders.LineStyle = xlContinuous
'"设表格边框样式
End With
xlSheet.Columns(2).ColumnWidth = 6
xlApp.Visible = True '"显示表格
' xlBook.Save '"保存"

xlSheet.PrintPreview
' xlSheet.PrintOut

Set xlApp = Nothing '"交还控制给Excel
End With


End Sub
nik_Amis 2003-01-17
  • 打赏
  • 举报
回复
up
yuer0308 2003-01-17
  • 打赏
  • 举报
回复
非常简单你,只要把表头和内容都放在细结中就可以了。

807

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧