서버 나 UI없이 임베디드 보고서 정의에서 PDF를 생성하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/138203

  •  02-07-2019
  •  | 
  •  

문제

독립형 실행 파일이 보고서를 생성하고 보고서를 생성하고 보고서를 작성하지 않고 PDF (또는 보고서 뷰어로부터 제공되는 다른 내보내기 옵션 중 하나)로 출력 할 수 있습니까?

보고서 정의는 실행 파일에 포함되어야하며보고 서비스 웹 서비스를 사용해서는 안됩니다.

도움이 되었습니까?

해결책

실제로 보고서 뷰어가 필요하지 않으며 직접 인스턴스화하고 로컬 보고서를 사용할 수 있습니다.

LocalReport report = new LocalReport();
report.ReportPath = "templatepath";
// or use file from resource with report.ReportEmbeddedResource

// add parameters, datasource, etc.

Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;

byte[] bytes;
bytes =report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

// save byte[] to file with FileStream or something else

다른 팁

컨트롤 자체를 보여줄 필요는 없습니다.

ReportViewer rv = new ReportViewer();
rv.LocalReport.ReportPath = "templatepath";
// or use file from resource with rv.LocalReport.ReportEmbeddedResource

// add parameters, datasource, etc.

Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;

byte[] bytes;
bytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

// save byte[] to file with FileStream or something else

그러나 PDF 및 XL 만 렌더링 할 수 있습니다 (ReportViewer Control은 reportig 서비스가 할 수있는 것처럼 Word 및 다른 사람으로 내보내기가 될 수 있기 때문에).

위 코드는 .NET 프레임 워크 및 ReportViewer Control을 사용하는 C#이라는 것을 언급하는 것을 잊었습니다. 체크 아웃 GotReportViewer 빠른 스타트를 위해.

.RDLC 보고서를 매개 변수와 함께 PDF에 직접 전달할 수 있습니까? 보고서를 뽑은 드롭 다운 목록이 두 개 있습니다. PDF로 자동으로 내보낼 때 매개 변수가 작동하지 않습니다. Microsoft.ReportingServices.ReportProcessing.ReportProcessingException : 보고서를 실행하는 데 필요한 하나 이상의 매개 변수가 지정되지 않았습니다.

DropdownList는 ReportViewer를 사용할 때 작동하지만이 단계를 건너 뛰고 싶습니다. 매개 변수가없는 경우 데이터가 PDF로 직접 이동할 수 있습니다. 내 드롭 다운 목록을 ddlyear 및 ddlmonth라고합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top