Rsview 32 报表的步骤
1:用VBA 将数据写到Acess中。代码
Sub DateRepWrite()
Dim sTagName As String
Dim tag1 As Tag
Dim myYear As Integer
Dim myMonth As Integer
Dim myDay As Integer
Dim myTime1 As Date
Dim myTime2 As Date
Dim value1 As Double, value2 As Double, value3 As Double, value4 As Double
Dim sWell(0 To 10) As String
Dim sUnit1(1 To 6) As String
Dim sCol(0 To 13) As String
Dim sUnit2(1 To 10) As String
Dim sCol2(1 To 7) As String
Dim sPump(1 To 6) As String
Dim wkDates As Workspace
Dim dbDates As Database
Dim rsDates As Recordset
Dim mydate As Date
Dim sDBFile As String
Dim sQuery As String
Dim nRow As Integer
Dim nCol As Integer
Dim sgValue As Single
On Error GoTo ErrHandler
‘TagsScanOn1
RepStatus = 1
Set tag1 = gTagDb("system\Year")
myYear = tag1.Value
Set tag1 = gTagDb("system\Month")
myMonth = tag1.Value
Set tag1 = gTagDb("system\Day")
myDay = tag1.Value
Set tag1 = gTagDb("system\Date")
myTime1 = tag1.Value
Set tag1 = gTagDb("system\Time")
myTime2 = tag1.Value
mydate = Now
sWell(0) = "Report2\"
sWell(1) = "Report1\"
sCol(1) = "Test1"
sCol(2) = "Test2"
sCol(3) = "Test3"
sDBFile = gProject.Path & "\VBA\yzwater2.mdb"
Set wkDates = Workspaces(0)
Set dbDates = wkDates.OpenDatabase(sDBFile)
‘向表well_date1添加记录
Set rsDates = dbDates.OpenRecordset("SELECT * FROM well_date1")
rsDates.MoveLast
For nRow = 0 To 1
rsDates.AddNew
rsDates.Fields(0).Value = mydate
rsDates.Fields(1).Value = nRow
For nCol = 1 To 3
sTagName = sWell(nRow) & sCol(nCol)
Set tag1 = gTagDb(sTagName)
rsDates.Fields(nCol).Value = tag1.Value
Next nCol
rsDates.Update
Next nRow
rsDates.Close
Exit Sub
ErrHandler:
gActivity.Log "RSView32 VBA Error" & Err.Number & ":" & Err.Description, roActivityError
Resume Next
End Sub
2:利用ADO datacombo datagrid 控件进行查询和显示。代码网上很多。
3:将Datagrid空间的数据导入EXCEL进行打印。网上有代码。
?