비즈니스 개체를 기반으로하는 보고서를 만들었습니다. 지금은 보고서를 PDF (winforms 응용 프로그램)로 직접 렌더링하는 버튼을 추가하려고합니다. 코드에서 나는 ReportViewer
을 만들고 DataSource
이라는 보고서를 만들고 (포함 된 리소스 임) 보고서를 바이트 배열로 렌더링 한 다음 System.IO.File.WriteAllBytes
을 사용하여 바이트 배열을 디스크로 플러시합니다. 내가 끊어 버린 한 가지는 객체의 인스턴스를 어떻게 적절히 지정 하는가이다. "보고서 처리 중에 오류가 발생했습니다."오류가 계속 발생합니다. . IntelliTrace
에서 나는 예외가 발생합니다 "데이터 소스 인스턴스가 데이터 소스 'IssRep'에 대한 공급되지 않은"것을 볼 수있다 (IssRep
다음은 보고서의 데이터 집합 이름입니다 코드 :런타임에 보고서 데이터 소스 인스턴스 설정
Dim warning As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimetype As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim viewer As New ReportViewer
Dim bs As New BindingSource
bs.DataSource = issuedet
Dim rds As New ReportDataSource
rds.Value = bs
viewer.LocalReport.DataSources.Add(rds)
viewer.ProcessingMode = ProcessingMode.Local
viewer.LocalReport.ReportEmbeddedResource = "FRSFE.SR.rdlc"
Dim pdfbytes As Byte()
Try
pdfbytes = viewer.LocalReport.Render("PDF", Nothing, mimetype, encoding, extension, streamids, warning)
File.WriteAllBytes("C:\Shared\FRS\SR.PDF", pdfbytes)
Catch ex As Exception
MsgBox(ex.Message)
End Try
I '내가 .NET에 매우 녹슨 해요하지만 난 그냥 그것을 알아낼 수 없기 때문에 아주 간단에 내가 붙어있어 어떤 확신 해요!