zoukankan      html  css  js  c++  java
  • 利用微软平台生成报表,线性图,柱形图

    说来惭愧,以前的工作中一直借助第三方dll进行报表制作,比如线性图,柱形图. 因为现在工作的这家公司不允许随便引入第三方dll,听同事说起可以建rdl类型文件进行引入到winform窗体中,窗体上使用reportViewer控件进行关联展示.下面是我今天摸索3个小时的结果分享.

    第一步.

    首先找到sql server 2012 如下图所示:

    按照向导进行下一步

    后面可以默认点击下一步下一步 完成项目设置.

    选中项目名 添加新项 创建一个空的报表

    拖动迷你图  手动拉大图标 边框会自适应大小 区域内右键选中转换成整个图表  如下图所示

     动态设置标题

    选中线别,右键选择序列化属性

    设置线别宽度.

    winform 界面读取rdl类型界面核心代码如下:

      try
                {
                      string sql = @"SELECT id,RNAME,mark,AGE,WORKYEAR  FROM dbo.Region";
    
    
                    DataTable temp = SQLHelper.GetDataTable(sql, CommandType.Text, null);
                    reportViewer1.LocalReport.ReportPath = AppDomain.CurrentDomain.BaseDirectory + "Report2.rdl";
    
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(reportViewer1.LocalReport.ReportPath);
                    XmlNodeList nodeTemplet = xmlDocument.GetElementsByTagName("DataSet");
                    string dataSetName = "";
                    if (nodeTemplet != null) dataSetName = nodeTemplet.Item(0).Attributes[0].Value;
    
                    reportViewer1.LocalReport.DataSources.Clear();
                    reportViewer1.LocalReport.SetParameters(new ReportParameter("mark", "测试用RDL生成线性图"));
                    reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(dataSetName, temp));
                    this.reportViewer1.RefreshReport();
                }
                catch (Exception ex)
                {
    
                    MessageBox.Show(ex.Message);
                }

     按字段进行统计

  • 相关阅读:
    Swap 2 Variables in Python
    Python Static Method
    Longest Palindromic Substring-Dynamic Programing
    Config Static IP Address manually in Ubuntu
    network FAQ
    [Python] Send emails to the recepients specified in Message["CC"]
    Rare But Powerful Vim Commands.
    主机名 域名 网站名 URL
    Extracts
    关于hibernate一对一配置
  • 原文地址:https://www.cnblogs.com/gudaozi/p/6600022.html
Copyright © 2011-2022 走看看