• 大小: 89KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-18
  • 语言: 其他
  • 标签: ReportView  动态  rdcl  

资源简介

ReportView控件动态加载rdlc

资源截图

代码片段和文件信息

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace DynamicMatrix
{
    public partial class Form1 : Form
    {
        private DataSet m_dataSet;
        private MemoryStream m_rdl;
        private List m_allFields = new List();
        private List m_rowFields = new List();
        private List m_columnFields = new List();
        private List m_summarizedFields = new List();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
        }

        private void ShowReport()
        {
            if (m_rdl == null)
                return;
            this.reportViewer1.Reset();
            m_rdl.Position = 0;
            this.reportViewer1.LocalReport.LoadReportDefinition(m_rdl);
            if (m_dataSet != null)
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(“MyData“ m_dataSet.Tables[0]));
            this.reportViewer1.RefreshReport();
        }

        private void GenerateRdl()
        {
            if (m_rdl != null)
                m_rdl.Dispose();
            m_rdl = new MemoryStream();
            RdlGenerator generator = new RdlGenerator();
            generator.AllFields = m_allFields;
            generator.RowFields = m_rowFields;
            generator.ColumnFields = m_columnFields;
            generator.SummarizedFields = m_summarizedFields;
            using (Graphics g = this.CreateGraphics())
            {
                generator.WidthInches = (this.ClientRectangle.Width - 25) / g.DpiX;
            }
            generator.Writexml(m_rdl);
        }

        private void SaveRdl(MemoryStream rdl string filename)
        {
            using (FileStream fs = new FileStream(filename FileMode.Create))
            {
                rdl.WriteTo(fs);
            }
        }

        private List GetAvailableFields()
        {
            DataTable dataTable = m_dataSet.Tables[0];
            List availableFields = new List();
            for (int i = 0; i < dataTable.Columns.Count; i++)
            {
                availableFields.Add(dataTable.Columns[i].ColumnName);
            }
            return availableFields;
        }

        private void OpenDataFile(string filename)
        {
            try
            {
                m_dataSet = new DataSet();
                m_dataSet.Readxml(filename);

                m_allFields = GetAvailableFields();
                m_columnFields.Clear();
                m_rowFields.Clear();
                m_summarizedFields.Clear();
                MatrixDialog matrixDialog = new MatrixDialog();
                matri

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2006-02-28 12:10  DynamicMatrix\bin\
     目录           0  2006-02-28 12:16  DynamicMatrix\bin\Debug\
     文件       39036  2006-02-22 10:32  DynamicMatrix\bin\Debug\demo1.xml
     文件        2347  2006-02-27 23:14  DynamicMatrix\bin\Debug\demo2.xml
     文件      131072  2006-02-28 12:13  DynamicMatrix\bin\Debug\DynamicMatrix.exe
     文件       39036  2006-02-22 10:32  DynamicMatrix\demo1.xml
     文件        2347  2006-02-27 23:14  DynamicMatrix\demo2.xml
     文件        4485  2006-02-28 12:13  DynamicMatrix\DynamicMatrix.csproj
     文件         914  2006-02-22 10:37  DynamicMatrix\DynamicMatrix.sln
     文件       56320  2006-02-28 12:15  DynamicMatrix\DynamicMatrix.suo
     文件        5531  2006-02-28 12:09  DynamicMatrix\Form1.cs
     文件        9849  2006-02-22 19:10  DynamicMatrix\Form1.Designer.cs
     文件        6420  2006-02-22 19:10  DynamicMatrix\Form1.resx
     目录           0  2006-02-28 12:10  DynamicMatrix\Images\
     文件         292  2003-03-03 14:01  DynamicMatrix\Images\DownArrow.gif
     文件         287  2003-03-03 14:01  DynamicMatrix\Images\UpArrow.gif
     文件       12199  2006-02-22 20:07  DynamicMatrix\MatrixDialog.cs
     文件       17405  2006-02-22 18:37  DynamicMatrix\MatrixDialog.Designer.cs
     文件        5814  2006-02-22 18:37  DynamicMatrix\MatrixDialog.resx
     文件       13330  2006-02-28 10:08  DynamicMatrix\MatrixRdlGenerator.cs
     文件         480  2006-02-22 10:37  DynamicMatrix\Program.cs
     目录           0  2006-02-28 12:12  DynamicMatrix\Properties\
     文件        1292  2006-02-22 10:37  DynamicMatrix\Properties\AssemblyInfo.cs
     文件        3361  2006-02-28 12:13  DynamicMatrix\Properties\Resources.Designer.cs
     文件        6443  2006-02-28 12:12  DynamicMatrix\Properties\Resources.resx
     文件        1092  2006-02-28 12:13  DynamicMatrix\Properties\Settings.Designer.cs
     文件         249  2006-02-22 10:37  DynamicMatrix\Properties\Settings.settings
     文件        6089  2006-02-22 15:01  DynamicMatrix\RdlGenerator.cs
     文件      280521  2006-02-27 13:40  DynamicMatrix\ReportDefinition.cs

评论

共有 条评论