GridReport 5 0 報表的使用

2021-06-06 03:36:16 字數 3574 閱讀 6940

連線:

'gripreport 連線語句  grid report 連線到的資料庫

public connectstringforgridreport as string = "provider=sqloledb.1;password=password;persist security info=true;user id=sa;initial catalog=dbname;data source=sql server;use procedure for prepare=1;auto translate=true;packet size=4096;workstation id=**pc003;use encryption for data=false;tag with column collation when possible=false"

引用:interop.grprolib,axinterop.grprolib

定義:imports grprolib

private report0 as new gri***report

使用:

'設定報表查詢顯示器控制項的關聯報表物件

axgrdisplayviewer1.report = report0

'啟動報表執行

report.detailgrid.fixcols = 2         '鎖定為兩行

axgrdisplayviewer1.start()

第二種:多條記錄的情況    

frm員工資訊報表.axgrdisplayviewer1.stop()

addhandler report.fetchrecord, addressof ******employeequery   '指標 + 位址  這一句可以不加

private structure matchfieldpairtype

public grfield as igrfield

public matchcolumnindex as integer

end structure      '結構體

public shared sub fillrecordtoreport(byval report as igri***report, byval dt as datatable)

dim matchfieldpairs() as matchfieldpairtype

redim matchfieldpairs(math.min(report.detailgrid.recordset.fields.count, dt.columns.count))

'根據欄位名稱與列名稱進行匹配,建立datareader欄位與grid++report記錄集的字段之間的對應關係

dim matchfieldcount as integer

matchfieldcount = 0

dim i as integer

for i = 0 to dt.columns.count - 1

dim fld as igrfield

for each fld in report.detailgrid.recordset.fields

if string.compare(fld.name, dt.columns.item(i).columnname, true) = 0 then

matchfieldpairs(matchfieldcount).grfield = fld

matchfieldpairs(matchfieldcount).matchcolumnindex = i

matchfieldcount = matchfieldcount + 1

exit for

end if

next fld

next

'將 datatable 中的每一條記錄轉儲到grid++report 的資料集中去

dim dr as datarow

for each dr in dt.rows

for i = 0 to matchfieldcount - 1

if not dr.isnull(matchfieldpairs(i).matchcolumnindex) then

matchfieldpairs(i).grfield.value = dr.item(matchfieldpairs(i).matchcolumnindex)

end if

next

report.detailgrid.recordset.post()

next

end sub   'datatable的gridreport的填充方式

public shared sub fillrecordtoreport(byval report as igri***report, byval dr as sqldatareader)

dim matchfieldpairs() as matchfieldpairtype

redim matchfieldpairs(math.min(report.detailgrid.recordset.fields.count, dr.fieldcount))

'根據欄位名稱與列名稱進行匹配,建立datareader欄位與grid++report記錄集的字段之間的對應關係

dim matchfieldcount as integer

matchfieldcount = 0

dim i as integer

for i = 0 to dr.fieldcount - 1

dim fld as igrfield

for each fld in report.detailgrid.recordset.fields

if string.compare(fld.runningdbfield, dr.getname(i), true) = 0 then

matchfieldpairs(matchfieldcount).grfield = fld

matchfieldpairs(matchfieldcount).matchcolumnindex = i

matchfieldcount = matchfieldcount + 1

exit for

end if

next fld

next

'loop through the contents of the oledbdatareader object.

'將 datareader 中的每一條記錄轉儲到grid++report 的資料集中去

for i = 0 to matchfieldcount - 1

if not dr.isdbnull(matchfieldpairs(i).matchcolumnindex) then

matchfieldpairs(i).grfield.value = dr.getvalue(matchfieldpairs(i).matchcolumnindex)

end if

next

report.detailgrid.recordset.post()

end sub           'datareader的gridreport的填充方式

客戶端: 註冊

regsvr32 grdes50.dll

regsvr32 gregn50.dll

Grid Report實現Web報表

最早接觸報表是在機房收費系統中,那時候還是在c s模式下,所以可以直接在窗體上新增報表。而現在,已經轉戰b s模式下。本篇部落格將介紹如何實現web報表。需求說明 在我們的生活中,也是無處不在,清晰而有條理。在這次的專案中,也需要 在瀏覽器中直接列印報表 非ie列印 與匯出報表 讓使用者使用更安全。...

Grid Report 報表動態使用

1.使用報表設計器新增你要的記錄集和標題行 內容行等內容 2.載入時 gri report subreport new gri report 建立個報表物件 3.建立個構造類 private struct matchfieldpairtype 4.載入報表檔案並新增個fetchrecord 事件 s...

銳浪GridReport交叉報表

一 概述 交叉報表 是行 列方向都有分組的報表。表頭是由上表頭和左表頭組成,從形式上來看,有點類似於數學上的二維數列,橫縱兩列 i,j 兩個座標共同決定了乙個數值。我們的目標就是 將 資料集展現形式 為 轉化成 報表需要的展現形式 姓名 分數日期 200905 200906 張三3.6 200905...