惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
Attack and Defense Labs
Attack and Defense Labs
Jina AI
Jina AI
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
H
Help Net Security
V
Visual Studio Blog
宝玉的分享
宝玉的分享
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
T
Tor Project blog
I
Intezer
美团技术团队
GbyAI
GbyAI
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
Y
Y Combinator Blog
博客园 - 司徒正美
T
Tenable Blog
O
OpenAI News
N
News and Events Feed by Topic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V
Vulnerabilities – Threatpost
P
Palo Alto Networks Blog
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
Help Net Security
Help Net Security

博客园 - rex.ying

ASP.NET+Win2003虚拟主机安全设置 Windows2003服务器安全配置详细篇 - rex.ying - 博客园 mssql 日期格式化函数 devexpress报表控件的使用 关闭wscript.shell VS2005网站和SQL一起打包部署安装心得【转载】 怎样制作VS2008.NET应用程序的安装包 Developer Express XtraGrid使用技巧 UltraGrid文章收集 QQ2009聊天记录破解思路 用独立的DLL来存储图片(资源文件) InstallShield集成.net Framework的安装包制作 导出EXCEL后去除单元格前置的单引号 从SQL Server中导入/导出 Excel 的基本方法 通过远程桌面操作程序出现hook cannot be created(SendKeys语句错误)的解决 ASP.NET自定义控件事件响应 C# 获取任意窗体选中文字 屏幕取词 在 ASP.NET 中执行 URL 重写 仿Google的输入下拉提示框
xtrareport的使用心得(转)
rex.ying · 2009-04-18 · via 博客园 - rex.ying

       近段时间一直在用xtrareport设计报表,所以有一些使用体会和园友们分享。

       以前我一直用reportmachine设计报表,不过这次做B/S开发放弃了rm ,不是rm不好用,应该说rm有许多优点,例如两种报表样式,设计报表的速度快,许多功能符合中国式报表等等。但是rm要用在web开发中还是有一些问题的 ,例如报表预览的时候经常失败,还要更改计算机安全等级(也有园友通过支付宝证书进行代码签名解决此问题,不过计算机没有使用过支付宝,这个方案就失败了 ),最要命的是缺少帮助文件,技术支持不太理想。这里就不在具体的评价两种报表工具的优缺点了 ,还是言归正传谈谈心得体会:

      1、设计报表

       建议通过RibbonEndUserDesignerDemo设计报表。个人感觉要比在VS中设计方便的多。

       2、调用报表

        Dim rpt As New DevExpress.XtraReports.UI.XtraReport
        rpt.LoadLayout(MapPath(Common.ConfigHelper.GetConfigString("ReportFile")) & "CerDetail.repx")
        rpt.DataSource = ds
        ReportViewer1.Report = rpt

        在这顺便提一下,有的同志提问说ds.Tables.Add(dt)会出现ds中已存在此table,其实通过如下方法就可以解决

        Dim dt As New DataTable
        dt = sm.GetList_CerEmp("").Copy
        dt.TableName = "CerEmp"    ‘CerEmp自己定义的
        ds.Tables.Add(dt)

      3、传递参数

        Dim rp As New DevExpress.XtraReports.UI.XtraReport

        Dim item As New DevExpress.XtraReports.Parameters.Parameter
        item.Name = ""

        item.Value = ""
        rp.Parameters.Add(item)

       request parameters 属性设置为NO

      4 、追加空白行

          通过报表的FillEmptySpace事件就可以实现了 ,给出代码

Private Sub OnFillEmptySpace(ByVal sender As Object, ByVal e As DevExpress.XtraReports.UI.BandEventArgs)
    Dim Tab As New XRTable()
    Tab.Size = New Size(692, e.Band.Height)
    Tab.location=New Point(8, 0)
    ' Set the table's borders.
    Tab.BorderWidth = 1
    Tab.Borders = DevExpress.XtraPrinting.BorderSide.All


    for i as integer=1 to Convert.ToInt32(e.Band.Height / Me.tableCell18.Height)
      dim row as new XRTableRow
      Row.Size = New Size(692, 25)
      'Row.location=New Point(8, i*25)

      ' Make the borders for all its cells visible.
      'Row.Borders = DevExpress.XtraPrinting.BorderSide.All

      ' Sets the border width for all its cells.
      'Row.BorderWidth = 1

      ' Add a collection of cells to the row.
      Row.Cells.AddRange(CreateArrayOfCells(i))
     ' e.Band.Controls.Add(row)
      tab.Rows.Add(Row)

    next i
    e.Band.Controls.Add(tab)
End Sub

Private Function CreateArrayOfCells(byval n as integer)
   ' Create an array of XRTableCell objects.
   Dim CellCollection As XRTableCell() = New XRTableCell(4) {}

   ' Initialize the cells.
   Dim i As Integer
   For i = 0 To CellCollection.Length - 1
      CellCollection(i) = New XRTableCell()
      'CellCollection(i).BackColor = Color.Aqua
      CellCollection(i).TextAlignment = TextAlignment.MiddleCenter
      if n =1 then
        CellCollection(0).font=New Font("楷体_GB2312", 9)
        CellCollection(0).text="以下空白"
      end if
      if i=0 then
         CellCollection(0).Size = New Size(67, 25)
      elseif i=1 then
         CellCollection(1).Size = New Size(118, 25)
      elseif i=2 then
         CellCollection(2).Size = New Size(57, 25)
      elseif i=3 then
         CellCollection(3).Size = New Size(214, 25)
      elseif i=4 then
         CellCollection(4).Size = New Size(236, 25)
      end if
   Next

   Return CellCollection
End Function

     5、打印和导出PDF不能很好的支持中文

      如果字体设置成宋体,打印出来会是小方块,建议使用“微软雅黑“、“楷体_GB2312”、“隶书”等

    以上有些可能不能不是最好的方法,请园友指正