WPF 프로젝트에 참조파일 추가

Microsoft.ReportViewer.Common,

Microsoft.ReportViewer.WinForms,

System.Windows.Forms,

WindowsFormIntegration.

 

 

windowsFormsHost를 끌어다 놓는다.

image

 

image

    <Grid >
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                <GradientStop Color="#FF373737" Offset="1"/>
                
                <GradientStop Color="#FF878787"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Canvas>
            <WindowsFormsHost Canvas.Left="0" Canvas.Top="31" Height="349" Name="windowsFormsHost1" Width="647" />
            <Label Canvas.Left="6" Canvas.Top="6" Content="WPF 리포트 생성" Height="28" Name="label1" />
        </Canvas>
    </Grid>

 

 

CS 코드

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            Microsoft.Reporting.WinForms.ReportViewer reportViewer = new Microsoft.Reporting.WinForms.ReportViewer();
            reportViewer.LocalReport.ReportPath = "Report1.rdlc";
            //리포트뷰 추가 데이터 엑세스 등등작업......
            this.windowsFormsHost1.Child = reportViewer;

            reportViewer.RefreshReport();
        }

+ Recent posts