방법: LightSwitch에서 SQL Server Reporting Services 보고서 보기
LightSwitch에는 기본 제공 보고 기능이 없지만 SQL Server Reporting Services를 사용하여 보고서를 작성하고 LightSwitch 응용 프로그램에서 볼 수 있습니다. 보고서를 인쇄하여 여러 파일 형식으로 내보낼 수 있는 브라우저 창에 표시합니다.
SQL Server Reporting Services를 사용하여 조직의 보고서를 작성, 배포 및 관리하고 다양한 프로그래밍 기능을 사용하여 보고 기능을 확장 및 사용자 지정할 수 있습니다. SQL Server의 전체 버전이 없더라도 무료 다운로드가 가능한 고급 서비스가 제공되는 SQL Server Express의 Reporting Services를 사용하여 리포트를 생성할 수 있습니다.
보고서를 보려면
솔루션 탐색기에서 클라이언트 프로젝트 노드에 대한 바로 가기 메뉴를 열고 참조 추가를 선택합니다.
참조 관리자 대화 상자에서 어셈블리 노드를 확장하여 프레임워크 노드를 선택하고 System.Windows.Browser 확인란을 선택한 다음 확인 단추를 클릭합니다.
솔루션 탐색기에서 화면의 바로 가기 메뉴를 열고 열기를 선택합니다.
화면 디자이너에서 화면 명령 모음 노드를 확장하고 추가노드를 선택한 다음 새 단추를 선택합니다.
단추 추가 대화 상자에서 새 메서드 옵션 단추를 선택하고, 만들고 있는 단추 이름을 지정한 다음 확인 단추를 선택합니다.
화면 디자이너에서 새 단추를 위한 바로 가기 메뉴를 열고 나서 Edit Execute Code를 선택합니다.
코드 편집기에서 다음 Imports 또는 using 문을 추가합니다.
Imports Microsoft.LightSwitch.Threading Imports System.Runtime.InteropServices.Automation
using Microsoft.LightSwitch.Threading; using System.Runtime.InteropServices.Automation;
다음 코드를 추가하여 보고서를 열고 Uri를 보고서의 URL로 바꾸고 ViewReport를 단추 이름으로 바꿉니다.
Private Sub ViewReport_Execute() Dispatchers.Main.BeginInvoke( Sub() ' Provide the URL for the report that you want to view Dim uri As New Uri("https://www.contoso.com/ReportServer/Pages/ReportViewer.aspx?%2fReportName&rs:Command=Render") If (AutomationFactory.IsAvailable) Then ' This is a desktop app, so shell to the default browser Dim shell = AutomationFactory.CreateObject("Shell.Application") shell.ShellExecute(uri.ToString) ElseIf (Not System.Windows.Application.Current.IsRunningOutOfBrowser) Then ' This is a web app, so navigate to the page System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank") End If End Sub) End Sub
private void ViewReport_Execute() { Dispatchers.Main.BeginInvoke(() => { // Provide the URL for the report that you want to view Uri uri = new Uri("https://www.contoso.com/ReportServer/Pages/ReportViewer.aspx?%2fReportName&rs:Command=Render"); if ((AutomationFactory.IsAvailable)) { // This is a desktop app, so shell to the default browser dynamic shell = AutomationFactory.CreateObject("Shell.Application"); shell.ShellExecute(uri.ToString()); } else if ((!System.Windows.Application.Current.IsRunningOutOfBrowser)) { // This is a web app, so navigate to the page System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank"); } }); }
새 브라우저 창에 보고서가 나타납니다.
팁
보고서 매개 변수, 암호, 렌더링 형식 등을 포함한 보고서를 위한 URL을 구성할 수 있습니다.자세한 내용은 URL 액세스를 참조하십시오.
참고 항목
기타 리소스
SQL Server Express with Advanced Services의 Reporting Services