Dolen

导航

winfrom调用FastReport模板

'存放模板的路径

If Dir(Application.StartupPath & "\ReportsFile\HB\01\IN.frx", FileAttribute.Normal) <> "" Then    

  '加载模板

  rpt_Desi.Load(Application.StartupPath & "\ReportsFile\HB\01\IN.frx")    

  '传参数

  If rpt_Desi.Parameters.FindByName("sUser_c") IsNot Nothing Then        

    rpt_Desi.Parameters.FindByName("sUser_c").Value = G.LogUserName    

  End If    

  '传参数

  If rpt_Desi.Parameters.FindByName("LanguageCode") IsNot Nothing Then        

    rpt_Desi.Parameters.FindByName("LanguageCode").Value = ""    

  End If    

  '传参数

  If rpt_Desi.Parameters.FindByName("LogShopID") IsNot Nothing Then        

    rpt_Desi.Parameters.FindByName("LogShopID").Value = G.LogShopID    

  End If

  '传递连接字符串

  ES_Desi.DesignerSettings.ApplicationConnection = New SqlClient.SqlConnection    

  ES_Desi.DesignerSettings.ApplicationConnection.ConnectionString = DataConn.ConnectionString  

  '判断是否有导出Excel权限,若没有权限隐藏其它菜单,只显示关闭按钮  

  If cmdExcel.Enabled = False Then        

    FastReport.Utils.Config.PreviewSettings.Buttons = PreviewButtons.Close    

  End If    

  '设计模板

  rpt_Desi.Design()

  '直接预览

  'rpt_Desi.Show()

  '直接打印

  'rpt_Desi.Print()

End If

示例源码:

https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.3ad93b44ZEjXSF&id=558395981043

 

posted on 2016-01-07 10:23  Dolen  阅读(2859)  评论(0编辑  收藏  举报