-1

本地报表处理时如何设置报表的文件路径

    private void btnReport_Click(object sender, RoutedEventArgs e)
    {
        try
        {                             
                    if (!_isReportViewerLoaded)
                    {

Tbl_SensorDataSet 是一个具有 Tbl_SensorDataSetTableadapter 的数据集

                        Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1;
                        Tbl_SensorDataSet dataset;
                        string query = Reportingquery;
                        dataset = new Tbl_SensorDataSet();
                        reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                        Tbl_SensorDataSetTableAdapters.GetFilterReadingTableAdapter TableAdapter1 = new Tbl_SensorDataSetTableAdapters.GetFilterReadingTableAdapter();
                        TableAdapter1.ClearBeforeFill = true;
                        TableAdapter1.Fill(dataset.GetFilterReading, query);
                        dataset.BeginInit();
                        reportDataSource1.Name = "DataSet1";
                        reportDataSource1.Value = dataset.GetFilterReading;
                        this._reportViewer.LocalReport.DataSources.Add(reportDataSource1);                            
                        this._reportViewer.LocalReport.ReportPath = "../../SensorReport.rdlc";
                        dataset.EndInit();
                        _reportViewer.RefreshReport();
                        _isReportViewerLoaded = true;
                    }
                }

        catch (Exception ex) { throw ex; }            
    }
4

1 回答 1

2

使用ReportEmbeddedResource而不是ReportPath,因为ReportPath查找文件存在并将ReportEmbeddedResource程序集资源作为完全限定的对象名称进行查找。

这是示例:

report.ReportEmbeddedResource = full Namespace.report.rdlc
于 2012-06-01T07:11:31.803 回答